From 265b455c996f7314ff995ecc3f5e3548365dbe87 Mon Sep 17 00:00:00 2001 From: Greg Fischer Date: Fri, 23 Sep 2022 06:45:32 -0600 Subject: Fix CreatDebugInlinedAt to not invoke def_use_mgr (#4939) --- source/opt/debug_info_manager.cpp | 11 +++-------- test/opt/inline_test.cpp | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/source/opt/debug_info_manager.cpp b/source/opt/debug_info_manager.cpp index 5ec0efb84..3585186f4 100644 --- a/source/opt/debug_info_manager.cpp +++ b/source/opt/debug_info_manager.cpp @@ -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; @@ -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"); @@ -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); diff --git a/test/opt/inline_test.cpp b/test/opt/inline_test.cpp index 7854965e8..f3ff81ce6 100644 --- a/test/opt/inline_test.cpp +++ b/test/opt/inline_test.cpp @@ -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 -- cgit v1.2.3