Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Fischer <greg@lunarg.com>2022-09-01 01:10:17 +0300
committerGitHub <noreply@github.com>2022-09-01 01:10:17 +0300
commitb5d1040b94f390a2981468bbf2752e79c98a4376 (patch)
tree438972f2a633c21945a3a4192c8767f647a2c89a
parentd51dc53d2caf25024c7721647ed2a23819bd509c (diff)
Fix ADCE to mark scope and inlined_at of line instructions as live. (#4910)
-rw-r--r--source/opt/aggressive_dead_code_elim_pass.cpp22
-rw-r--r--source/opt/aggressive_dead_code_elim_pass.h3
2 files changed, 15 insertions, 10 deletions
diff --git a/source/opt/aggressive_dead_code_elim_pass.cpp b/source/opt/aggressive_dead_code_elim_pass.cpp
index 116ab69ae..7fa5c8a95 100644
--- a/source/opt/aggressive_dead_code_elim_pass.cpp
+++ b/source/opt/aggressive_dead_code_elim_pass.cpp
@@ -338,23 +338,25 @@ void AggressiveDCEPass::ProcessWorkList(Function* func) {
}
}
+void AggressiveDCEPass::AddDebugScopeToWorkList(const Instruction* inst) {
+ auto scope = inst->GetDebugScope();
+ auto lex_scope_id = scope.GetLexicalScope();
+ if (lex_scope_id != kNoDebugScope)
+ AddToWorklist(get_def_use_mgr()->GetDef(lex_scope_id));
+ auto inlined_at_id = scope.GetInlinedAt();
+ if (inlined_at_id != kNoInlinedAt)
+ AddToWorklist(get_def_use_mgr()->GetDef(inlined_at_id));
+}
+
void AggressiveDCEPass::AddDebugInstructionsToWorkList(
const Instruction* inst) {
for (auto& line_inst : inst->dbg_line_insts()) {
if (line_inst.IsDebugLineInst()) {
AddOperandsToWorkList(&line_inst);
}
+ AddDebugScopeToWorkList(&line_inst);
}
-
- if (inst->GetDebugScope().GetLexicalScope() != kNoDebugScope) {
- auto* scope =
- get_def_use_mgr()->GetDef(inst->GetDebugScope().GetLexicalScope());
- AddToWorklist(scope);
- }
- if (inst->GetDebugInlinedAt() != kNoInlinedAt) {
- auto* inlined_at = get_def_use_mgr()->GetDef(inst->GetDebugInlinedAt());
- AddToWorklist(inlined_at);
- }
+ AddDebugScopeToWorkList(inst);
}
void AggressiveDCEPass::AddDecorationsToWorkList(const Instruction* inst) {
diff --git a/source/opt/aggressive_dead_code_elim_pass.h b/source/opt/aggressive_dead_code_elim_pass.h
index 1b3fd1e85..c1291dc47 100644
--- a/source/opt/aggressive_dead_code_elim_pass.h
+++ b/source/opt/aggressive_dead_code_elim_pass.h
@@ -178,6 +178,9 @@ class AggressiveDCEPass : public MemPass {
// Adds all decorations of |inst| to the work list.
void AddDecorationsToWorkList(const Instruction* inst);
+ // Adds DebugScope instruction associated with |inst| to the work list.
+ void AddDebugScopeToWorkList(const Instruction* inst);
+
// Adds all debug instruction associated with |inst| to the work list.
void AddDebugInstructionsToWorkList(const Instruction* inst);