Skip to content

Commit 29fe998

Browse files
committed
[VPlan] Preserve debug location when creating branch.
Update createEmptyBasicBlock to preserve the debug location of the previous terminator.
1 parent 547567f commit 29fe998

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,10 @@ VPBasicBlock::createEmptyBasicBlock(VPTransformState::CFGState &CFG) {
280280
if (isa<UnreachableInst>(PredBBTerminator)) {
281281
assert(PredVPSuccessors.size() == 1 &&
282282
"Predecessor ending w/o branch must have single successor.");
283+
DebugLoc DL = PredBBTerminator->getDebugLoc();
283284
PredBBTerminator->eraseFromParent();
284-
BranchInst::Create(NewBB, PredBB);
285+
auto *Br = BranchInst::Create(NewBB, PredBB);
286+
Br->setDebugLoc(DL);
285287
} else {
286288
assert(PredVPSuccessors.size() == 2 &&
287289
"Predecessor ending with branch must have two successors.");

llvm/test/Transforms/LoopVectorize/debugloc.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ define i32 @test_debug_loc_on_branch_in_loop(i32* noalias %src, i32* noalias %ds
7070
; CHECK-NEXT: pred.store.if:
7171
; CHECK-NEXT: [[GEP:%.+]] = getelementptr inbounds i32, i32* %dst, i64 {{.+}}, !dbg [[LOC3]]
7272
; CHECK-NEXT: store i32 0, i32* [[GEP]], align 4, !dbg [[LOC3]]
73-
; CHECK-NEXT: br label %pred.store.continue
74-
; CHECK-NOT: !dbg
73+
; CHECK-NEXT: br label %pred.store.continue, !dbg [[LOC3]]
7574
; CHECK-EMPTY:
7675
;
7776
entry:

0 commit comments

Comments
 (0)