MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / CreateDebugInlinedAt

Method CreateDebugInlinedAt

source/opt/debug_info_manager.cpp:169–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169uint32_t DebugInfoManager::CreateDebugInlinedAt(const Instruction* line,
170 const DebugScope& scope) {
171 uint32_t setId = GetDbgSetImportId();
172
173 if (setId == 0) return kNoInlinedAt;
174
175 spv_operand_type_t line_number_type =
176 spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER;
177
178 // In NonSemantic.Shader.DebugInfo, all constants are IDs of OpConstant,
179 // not literals.
180 if (setId ==
181 context()->get_feature_mgr()->GetExtInstImportId_ShaderDebugInfo())
182 line_number_type = spv_operand_type_t::SPV_OPERAND_TYPE_ID;
183
184 uint32_t line_number = 0;
185 if (line == nullptr) {
186 auto* lexical_scope_inst = GetDbgInst(scope.GetLexicalScope());
187 if (lexical_scope_inst == nullptr) return kNoInlinedAt;
188 CommonDebugInfoInstructions debug_opcode =
189 lexical_scope_inst->GetCommonDebugOpcode();
190 switch (debug_opcode) {
191 case CommonDebugInfoDebugFunction:
192 line_number = lexical_scope_inst->GetSingleWordOperand(
193 kLineOperandIndexDebugFunction);
194 break;
195 case CommonDebugInfoDebugLexicalBlock:
196 line_number = lexical_scope_inst->GetSingleWordOperand(
197 kLineOperandIndexDebugLexicalBlock);
198 break;
199 case CommonDebugInfoDebugTypeComposite:
200 case CommonDebugInfoDebugCompilationUnit:
201 assert(false &&
202 "DebugTypeComposite and DebugCompilationUnit are lexical "
203 "scopes, but we inline functions into a function or a block "
204 "of a function, not into a struct/class or a global scope.");
205 break;
206 default:
207 assert(false &&
208 "Unreachable. a debug extension instruction for a "
209 "lexical scope must be DebugFunction, DebugTypeComposite, "
210 "DebugLexicalBlock, or DebugCompilationUnit.");
211 break;
212 }
213 } else {
214 if (line->opcode() == spv::Op::OpLine) {
215 line_number = line->GetSingleWordOperand(kOpLineOperandLineIndex);
216 } else if (line->GetShaderDebugOpcode() ==
217 NonSemanticShaderDebugInfoDebugLine) {
218 line_number = line->GetSingleWordOperand(kLineOperandIndexDebugLine);
219 } else {
220 assert(false &&
221 "Unreachable. A line instruction must be OpLine or DebugLine");
222 }
223
224 // If we need the line number as an ID, generate that constant now.
225 // If Constant or DefUse managers are invalid, generate constant
226 // directly into the global value section of the module; do not

Callers 1

TESTFunction · 0.80

Calls 15

AddNewConstInGlobalsFunction · 0.85
GetLexicalScopeMethod · 0.80
GetCommonDebugOpcodeMethod · 0.80
GetSingleWordOperandMethod · 0.80
GetShaderDebugOpcodeMethod · 0.80
AreAnalysesValidMethod · 0.80
GetUIntConstIdMethod · 0.80
get_constant_mgrMethod · 0.80
get_type_mgrMethod · 0.80
GetInlinedAtMethod · 0.80
AddOperandMethod · 0.80

Tested by 1

TESTFunction · 0.64