@@ -138,7 +138,7 @@ void InstDebugPrintfPass::GenOutputValues(Instruction* val_inst,
138
138
}
139
139
140
140
void InstDebugPrintfPass::GenOutputCode (
141
- Instruction* printf_inst, uint32_t stage_idx,
141
+ Instruction* printf_inst,
142
142
std::vector<std::unique_ptr<BasicBlock>>* new_blocks) {
143
143
BasicBlock* back_blk_ptr = &*new_blocks->back ();
144
144
InstructionBuilder builder (
@@ -168,14 +168,14 @@ void InstDebugPrintfPass::GenOutputCode(
168
168
});
169
169
GenDebugStreamWrite (
170
170
builder.GetUintConstantId (shader_id_),
171
- builder.GetUintConstantId (uid2offset_[printf_inst->unique_id ()]),
172
- GenStageInfo (stage_idx, &builder), val_ids, &builder);
171
+ builder.GetUintConstantId (uid2offset_[printf_inst->unique_id ()]), val_ids,
172
+ &builder);
173
173
context ()->KillInst (printf_inst);
174
174
}
175
175
176
176
void InstDebugPrintfPass::GenDebugPrintfCode (
177
177
BasicBlock::iterator ref_inst_itr,
178
- UptrVectorIterator<BasicBlock> ref_block_itr, uint32_t stage_idx,
178
+ UptrVectorIterator<BasicBlock> ref_block_itr,
179
179
std::vector<std::unique_ptr<BasicBlock>>* new_blocks) {
180
180
// If not DebugPrintf OpExtInst, return.
181
181
Instruction* printf_inst = &*ref_inst_itr;
@@ -191,7 +191,7 @@ void InstDebugPrintfPass::GenDebugPrintfCode(
191
191
MovePreludeCode (ref_inst_itr, ref_block_itr, &new_blk_ptr);
192
192
new_blocks->push_back (std::move (new_blk_ptr));
193
193
// Generate instructions to output printf args to printf buffer
194
- GenOutputCode (printf_inst, stage_idx, new_blocks);
194
+ GenOutputCode (printf_inst, new_blocks);
195
195
// Caller expects at least two blocks with last block containing remaining
196
196
// code, so end block after instrumentation, create remainder block, and
197
197
// branch to it
@@ -301,8 +301,7 @@ uint32_t InstDebugPrintfPass::GetStreamWriteFunctionId(uint32_t param_cnt) {
301
301
enum {
302
302
kShaderId = 0 ,
303
303
kInstructionIndex = 1 ,
304
- kStageInfo = 2 ,
305
- kFirstParam = 3 ,
304
+ kFirstParam = 2 ,
306
305
};
307
306
// Total param count is common params plus validation-specific
308
307
// params
@@ -312,12 +311,9 @@ uint32_t InstDebugPrintfPass::GetStreamWriteFunctionId(uint32_t param_cnt) {
312
311
analysis::TypeManager* type_mgr = context ()->get_type_mgr ();
313
312
314
313
const analysis::Type* uint_type = GetInteger (32 , false );
315
- const analysis::Vector v4uint (uint_type, 4 );
316
- const analysis::Type* v4uint_type = type_mgr->GetRegisteredType (&v4uint);
317
314
318
315
std::vector<const analysis::Type*> param_types (kFirstParam + param_cnt,
319
316
uint_type);
320
- param_types[kStageInfo ] = v4uint_type;
321
317
std::unique_ptr<Function> output_func = StartFunction (
322
318
param2output_func_id_[param_cnt], type_mgr->GetVoidType (), param_types);
323
319
@@ -330,8 +326,8 @@ uint32_t InstDebugPrintfPass::GetStreamWriteFunctionId(uint32_t param_cnt) {
330
326
context (), &*new_blk_ptr,
331
327
IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping );
332
328
// Gen test if debug output buffer size will not be exceeded.
333
- const uint32_t val_spec_offset = kInstStageOutCnt ;
334
- const uint32_t obuf_record_sz = val_spec_offset + param_cnt;
329
+ const uint32_t first_param_offset = kInstCommonOutInstructionIdx + 1 ;
330
+ const uint32_t obuf_record_sz = first_param_offset + param_cnt;
335
331
const uint32_t buf_id = GetOutputBufferId ();
336
332
const uint32_t buf_uint_ptr_id = GetOutputBufferPtrId ();
337
333
Instruction* obuf_curr_sz_ac_inst = builder.AddAccessChain (
@@ -382,16 +378,9 @@ uint32_t InstDebugPrintfPass::GetStreamWriteFunctionId(uint32_t param_cnt) {
382
378
// Store Instruction Idx
383
379
GenDebugOutputFieldCode (obuf_curr_sz_id, kInstCommonOutInstructionIdx ,
384
380
param_ids[kInstructionIndex ], &builder);
385
- // Store stage info. Stage Idx + 3 words of stage-specific data.
386
- for (uint32_t i = 0 ; i < 4 ; ++i) {
387
- Instruction* field =
388
- builder.AddCompositeExtract (GetUintId (), param_ids[kStageInfo ], {i});
389
- GenDebugOutputFieldCode (obuf_curr_sz_id, kInstCommonOutStageIdx + i,
390
- field->result_id (), &builder);
391
- }
392
381
// Gen writes of validation specific data
393
382
for (uint32_t i = 0 ; i < param_cnt; ++i) {
394
- GenDebugOutputFieldCode (obuf_curr_sz_id, val_spec_offset + i,
383
+ GenDebugOutputFieldCode (obuf_curr_sz_id, first_param_offset + i,
395
384
param_ids[kFirstParam + i], &builder);
396
385
}
397
386
// Close write block and gen merge block
@@ -416,12 +405,12 @@ uint32_t InstDebugPrintfPass::GetStreamWriteFunctionId(uint32_t param_cnt) {
416
405
}
417
406
418
407
void InstDebugPrintfPass::GenDebugStreamWrite (
419
- uint32_t shader_id, uint32_t instruction_idx_id, uint32_t stage_info_id,
408
+ uint32_t shader_id, uint32_t instruction_idx_id,
420
409
const std::vector<uint32_t >& validation_ids, InstructionBuilder* builder) {
421
410
// Call debug output function. Pass func_idx, instruction_idx and
422
411
// validation ids as args.
423
412
uint32_t val_id_cnt = static_cast <uint32_t >(validation_ids.size ());
424
- std::vector<uint32_t > args = {shader_id, instruction_idx_id, stage_info_id };
413
+ std::vector<uint32_t > args = {shader_id, instruction_idx_id};
425
414
(void )args.insert (args.end (), validation_ids.begin (), validation_ids.end ());
426
415
(void )builder->AddFunctionCall (GetVoidId (),
427
416
GetStreamWriteFunctionId (val_id_cnt), args);
@@ -455,10 +444,10 @@ Pass::Status InstDebugPrintfPass::ProcessImpl() {
455
444
// Perform printf instrumentation on each entry point function in module
456
445
InstProcessFunction pfn =
457
446
[this ](BasicBlock::iterator ref_inst_itr,
458
- UptrVectorIterator<BasicBlock> ref_block_itr, uint32_t stage_idx,
447
+ UptrVectorIterator<BasicBlock> ref_block_itr,
448
+ [[maybe_unused]] uint32_t stage_idx,
459
449
std::vector<std::unique_ptr<BasicBlock>>* new_blocks) {
460
- return GenDebugPrintfCode (ref_inst_itr, ref_block_itr, stage_idx,
461
- new_blocks);
450
+ return GenDebugPrintfCode (ref_inst_itr, ref_block_itr, new_blocks);
462
451
};
463
452
(void )InstProcessEntryPointCallTree (pfn);
464
453
// Remove DebugPrintf OpExtInstImport instruction
0 commit comments