Skip to content

Commit

Permalink
Fix CreatDebugInlinedAt to not invoke def_use_mgr (#4939)
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-lunarg authored Sep 23, 2022
1 parent ddbee48 commit 265b455
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions source/opt/debug_info_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ static const uint32_t kOpLineOperandLineIndex = 1;
static const uint32_t kLineOperandIndexDebugFunction = 7;
static const uint32_t kLineOperandIndexDebugLexicalBlock = 5;
static const uint32_t kLineOperandIndexDebugLine = 5;
static const uint32_t kConstanstOperandIndexLiteral = 2;
static const uint32_t kDebugFunctionOperandFunctionIndex = 13;
static const uint32_t kDebugFunctionDefinitionOperandDebugFunctionIndex = 4;
static const uint32_t kDebugFunctionDefinitionOperandOpFunctionIndex = 5;
Expand Down Expand Up @@ -217,12 +216,7 @@ uint32_t DebugInfoManager::CreateDebugInlinedAt(const Instruction* line,
line_number = line->GetSingleWordOperand(kOpLineOperandLineIndex);
} else if (line->GetShader100DebugOpcode() ==
NonSemanticShaderDebugInfo100DebugLine) {
auto const line_number_id =
line->GetSingleWordOperand(kLineOperandIndexDebugLine);
auto const line_number_inst =
context()->get_def_use_mgr()->GetDef(line_number_id);
line_number =
line_number_inst->GetSingleWordOperand(kConstanstOperandIndexLiteral);
line_number = line->GetSingleWordOperand(kLineOperandIndexDebugLine);
} else {
assert(false &&
"Unreachable. A line instruction must be OpLine or DebugLine");
Expand All @@ -235,7 +229,8 @@ uint32_t DebugInfoManager::CreateDebugInlinedAt(const Instruction* line,
// DefUse manager which cannot be done during inlining. The extra
// constants that may be generated here is likely not significant
// and will likely be cleaned up in later passes.
if (line_number_type == spv_operand_type_t::SPV_OPERAND_TYPE_ID) {
if (line_number_type == spv_operand_type_t::SPV_OPERAND_TYPE_ID &&
line->opcode() == SpvOpLine) {
if (!context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse) ||
!context()->AreAnalysesValid(IRContext::Analysis::kAnalysisConstants))
line_number = AddNewConstInGlobals(context(), line_number);
Expand Down
2 changes: 1 addition & 1 deletion test/opt/inline_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4339,7 +4339,7 @@ OpFunctionEnd

TEST_F(InlineTest, CreateDebugInlinedAtFromDebugLine) {
const std::string text = R"(OpCapability Shader
; CHECK: OpExtInst %void %1 DebugInlinedAt %uint_6_0
; CHECK: OpExtInst %void %1 DebugInlinedAt %uint_6
OpExtension "SPV_KHR_non_semantic_info"
%1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
OpMemoryModel Logical GLSL450
Expand Down

0 comments on commit 265b455

Please sign in to comment.