Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move RemoveRedundantDbgInstrs outside of inner loop in JumpThreading #123008

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions llvm/lib/Transforms/Scalar/JumpThreading.cpp
Original file line number Diff line number Diff line change
@@ -330,11 +330,6 @@ bool JumpThreadingPass::runImpl(Function &F_, FunctionAnalysisManager *FAM_,
while (processBlock(&BB)) // Thread all of the branches we can over BB.
Changed = ChangedSinceLastAnalysisUpdate = true;

// Jump threading may have introduced redundant debug values into BB
// which should be removed.
if (Changed)
RemoveRedundantDbgInstrs(&BB);

// Stop processing BB if it's the entry or is now deleted. The following
// routines attempt to eliminate BB and locating a suitable replacement
// for the entry is non-trivial.
@@ -366,7 +361,6 @@ bool JumpThreadingPass::runImpl(Function &F_, FunctionAnalysisManager *FAM_,
// detect and transform nested loops later.
!LoopHeaders.count(&BB) && !LoopHeaders.count(Succ) &&
TryToSimplifyUncondBranchFromEmptyBlock(&BB, DTU.get())) {
RemoveRedundantDbgInstrs(Succ);
// BB is valid for cleanup here because we passed in DTU. F remains
// BB's parent until a DTU->getDomTree() event.
LVI->eraseBlock(&BB);
@@ -377,6 +371,13 @@ bool JumpThreadingPass::runImpl(Function &F_, FunctionAnalysisManager *FAM_,
EverChanged |= Changed;
} while (Changed);

// Jump threading may have introduced redundant debug values into F which
// should be removed.
if (EverChanged)
for (auto &BB : *F) {
RemoveRedundantDbgInstrs(&BB);
}

LoopHeaders.clear();
return EverChanged;
}
3 changes: 2 additions & 1 deletion llvm/test/Transforms/JumpThreading/thread-debug-info.ll
Original file line number Diff line number Diff line change
@@ -96,6 +96,8 @@ exit: ; preds = %bb.f4, %bb.f3, %bb.
; being threaded, the `and` in the function below is optimised away, but its
; debug-info should still be preserved.
; Similarly, the call to f1 gets cloned, its dbg.value should be cloned too.
; Duplicated debug value in land.end.thr_comm is removed by
; RemoveRedundantDbgInstrs pass at the end.
define void @test16(i1 %c, i1 %c2, i1 %c3, i1 %c4) nounwind ssp !dbg !30 {
; CHECK-LABEL: define void @test16(i1
entry:
@@ -109,7 +111,6 @@ lor.lhs.false.i:
br i1 %c3, label %land.end, label %land.end, !dbg !33

; CHECK-LABEL: land.end.thr_comm:
; CHECK-NEXT: #dbg_value(i32 0,
; CHECK-NEXT: #dbg_value(i32 1,
; CHECK-NEXT: call void @f1()
; CHECK-NEXT: br i1 %c4,