debug_info_manager.cpp 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  1. // Copyright (c) 2020 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include "source/opt/debug_info_manager.h"
  15. #include <cassert>
  16. #include "source/opt/ir_context.h"
  17. // Constants for OpenCL.DebugInfo.100 & NonSemantic.Shader.DebugInfo.100
  18. // extension instructions.
  19. static const uint32_t kOpLineOperandLineIndex = 1;
  20. static const uint32_t kLineOperandIndexDebugFunction = 7;
  21. static const uint32_t kLineOperandIndexDebugLexicalBlock = 5;
  22. static const uint32_t kDebugFunctionOperandFunctionIndex = 13;
  23. static const uint32_t kDebugFunctionDefinitionOperandDebugFunctionIndex = 4;
  24. static const uint32_t kDebugFunctionDefinitionOperandOpFunctionIndex = 5;
  25. static const uint32_t kDebugFunctionOperandParentIndex = 9;
  26. static const uint32_t kDebugTypeCompositeOperandParentIndex = 9;
  27. static const uint32_t kDebugLexicalBlockOperandParentIndex = 7;
  28. static const uint32_t kDebugInlinedAtOperandInlinedIndex = 6;
  29. static const uint32_t kDebugExpressOperandOperationIndex = 4;
  30. static const uint32_t kDebugDeclareOperandLocalVariableIndex = 4;
  31. static const uint32_t kDebugDeclareOperandVariableIndex = 5;
  32. static const uint32_t kDebugValueOperandExpressionIndex = 6;
  33. static const uint32_t kDebugOperationOperandOperationIndex = 4;
  34. static const uint32_t kOpVariableOperandStorageClassIndex = 2;
  35. static const uint32_t kDebugLocalVariableOperandParentIndex = 9;
  36. static const uint32_t kExtInstInstructionInIdx = 1;
  37. static const uint32_t kDebugGlobalVariableOperandFlagsIndex = 12;
  38. static const uint32_t kDebugLocalVariableOperandFlagsIndex = 10;
  39. namespace spvtools {
  40. namespace opt {
  41. namespace analysis {
  42. namespace {
  43. void SetInlinedOperand(Instruction* dbg_inlined_at, uint32_t inlined_operand) {
  44. assert(dbg_inlined_at);
  45. assert(dbg_inlined_at->GetCommonDebugOpcode() ==
  46. CommonDebugInfoDebugInlinedAt);
  47. if (dbg_inlined_at->NumOperands() <= kDebugInlinedAtOperandInlinedIndex) {
  48. dbg_inlined_at->AddOperand(
  49. {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {inlined_operand}});
  50. } else {
  51. dbg_inlined_at->SetOperand(kDebugInlinedAtOperandInlinedIndex,
  52. {inlined_operand});
  53. }
  54. }
  55. uint32_t GetInlinedOperand(Instruction* dbg_inlined_at) {
  56. assert(dbg_inlined_at);
  57. assert(dbg_inlined_at->GetCommonDebugOpcode() ==
  58. CommonDebugInfoDebugInlinedAt);
  59. if (dbg_inlined_at->NumOperands() <= kDebugInlinedAtOperandInlinedIndex)
  60. return kNoInlinedAt;
  61. return dbg_inlined_at->GetSingleWordOperand(
  62. kDebugInlinedAtOperandInlinedIndex);
  63. }
  64. bool IsEmptyDebugExpression(Instruction* instr) {
  65. return (instr->GetCommonDebugOpcode() == CommonDebugInfoDebugExpression) &&
  66. instr->NumOperands() == kDebugExpressOperandOperationIndex;
  67. }
  68. } // namespace
  69. DebugInfoManager::DebugInfoManager(IRContext* c) : context_(c) {
  70. AnalyzeDebugInsts(*c->module());
  71. }
  72. uint32_t DebugInfoManager::GetDbgSetImportId() {
  73. uint32_t setId =
  74. context()->get_feature_mgr()->GetExtInstImportId_OpenCL100DebugInfo();
  75. if (setId == 0) {
  76. setId =
  77. context()->get_feature_mgr()->GetExtInstImportId_Shader100DebugInfo();
  78. }
  79. return setId;
  80. }
  81. Instruction* DebugInfoManager::GetDbgInst(uint32_t id) {
  82. auto dbg_inst_it = id_to_dbg_inst_.find(id);
  83. return dbg_inst_it == id_to_dbg_inst_.end() ? nullptr : dbg_inst_it->second;
  84. }
  85. void DebugInfoManager::RegisterDbgInst(Instruction* inst) {
  86. assert(inst->NumInOperands() != 0 &&
  87. (GetDbgSetImportId() == inst->GetInOperand(0).words[0]) &&
  88. "Given instruction is not a debug instruction");
  89. id_to_dbg_inst_[inst->result_id()] = inst;
  90. }
  91. void DebugInfoManager::RegisterDbgFunction(Instruction* inst) {
  92. if (inst->GetOpenCL100DebugOpcode() == OpenCLDebugInfo100DebugFunction) {
  93. auto fn_id = inst->GetSingleWordOperand(kDebugFunctionOperandFunctionIndex);
  94. // Do not register function that has been optimized away.
  95. auto fn_inst = GetDbgInst(fn_id);
  96. if (fn_inst != nullptr) {
  97. assert(GetDbgInst(fn_id)->GetOpenCL100DebugOpcode() ==
  98. OpenCLDebugInfo100DebugInfoNone);
  99. return;
  100. }
  101. assert(
  102. fn_id_to_dbg_fn_.find(fn_id) == fn_id_to_dbg_fn_.end() &&
  103. "Register DebugFunction for a function that already has DebugFunction");
  104. fn_id_to_dbg_fn_[fn_id] = inst;
  105. } else if (inst->GetShader100DebugOpcode() ==
  106. NonSemanticShaderDebugInfo100DebugFunctionDefinition) {
  107. auto fn_id = inst->GetSingleWordOperand(
  108. kDebugFunctionDefinitionOperandOpFunctionIndex);
  109. auto fn_inst = GetDbgInst(inst->GetSingleWordOperand(
  110. kDebugFunctionDefinitionOperandDebugFunctionIndex));
  111. assert(fn_inst && fn_inst->GetShader100DebugOpcode() ==
  112. NonSemanticShaderDebugInfo100DebugFunction);
  113. assert(fn_id_to_dbg_fn_.find(fn_id) == fn_id_to_dbg_fn_.end() &&
  114. "Register DebugFunctionDefinition for a function that already has "
  115. "DebugFunctionDefinition");
  116. fn_id_to_dbg_fn_[fn_id] = fn_inst;
  117. } else {
  118. assert(false && "inst is not a DebugFunction");
  119. }
  120. }
  121. void DebugInfoManager::RegisterDbgDeclare(uint32_t var_id,
  122. Instruction* dbg_declare) {
  123. assert(dbg_declare->GetCommonDebugOpcode() == CommonDebugInfoDebugDeclare ||
  124. dbg_declare->GetCommonDebugOpcode() == CommonDebugInfoDebugValue);
  125. auto dbg_decl_itr = var_id_to_dbg_decl_.find(var_id);
  126. if (dbg_decl_itr == var_id_to_dbg_decl_.end()) {
  127. var_id_to_dbg_decl_[var_id] = {dbg_declare};
  128. } else {
  129. dbg_decl_itr->second.insert(dbg_declare);
  130. }
  131. }
  132. // Create new constant directly into global value area, bypassing the
  133. // Constant manager. This is used when the DefUse or Constant managers
  134. // are invalid and cannot be regenerated due to the module being in an
  135. // inconsistant state e.g. in the middle of significant modification
  136. // such as inlining. Invalidate Constant and DefUse managers if used.
  137. uint32_t AddNewConstInGlobals(IRContext* context, uint32_t const_value) {
  138. uint32_t id = context->TakeNextId();
  139. std::unique_ptr<Instruction> new_const(new Instruction(
  140. context, SpvOpConstant, context->get_type_mgr()->GetUIntTypeId(), id,
  141. {
  142. {spv_operand_type_t::SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER,
  143. {const_value}},
  144. }));
  145. context->module()->AddGlobalValue(std::move(new_const));
  146. context->InvalidateAnalyses(IRContext::kAnalysisConstants);
  147. context->InvalidateAnalyses(IRContext::kAnalysisDefUse);
  148. return id;
  149. }
  150. uint32_t DebugInfoManager::CreateDebugInlinedAt(const Instruction* line,
  151. const DebugScope& scope) {
  152. uint32_t setId = GetDbgSetImportId();
  153. if (setId == 0) return kNoInlinedAt;
  154. spv_operand_type_t line_number_type =
  155. spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER;
  156. // In NonSemantic.Shader.DebugInfo.100, all constants are IDs of OpConstant,
  157. // not literals.
  158. if (setId ==
  159. context()->get_feature_mgr()->GetExtInstImportId_Shader100DebugInfo())
  160. line_number_type = spv_operand_type_t::SPV_OPERAND_TYPE_ID;
  161. uint32_t line_number = 0;
  162. if (line == nullptr) {
  163. auto* lexical_scope_inst = GetDbgInst(scope.GetLexicalScope());
  164. if (lexical_scope_inst == nullptr) return kNoInlinedAt;
  165. CommonDebugInfoInstructions debug_opcode =
  166. lexical_scope_inst->GetCommonDebugOpcode();
  167. switch (debug_opcode) {
  168. case CommonDebugInfoDebugFunction:
  169. line_number = lexical_scope_inst->GetSingleWordOperand(
  170. kLineOperandIndexDebugFunction);
  171. break;
  172. case CommonDebugInfoDebugLexicalBlock:
  173. line_number = lexical_scope_inst->GetSingleWordOperand(
  174. kLineOperandIndexDebugLexicalBlock);
  175. break;
  176. case CommonDebugInfoDebugTypeComposite:
  177. case CommonDebugInfoDebugCompilationUnit:
  178. assert(false &&
  179. "DebugTypeComposite and DebugCompilationUnit are lexical "
  180. "scopes, but we inline functions into a function or a block "
  181. "of a function, not into a struct/class or a global scope.");
  182. break;
  183. default:
  184. assert(false &&
  185. "Unreachable. a debug extension instruction for a "
  186. "lexical scope must be DebugFunction, DebugTypeComposite, "
  187. "DebugLexicalBlock, or DebugCompilationUnit.");
  188. break;
  189. }
  190. } else {
  191. line_number = line->GetSingleWordOperand(kOpLineOperandLineIndex);
  192. // If we need the line number as an ID, generate that constant now.
  193. // If Constant or DefUse managers are invalid, generate constant
  194. // directly into the global value section of the module; do not
  195. // use Constant manager which may attempt to invoke building of the
  196. // DefUse manager which cannot be done during inlining. The extra
  197. // constants that may be generated here is likely not significant
  198. // and will likely be cleaned up in later passes.
  199. if (line_number_type == spv_operand_type_t::SPV_OPERAND_TYPE_ID) {
  200. if (!context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse) ||
  201. !context()->AreAnalysesValid(IRContext::Analysis::kAnalysisConstants))
  202. line_number = AddNewConstInGlobals(context(), line_number);
  203. else
  204. line_number = context()->get_constant_mgr()->GetUIntConst(line_number);
  205. }
  206. }
  207. uint32_t result_id = context()->TakeNextId();
  208. std::unique_ptr<Instruction> inlined_at(new Instruction(
  209. context(), SpvOpExtInst, context()->get_type_mgr()->GetVoidTypeId(),
  210. result_id,
  211. {
  212. {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {setId}},
  213. {spv_operand_type_t::SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER,
  214. {static_cast<uint32_t>(CommonDebugInfoDebugInlinedAt)}},
  215. {line_number_type, {line_number}},
  216. {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {scope.GetLexicalScope()}},
  217. }));
  218. // |scope| already has DebugInlinedAt. We put the existing DebugInlinedAt
  219. // into the Inlined operand of this new DebugInlinedAt.
  220. if (scope.GetInlinedAt() != kNoInlinedAt) {
  221. inlined_at->AddOperand(
  222. {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {scope.GetInlinedAt()}});
  223. }
  224. RegisterDbgInst(inlined_at.get());
  225. if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
  226. context()->get_def_use_mgr()->AnalyzeInstDefUse(inlined_at.get());
  227. context()->module()->AddExtInstDebugInfo(std::move(inlined_at));
  228. return result_id;
  229. }
  230. DebugScope DebugInfoManager::BuildDebugScope(
  231. const DebugScope& callee_instr_scope,
  232. DebugInlinedAtContext* inlined_at_ctx) {
  233. return DebugScope(callee_instr_scope.GetLexicalScope(),
  234. BuildDebugInlinedAtChain(callee_instr_scope.GetInlinedAt(),
  235. inlined_at_ctx));
  236. }
  237. uint32_t DebugInfoManager::BuildDebugInlinedAtChain(
  238. uint32_t callee_inlined_at, DebugInlinedAtContext* inlined_at_ctx) {
  239. if (inlined_at_ctx->GetScopeOfCallInstruction().GetLexicalScope() ==
  240. kNoDebugScope)
  241. return kNoInlinedAt;
  242. // Reuse the already generated DebugInlinedAt chain if exists.
  243. uint32_t already_generated_chain_head_id =
  244. inlined_at_ctx->GetDebugInlinedAtChain(callee_inlined_at);
  245. if (already_generated_chain_head_id != kNoInlinedAt) {
  246. return already_generated_chain_head_id;
  247. }
  248. const uint32_t new_dbg_inlined_at_id =
  249. CreateDebugInlinedAt(inlined_at_ctx->GetLineOfCallInstruction(),
  250. inlined_at_ctx->GetScopeOfCallInstruction());
  251. if (new_dbg_inlined_at_id == kNoInlinedAt) return kNoInlinedAt;
  252. if (callee_inlined_at == kNoInlinedAt) {
  253. inlined_at_ctx->SetDebugInlinedAtChain(kNoInlinedAt, new_dbg_inlined_at_id);
  254. return new_dbg_inlined_at_id;
  255. }
  256. uint32_t chain_head_id = kNoInlinedAt;
  257. uint32_t chain_iter_id = callee_inlined_at;
  258. Instruction* last_inlined_at_in_chain = nullptr;
  259. do {
  260. Instruction* new_inlined_at_in_chain = CloneDebugInlinedAt(
  261. chain_iter_id, /* insert_before */ last_inlined_at_in_chain);
  262. assert(new_inlined_at_in_chain != nullptr);
  263. // Set DebugInlinedAt of the new scope as the head of the chain.
  264. if (chain_head_id == kNoInlinedAt)
  265. chain_head_id = new_inlined_at_in_chain->result_id();
  266. // Previous DebugInlinedAt of the chain must point to the new
  267. // DebugInlinedAt as its Inlined operand to build a recursive
  268. // chain.
  269. if (last_inlined_at_in_chain != nullptr) {
  270. SetInlinedOperand(last_inlined_at_in_chain,
  271. new_inlined_at_in_chain->result_id());
  272. }
  273. last_inlined_at_in_chain = new_inlined_at_in_chain;
  274. chain_iter_id = GetInlinedOperand(new_inlined_at_in_chain);
  275. } while (chain_iter_id != kNoInlinedAt);
  276. // Put |new_dbg_inlined_at_id| into the end of the chain.
  277. SetInlinedOperand(last_inlined_at_in_chain, new_dbg_inlined_at_id);
  278. // Keep the new chain information that will be reused it.
  279. inlined_at_ctx->SetDebugInlinedAtChain(callee_inlined_at, chain_head_id);
  280. return chain_head_id;
  281. }
  282. Instruction* DebugInfoManager::GetDebugOperationWithDeref() {
  283. if (deref_operation_ != nullptr) return deref_operation_;
  284. uint32_t result_id = context()->TakeNextId();
  285. std::unique_ptr<Instruction> deref_operation;
  286. if (context()->get_feature_mgr()->GetExtInstImportId_OpenCL100DebugInfo()) {
  287. deref_operation = std::unique_ptr<Instruction>(new Instruction(
  288. context(), SpvOpExtInst, context()->get_type_mgr()->GetVoidTypeId(),
  289. result_id,
  290. {
  291. {SPV_OPERAND_TYPE_ID, {GetDbgSetImportId()}},
  292. {SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER,
  293. {static_cast<uint32_t>(OpenCLDebugInfo100DebugOperation)}},
  294. {SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_OPERATION,
  295. {static_cast<uint32_t>(OpenCLDebugInfo100Deref)}},
  296. }));
  297. } else {
  298. uint32_t deref_id = context()->get_constant_mgr()->GetUIntConst(
  299. NonSemanticShaderDebugInfo100Deref);
  300. deref_operation = std::unique_ptr<Instruction>(
  301. new Instruction(context(), SpvOpExtInst,
  302. context()->get_type_mgr()->GetVoidTypeId(), result_id,
  303. {
  304. {SPV_OPERAND_TYPE_ID, {GetDbgSetImportId()}},
  305. {SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER,
  306. {static_cast<uint32_t>(
  307. NonSemanticShaderDebugInfo100DebugOperation)}},
  308. {SPV_OPERAND_TYPE_ID, {deref_id}},
  309. }));
  310. }
  311. // Add to the front of |ext_inst_debuginfo_|.
  312. deref_operation_ =
  313. context()->module()->ext_inst_debuginfo_begin()->InsertBefore(
  314. std::move(deref_operation));
  315. RegisterDbgInst(deref_operation_);
  316. if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
  317. context()->get_def_use_mgr()->AnalyzeInstDefUse(deref_operation_);
  318. return deref_operation_;
  319. }
  320. Instruction* DebugInfoManager::DerefDebugExpression(Instruction* dbg_expr) {
  321. assert(dbg_expr->GetCommonDebugOpcode() == CommonDebugInfoDebugExpression);
  322. std::unique_ptr<Instruction> deref_expr(dbg_expr->Clone(context()));
  323. deref_expr->SetResultId(context()->TakeNextId());
  324. deref_expr->InsertOperand(
  325. kDebugExpressOperandOperationIndex,
  326. {SPV_OPERAND_TYPE_ID, {GetDebugOperationWithDeref()->result_id()}});
  327. auto* deref_expr_instr =
  328. context()->ext_inst_debuginfo_end()->InsertBefore(std::move(deref_expr));
  329. AnalyzeDebugInst(deref_expr_instr);
  330. if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
  331. context()->get_def_use_mgr()->AnalyzeInstDefUse(deref_expr_instr);
  332. return deref_expr_instr;
  333. }
  334. Instruction* DebugInfoManager::GetDebugInfoNone() {
  335. if (debug_info_none_inst_ != nullptr) return debug_info_none_inst_;
  336. uint32_t result_id = context()->TakeNextId();
  337. std::unique_ptr<Instruction> dbg_info_none_inst(new Instruction(
  338. context(), SpvOpExtInst, context()->get_type_mgr()->GetVoidTypeId(),
  339. result_id,
  340. {
  341. {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {GetDbgSetImportId()}},
  342. {spv_operand_type_t::SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER,
  343. {static_cast<uint32_t>(CommonDebugInfoDebugInfoNone)}},
  344. }));
  345. // Add to the front of |ext_inst_debuginfo_|.
  346. debug_info_none_inst_ =
  347. context()->module()->ext_inst_debuginfo_begin()->InsertBefore(
  348. std::move(dbg_info_none_inst));
  349. RegisterDbgInst(debug_info_none_inst_);
  350. if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
  351. context()->get_def_use_mgr()->AnalyzeInstDefUse(debug_info_none_inst_);
  352. return debug_info_none_inst_;
  353. }
  354. Instruction* DebugInfoManager::GetEmptyDebugExpression() {
  355. if (empty_debug_expr_inst_ != nullptr) return empty_debug_expr_inst_;
  356. uint32_t result_id = context()->TakeNextId();
  357. std::unique_ptr<Instruction> empty_debug_expr(new Instruction(
  358. context(), SpvOpExtInst, context()->get_type_mgr()->GetVoidTypeId(),
  359. result_id,
  360. {
  361. {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {GetDbgSetImportId()}},
  362. {spv_operand_type_t::SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER,
  363. {static_cast<uint32_t>(CommonDebugInfoDebugExpression)}},
  364. }));
  365. // Add to the front of |ext_inst_debuginfo_|.
  366. empty_debug_expr_inst_ =
  367. context()->module()->ext_inst_debuginfo_begin()->InsertBefore(
  368. std::move(empty_debug_expr));
  369. RegisterDbgInst(empty_debug_expr_inst_);
  370. if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
  371. context()->get_def_use_mgr()->AnalyzeInstDefUse(empty_debug_expr_inst_);
  372. return empty_debug_expr_inst_;
  373. }
  374. Instruction* DebugInfoManager::GetDebugInlinedAt(uint32_t dbg_inlined_at_id) {
  375. auto* inlined_at = GetDbgInst(dbg_inlined_at_id);
  376. if (inlined_at == nullptr) return nullptr;
  377. if (inlined_at->GetCommonDebugOpcode() != CommonDebugInfoDebugInlinedAt) {
  378. return nullptr;
  379. }
  380. return inlined_at;
  381. }
  382. Instruction* DebugInfoManager::CloneDebugInlinedAt(uint32_t clone_inlined_at_id,
  383. Instruction* insert_before) {
  384. auto* inlined_at = GetDebugInlinedAt(clone_inlined_at_id);
  385. if (inlined_at == nullptr) return nullptr;
  386. std::unique_ptr<Instruction> new_inlined_at(inlined_at->Clone(context()));
  387. new_inlined_at->SetResultId(context()->TakeNextId());
  388. RegisterDbgInst(new_inlined_at.get());
  389. if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
  390. context()->get_def_use_mgr()->AnalyzeInstDefUse(new_inlined_at.get());
  391. if (insert_before != nullptr)
  392. return insert_before->InsertBefore(std::move(new_inlined_at));
  393. return context()->module()->ext_inst_debuginfo_end()->InsertBefore(
  394. std::move(new_inlined_at));
  395. }
  396. bool DebugInfoManager::IsVariableDebugDeclared(uint32_t variable_id) {
  397. auto dbg_decl_itr = var_id_to_dbg_decl_.find(variable_id);
  398. return dbg_decl_itr != var_id_to_dbg_decl_.end();
  399. }
  400. bool DebugInfoManager::KillDebugDeclares(uint32_t variable_id) {
  401. bool modified = false;
  402. auto dbg_decl_itr = var_id_to_dbg_decl_.find(variable_id);
  403. if (dbg_decl_itr != var_id_to_dbg_decl_.end()) {
  404. // We intentionally copy the list of DebugDeclare instructions because
  405. // context()->KillInst(dbg_decl) will update |var_id_to_dbg_decl_|. If we
  406. // directly use |dbg_decl_itr->second|, it accesses a dangling pointer.
  407. auto copy_dbg_decls = dbg_decl_itr->second;
  408. for (auto* dbg_decl : copy_dbg_decls) {
  409. context()->KillInst(dbg_decl);
  410. modified = true;
  411. }
  412. var_id_to_dbg_decl_.erase(dbg_decl_itr);
  413. }
  414. return modified;
  415. }
  416. uint32_t DebugInfoManager::GetParentScope(uint32_t child_scope) {
  417. auto dbg_scope_itr = id_to_dbg_inst_.find(child_scope);
  418. assert(dbg_scope_itr != id_to_dbg_inst_.end());
  419. CommonDebugInfoInstructions debug_opcode =
  420. dbg_scope_itr->second->GetCommonDebugOpcode();
  421. uint32_t parent_scope = kNoDebugScope;
  422. switch (debug_opcode) {
  423. case CommonDebugInfoDebugFunction:
  424. parent_scope = dbg_scope_itr->second->GetSingleWordOperand(
  425. kDebugFunctionOperandParentIndex);
  426. break;
  427. case CommonDebugInfoDebugLexicalBlock:
  428. parent_scope = dbg_scope_itr->second->GetSingleWordOperand(
  429. kDebugLexicalBlockOperandParentIndex);
  430. break;
  431. case CommonDebugInfoDebugTypeComposite:
  432. parent_scope = dbg_scope_itr->second->GetSingleWordOperand(
  433. kDebugTypeCompositeOperandParentIndex);
  434. break;
  435. case CommonDebugInfoDebugCompilationUnit:
  436. // DebugCompilationUnit does not have a parent scope.
  437. break;
  438. default:
  439. assert(false &&
  440. "Unreachable. A debug scope instruction must be "
  441. "DebugFunction, DebugTypeComposite, DebugLexicalBlock, "
  442. "or DebugCompilationUnit.");
  443. break;
  444. }
  445. return parent_scope;
  446. }
  447. bool DebugInfoManager::IsAncestorOfScope(uint32_t scope, uint32_t ancestor) {
  448. uint32_t ancestor_scope_itr = scope;
  449. while (ancestor_scope_itr != kNoDebugScope) {
  450. if (ancestor == ancestor_scope_itr) return true;
  451. ancestor_scope_itr = GetParentScope(ancestor_scope_itr);
  452. }
  453. return false;
  454. }
  455. bool DebugInfoManager::IsDeclareVisibleToInstr(Instruction* dbg_declare,
  456. Instruction* scope) {
  457. assert(dbg_declare != nullptr);
  458. assert(scope != nullptr);
  459. std::vector<uint32_t> scope_ids;
  460. if (scope->opcode() == SpvOpPhi) {
  461. scope_ids.push_back(scope->GetDebugScope().GetLexicalScope());
  462. for (uint32_t i = 0; i < scope->NumInOperands(); i += 2) {
  463. auto* value = context()->get_def_use_mgr()->GetDef(
  464. scope->GetSingleWordInOperand(i));
  465. if (value != nullptr)
  466. scope_ids.push_back(value->GetDebugScope().GetLexicalScope());
  467. }
  468. } else {
  469. scope_ids.push_back(scope->GetDebugScope().GetLexicalScope());
  470. }
  471. uint32_t dbg_local_var_id =
  472. dbg_declare->GetSingleWordOperand(kDebugDeclareOperandLocalVariableIndex);
  473. auto dbg_local_var_itr = id_to_dbg_inst_.find(dbg_local_var_id);
  474. assert(dbg_local_var_itr != id_to_dbg_inst_.end());
  475. uint32_t decl_scope_id = dbg_local_var_itr->second->GetSingleWordOperand(
  476. kDebugLocalVariableOperandParentIndex);
  477. // If the scope of DebugDeclare is an ancestor scope of the instruction's
  478. // scope, the local variable is visible to the instruction.
  479. for (uint32_t scope_id : scope_ids) {
  480. if (scope_id != kNoDebugScope &&
  481. IsAncestorOfScope(scope_id, decl_scope_id)) {
  482. return true;
  483. }
  484. }
  485. return false;
  486. }
  487. bool DebugInfoManager::AddDebugValueIfVarDeclIsVisible(
  488. Instruction* scope_and_line, uint32_t variable_id, uint32_t value_id,
  489. Instruction* insert_pos,
  490. std::unordered_set<Instruction*>* invisible_decls) {
  491. assert(scope_and_line != nullptr);
  492. auto dbg_decl_itr = var_id_to_dbg_decl_.find(variable_id);
  493. if (dbg_decl_itr == var_id_to_dbg_decl_.end()) return false;
  494. bool modified = false;
  495. for (auto* dbg_decl_or_val : dbg_decl_itr->second) {
  496. if (!IsDeclareVisibleToInstr(dbg_decl_or_val, scope_and_line)) {
  497. if (invisible_decls) invisible_decls->insert(dbg_decl_or_val);
  498. continue;
  499. }
  500. // Avoid inserting the new DebugValue between OpPhi or OpVariable
  501. // instructions.
  502. Instruction* insert_before = insert_pos->NextNode();
  503. while (insert_before->opcode() == SpvOpPhi ||
  504. insert_before->opcode() == SpvOpVariable) {
  505. insert_before = insert_before->NextNode();
  506. }
  507. modified |= AddDebugValueForDecl(dbg_decl_or_val, value_id, insert_before,
  508. scope_and_line) != nullptr;
  509. }
  510. return modified;
  511. }
  512. Instruction* DebugInfoManager::AddDebugValueForDecl(
  513. Instruction* dbg_decl, uint32_t value_id, Instruction* insert_before,
  514. Instruction* scope_and_line) {
  515. if (dbg_decl == nullptr || !IsDebugDeclare(dbg_decl)) return nullptr;
  516. std::unique_ptr<Instruction> dbg_val(dbg_decl->Clone(context()));
  517. dbg_val->SetResultId(context()->TakeNextId());
  518. dbg_val->SetInOperand(kExtInstInstructionInIdx, {CommonDebugInfoDebugValue});
  519. dbg_val->SetOperand(kDebugDeclareOperandVariableIndex, {value_id});
  520. dbg_val->SetOperand(kDebugValueOperandExpressionIndex,
  521. {GetEmptyDebugExpression()->result_id()});
  522. dbg_val->UpdateDebugInfoFrom(scope_and_line);
  523. auto* added_dbg_val = insert_before->InsertBefore(std::move(dbg_val));
  524. AnalyzeDebugInst(added_dbg_val);
  525. if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
  526. context()->get_def_use_mgr()->AnalyzeInstDefUse(added_dbg_val);
  527. if (context()->AreAnalysesValid(
  528. IRContext::Analysis::kAnalysisInstrToBlockMapping)) {
  529. auto insert_blk = context()->get_instr_block(insert_before);
  530. context()->set_instr_block(added_dbg_val, insert_blk);
  531. }
  532. return added_dbg_val;
  533. }
  534. uint32_t DebugInfoManager::GetVulkanDebugOperation(Instruction* inst) {
  535. assert(inst->GetShader100DebugOpcode() ==
  536. NonSemanticShaderDebugInfo100DebugOperation &&
  537. "inst must be Vulkan DebugOperation");
  538. return context()
  539. ->get_constant_mgr()
  540. ->GetConstantFromInst(context()->get_def_use_mgr()->GetDef(
  541. inst->GetSingleWordOperand(kDebugOperationOperandOperationIndex)))
  542. ->GetU32();
  543. }
  544. uint32_t DebugInfoManager::GetVariableIdOfDebugValueUsedForDeclare(
  545. Instruction* inst) {
  546. if (inst->GetCommonDebugOpcode() != CommonDebugInfoDebugValue) return 0;
  547. auto* expr =
  548. GetDbgInst(inst->GetSingleWordOperand(kDebugValueOperandExpressionIndex));
  549. if (expr == nullptr) return 0;
  550. if (expr->NumOperands() != kDebugExpressOperandOperationIndex + 1) return 0;
  551. auto* operation = GetDbgInst(
  552. expr->GetSingleWordOperand(kDebugExpressOperandOperationIndex));
  553. if (operation == nullptr) return 0;
  554. // OpenCL.DebugInfo.100 contains a literal for the operation, Vulkan uses an
  555. // OpConstant.
  556. if (inst->IsOpenCL100DebugInstr()) {
  557. if (operation->GetSingleWordOperand(kDebugOperationOperandOperationIndex) !=
  558. OpenCLDebugInfo100Deref) {
  559. return 0;
  560. }
  561. } else {
  562. uint32_t operation_const = GetVulkanDebugOperation(operation);
  563. if (operation_const != NonSemanticShaderDebugInfo100Deref) {
  564. return 0;
  565. }
  566. }
  567. uint32_t var_id =
  568. inst->GetSingleWordOperand(kDebugDeclareOperandVariableIndex);
  569. if (!context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse)) {
  570. assert(false &&
  571. "Checking a DebugValue can be used for declare needs DefUseManager");
  572. return 0;
  573. }
  574. auto* var = context()->get_def_use_mgr()->GetDef(var_id);
  575. if (var->opcode() == SpvOpVariable &&
  576. SpvStorageClass(var->GetSingleWordOperand(
  577. kOpVariableOperandStorageClassIndex)) == SpvStorageClassFunction) {
  578. return var_id;
  579. }
  580. return 0;
  581. }
  582. bool DebugInfoManager::IsDebugDeclare(Instruction* instr) {
  583. if (!instr->IsCommonDebugInstr()) return false;
  584. return instr->GetCommonDebugOpcode() == CommonDebugInfoDebugDeclare ||
  585. GetVariableIdOfDebugValueUsedForDeclare(instr) != 0;
  586. }
  587. void DebugInfoManager::ReplaceAllUsesInDebugScopeWithPredicate(
  588. uint32_t before, uint32_t after,
  589. const std::function<bool(Instruction*)>& predicate) {
  590. auto scope_id_to_users_itr = scope_id_to_users_.find(before);
  591. if (scope_id_to_users_itr != scope_id_to_users_.end()) {
  592. for (Instruction* inst : scope_id_to_users_itr->second) {
  593. if (predicate(inst)) inst->UpdateLexicalScope(after);
  594. }
  595. scope_id_to_users_[after] = scope_id_to_users_itr->second;
  596. scope_id_to_users_.erase(scope_id_to_users_itr);
  597. }
  598. auto inlinedat_id_to_users_itr = inlinedat_id_to_users_.find(before);
  599. if (inlinedat_id_to_users_itr != inlinedat_id_to_users_.end()) {
  600. for (Instruction* inst : inlinedat_id_to_users_itr->second) {
  601. if (predicate(inst)) inst->UpdateDebugInlinedAt(after);
  602. }
  603. inlinedat_id_to_users_[after] = inlinedat_id_to_users_itr->second;
  604. inlinedat_id_to_users_.erase(inlinedat_id_to_users_itr);
  605. }
  606. }
  607. void DebugInfoManager::ClearDebugScopeAndInlinedAtUses(Instruction* inst) {
  608. auto scope_id_to_users_itr = scope_id_to_users_.find(inst->result_id());
  609. if (scope_id_to_users_itr != scope_id_to_users_.end()) {
  610. scope_id_to_users_.erase(scope_id_to_users_itr);
  611. }
  612. auto inlinedat_id_to_users_itr =
  613. inlinedat_id_to_users_.find(inst->result_id());
  614. if (inlinedat_id_to_users_itr != inlinedat_id_to_users_.end()) {
  615. inlinedat_id_to_users_.erase(inlinedat_id_to_users_itr);
  616. }
  617. }
  618. void DebugInfoManager::AnalyzeDebugInst(Instruction* inst) {
  619. if (inst->GetDebugScope().GetLexicalScope() != kNoDebugScope) {
  620. auto& users = scope_id_to_users_[inst->GetDebugScope().GetLexicalScope()];
  621. users.insert(inst);
  622. }
  623. if (inst->GetDebugInlinedAt() != kNoInlinedAt) {
  624. auto& users = inlinedat_id_to_users_[inst->GetDebugInlinedAt()];
  625. users.insert(inst);
  626. }
  627. if (!inst->IsCommonDebugInstr()) return;
  628. RegisterDbgInst(inst);
  629. if (inst->GetOpenCL100DebugOpcode() == OpenCLDebugInfo100DebugFunction ||
  630. inst->GetShader100DebugOpcode() ==
  631. NonSemanticShaderDebugInfo100DebugFunctionDefinition) {
  632. RegisterDbgFunction(inst);
  633. }
  634. if (deref_operation_ == nullptr &&
  635. inst->GetOpenCL100DebugOpcode() == OpenCLDebugInfo100DebugOperation &&
  636. inst->GetSingleWordOperand(kDebugOperationOperandOperationIndex) ==
  637. OpenCLDebugInfo100Deref) {
  638. deref_operation_ = inst;
  639. }
  640. if (deref_operation_ == nullptr &&
  641. inst->GetShader100DebugOpcode() ==
  642. NonSemanticShaderDebugInfo100DebugOperation) {
  643. uint32_t operation_const = GetVulkanDebugOperation(inst);
  644. if (operation_const == NonSemanticShaderDebugInfo100Deref) {
  645. deref_operation_ = inst;
  646. }
  647. }
  648. if (debug_info_none_inst_ == nullptr &&
  649. inst->GetCommonDebugOpcode() == CommonDebugInfoDebugInfoNone) {
  650. debug_info_none_inst_ = inst;
  651. }
  652. if (empty_debug_expr_inst_ == nullptr && IsEmptyDebugExpression(inst)) {
  653. empty_debug_expr_inst_ = inst;
  654. }
  655. if (inst->GetCommonDebugOpcode() == CommonDebugInfoDebugDeclare) {
  656. uint32_t var_id =
  657. inst->GetSingleWordOperand(kDebugDeclareOperandVariableIndex);
  658. RegisterDbgDeclare(var_id, inst);
  659. }
  660. if (uint32_t var_id = GetVariableIdOfDebugValueUsedForDeclare(inst)) {
  661. RegisterDbgDeclare(var_id, inst);
  662. }
  663. }
  664. void DebugInfoManager::ConvertDebugGlobalToLocalVariable(
  665. Instruction* dbg_global_var, Instruction* local_var) {
  666. if (dbg_global_var->GetCommonDebugOpcode() !=
  667. CommonDebugInfoDebugGlobalVariable) {
  668. return;
  669. }
  670. assert(local_var->opcode() == SpvOpVariable ||
  671. local_var->opcode() == SpvOpFunctionParameter);
  672. // Convert |dbg_global_var| to DebugLocalVariable
  673. dbg_global_var->SetInOperand(kExtInstInstructionInIdx,
  674. {CommonDebugInfoDebugLocalVariable});
  675. auto flags = dbg_global_var->GetSingleWordOperand(
  676. kDebugGlobalVariableOperandFlagsIndex);
  677. for (uint32_t i = dbg_global_var->NumInOperands() - 1;
  678. i >= kDebugLocalVariableOperandFlagsIndex; --i) {
  679. dbg_global_var->RemoveOperand(i);
  680. }
  681. dbg_global_var->SetOperand(kDebugLocalVariableOperandFlagsIndex, {flags});
  682. context()->ForgetUses(dbg_global_var);
  683. context()->AnalyzeUses(dbg_global_var);
  684. // Create a DebugDeclare
  685. std::unique_ptr<Instruction> new_dbg_decl(new Instruction(
  686. context(), SpvOpExtInst, context()->get_type_mgr()->GetVoidTypeId(),
  687. context()->TakeNextId(),
  688. {
  689. {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {GetDbgSetImportId()}},
  690. {spv_operand_type_t::SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER,
  691. {static_cast<uint32_t>(CommonDebugInfoDebugDeclare)}},
  692. {spv_operand_type_t::SPV_OPERAND_TYPE_ID,
  693. {dbg_global_var->result_id()}},
  694. {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {local_var->result_id()}},
  695. {spv_operand_type_t::SPV_OPERAND_TYPE_ID,
  696. {GetEmptyDebugExpression()->result_id()}},
  697. }));
  698. // Must insert after all OpVariables in block
  699. Instruction* insert_before = local_var;
  700. while (insert_before->opcode() == SpvOpVariable)
  701. insert_before = insert_before->NextNode();
  702. auto* added_dbg_decl = insert_before->InsertBefore(std::move(new_dbg_decl));
  703. if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse))
  704. context()->get_def_use_mgr()->AnalyzeInstDefUse(added_dbg_decl);
  705. if (context()->AreAnalysesValid(
  706. IRContext::Analysis::kAnalysisInstrToBlockMapping)) {
  707. auto insert_blk = context()->get_instr_block(local_var);
  708. context()->set_instr_block(added_dbg_decl, insert_blk);
  709. }
  710. }
  711. void DebugInfoManager::AnalyzeDebugInsts(Module& module) {
  712. deref_operation_ = nullptr;
  713. debug_info_none_inst_ = nullptr;
  714. empty_debug_expr_inst_ = nullptr;
  715. module.ForEachInst([this](Instruction* cpi) { AnalyzeDebugInst(cpi); });
  716. // Move |empty_debug_expr_inst_| to the beginning of the debug instruction
  717. // list.
  718. if (empty_debug_expr_inst_ != nullptr &&
  719. empty_debug_expr_inst_->PreviousNode() != nullptr &&
  720. empty_debug_expr_inst_->PreviousNode()->IsCommonDebugInstr()) {
  721. empty_debug_expr_inst_->InsertBefore(
  722. &*context()->module()->ext_inst_debuginfo_begin());
  723. }
  724. // Move |debug_info_none_inst_| to the beginning of the debug instruction
  725. // list.
  726. if (debug_info_none_inst_ != nullptr &&
  727. debug_info_none_inst_->PreviousNode() != nullptr &&
  728. debug_info_none_inst_->PreviousNode()->IsCommonDebugInstr()) {
  729. debug_info_none_inst_->InsertBefore(
  730. &*context()->module()->ext_inst_debuginfo_begin());
  731. }
  732. }
  733. void DebugInfoManager::ClearDebugInfo(Instruction* instr) {
  734. auto scope_id_to_users_itr =
  735. scope_id_to_users_.find(instr->GetDebugScope().GetLexicalScope());
  736. if (scope_id_to_users_itr != scope_id_to_users_.end()) {
  737. scope_id_to_users_itr->second.erase(instr);
  738. }
  739. auto inlinedat_id_to_users_itr =
  740. inlinedat_id_to_users_.find(instr->GetDebugInlinedAt());
  741. if (inlinedat_id_to_users_itr != inlinedat_id_to_users_.end()) {
  742. inlinedat_id_to_users_itr->second.erase(instr);
  743. }
  744. if (instr == nullptr || !instr->IsCommonDebugInstr()) {
  745. return;
  746. }
  747. id_to_dbg_inst_.erase(instr->result_id());
  748. if (instr->GetOpenCL100DebugOpcode() == OpenCLDebugInfo100DebugFunction) {
  749. auto fn_id =
  750. instr->GetSingleWordOperand(kDebugFunctionOperandFunctionIndex);
  751. fn_id_to_dbg_fn_.erase(fn_id);
  752. }
  753. if (instr->GetShader100DebugOpcode() ==
  754. NonSemanticShaderDebugInfo100DebugFunction) {
  755. auto fn_id = instr->GetSingleWordOperand(
  756. kDebugFunctionDefinitionOperandOpFunctionIndex);
  757. fn_id_to_dbg_fn_.erase(fn_id);
  758. }
  759. if (instr->GetCommonDebugOpcode() == CommonDebugInfoDebugDeclare ||
  760. instr->GetCommonDebugOpcode() == CommonDebugInfoDebugValue) {
  761. auto var_or_value_id =
  762. instr->GetSingleWordOperand(kDebugDeclareOperandVariableIndex);
  763. auto dbg_decl_itr = var_id_to_dbg_decl_.find(var_or_value_id);
  764. if (dbg_decl_itr != var_id_to_dbg_decl_.end()) {
  765. dbg_decl_itr->second.erase(instr);
  766. }
  767. }
  768. if (deref_operation_ == instr) {
  769. deref_operation_ = nullptr;
  770. for (auto dbg_instr_itr = context()->module()->ext_inst_debuginfo_begin();
  771. dbg_instr_itr != context()->module()->ext_inst_debuginfo_end();
  772. ++dbg_instr_itr) {
  773. // OpenCL.DebugInfo.100 contains the operation as a literal operand, in
  774. // Vulkan it's referenced as an OpConstant.
  775. if (instr != &*dbg_instr_itr &&
  776. dbg_instr_itr->GetOpenCL100DebugOpcode() ==
  777. OpenCLDebugInfo100DebugOperation &&
  778. dbg_instr_itr->GetSingleWordOperand(
  779. kDebugOperationOperandOperationIndex) ==
  780. OpenCLDebugInfo100Deref) {
  781. deref_operation_ = &*dbg_instr_itr;
  782. break;
  783. } else if (instr != &*dbg_instr_itr &&
  784. dbg_instr_itr->GetShader100DebugOpcode() ==
  785. NonSemanticShaderDebugInfo100DebugOperation) {
  786. uint32_t operation_const = GetVulkanDebugOperation(&*dbg_instr_itr);
  787. if (operation_const == NonSemanticShaderDebugInfo100Deref) {
  788. deref_operation_ = &*dbg_instr_itr;
  789. break;
  790. }
  791. }
  792. }
  793. }
  794. if (debug_info_none_inst_ == instr) {
  795. debug_info_none_inst_ = nullptr;
  796. for (auto dbg_instr_itr = context()->module()->ext_inst_debuginfo_begin();
  797. dbg_instr_itr != context()->module()->ext_inst_debuginfo_end();
  798. ++dbg_instr_itr) {
  799. if (instr != &*dbg_instr_itr && dbg_instr_itr->GetCommonDebugOpcode() ==
  800. CommonDebugInfoDebugInfoNone) {
  801. debug_info_none_inst_ = &*dbg_instr_itr;
  802. break;
  803. }
  804. }
  805. }
  806. if (empty_debug_expr_inst_ == instr) {
  807. empty_debug_expr_inst_ = nullptr;
  808. for (auto dbg_instr_itr = context()->module()->ext_inst_debuginfo_begin();
  809. dbg_instr_itr != context()->module()->ext_inst_debuginfo_end();
  810. ++dbg_instr_itr) {
  811. if (instr != &*dbg_instr_itr && IsEmptyDebugExpression(&*dbg_instr_itr)) {
  812. empty_debug_expr_inst_ = &*dbg_instr_itr;
  813. break;
  814. }
  815. }
  816. }
  817. }
  818. } // namespace analysis
  819. } // namespace opt
  820. } // namespace spvtools