aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopUtils.cpp
diff options
context:
space:
mode:
authorJeremy Morse <jeremy.morse@sony.com>2025-06-11 14:51:13 +0100
committerJeremy Morse <jeremy.morse@sony.com>2025-06-11 14:52:17 +0100
commit76197ea6f91f802467f2614e1217e99eb4037200 (patch)
tree7398905a7079d66ec996598a4a9ec4043c1d05ec /llvm/lib/Transforms/Utils/LoopUtils.cpp
parent46d9abbba2ad63c0280d4248cc2349de78439294 (diff)
downloadllvm-76197ea6f91f802467f2614e1217e99eb4037200.zip
llvm-76197ea6f91f802467f2614e1217e99eb4037200.tar.gz
llvm-76197ea6f91f802467f2614e1217e99eb4037200.tar.bz2
Revert "[DebugInfo][RemoveDIs] Remove some debug intrinsic-only codepaths (#143451)"
This reverts commit c71a2e688828ab3ede4fb54168a674ff68396f61. /me squints -- this is hitting an assertion I thought had been deleted, will revert and investigate for a bit.
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUtils.cpp36
1 files changed, 25 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index ff69fa9..0681ebc 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -606,6 +606,7 @@ void llvm::deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE,
// Use a map to unique and a vector to guarantee deterministic ordering.
llvm::SmallDenseSet<DebugVariable, 4> DeadDebugSet;
+ llvm::SmallVector<DbgVariableIntrinsic *, 4> DeadDebugInst;
llvm::SmallVector<DbgVariableRecord *, 4> DeadDbgVariableRecords;
if (ExitBlock) {
@@ -632,19 +633,29 @@ void llvm::deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE,
U.set(Poison);
}
- // For one of each variable encountered, preserve a debug record (set
+ // RemoveDIs: do the same as below for DbgVariableRecords.
+ if (Block->IsNewDbgInfoFormat) {
+ for (DbgVariableRecord &DVR : llvm::make_early_inc_range(
+ filterDbgVars(I.getDbgRecordRange()))) {
+ DebugVariable Key(DVR.getVariable(), DVR.getExpression(),
+ DVR.getDebugLoc().get());
+ if (!DeadDebugSet.insert(Key).second)
+ continue;
+ // Unlinks the DVR from it's container, for later insertion.
+ DVR.removeFromParent();
+ DeadDbgVariableRecords.push_back(&DVR);
+ }
+ }
+
+ // For one of each variable encountered, preserve a debug intrinsic (set
// to Poison) and transfer it to the loop exit. This terminates any
// variable locations that were set during the loop.
- for (DbgVariableRecord &DVR :
- llvm::make_early_inc_range(filterDbgVars(I.getDbgRecordRange()))) {
- DebugVariable Key(DVR.getVariable(), DVR.getExpression(),
- DVR.getDebugLoc().get());
- if (!DeadDebugSet.insert(Key).second)
- continue;
- // Unlinks the DVR from it's container, for later insertion.
- DVR.removeFromParent();
- DeadDbgVariableRecords.push_back(&DVR);
- }
+ auto *DVI = dyn_cast<DbgVariableIntrinsic>(&I);
+ if (!DVI)
+ continue;
+ if (!DeadDebugSet.insert(DebugVariable(DVI)).second)
+ continue;
+ DeadDebugInst.push_back(DVI);
}
// After the loop has been deleted all the values defined and modified
@@ -660,6 +671,9 @@ void llvm::deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE,
"There should be a non-PHI instruction in exit block, else these "
"instructions will have no parent.");
+ for (auto *DVI : DeadDebugInst)
+ DVI->moveBefore(*ExitBlock, InsertDbgValueBefore);
+
// Due to the "head" bit in BasicBlock::iterator, we're going to insert
// each DbgVariableRecord right at the start of the block, wheras dbg.values
// would be repeatedly inserted before the first instruction. To replicate