[VPlan] Preserve debug location when creating branch.

Update createEmptyBasicBlock to preserve the debug location of the
previous terminator.
This commit is contained in:
Florian Hahn 2022-04-08 17:22:38 +02:00
parent 547567fe2b
commit 29fe998eaa
No known key found for this signature in database
GPG Key ID: CF59919C6547A668
2 changed files with 4 additions and 3 deletions

View File

@ -280,8 +280,10 @@ VPBasicBlock::createEmptyBasicBlock(VPTransformState::CFGState &CFG) {
if (isa<UnreachableInst>(PredBBTerminator)) {
assert(PredVPSuccessors.size() == 1 &&
"Predecessor ending w/o branch must have single successor.");
DebugLoc DL = PredBBTerminator->getDebugLoc();
PredBBTerminator->eraseFromParent();
BranchInst::Create(NewBB, PredBB);
auto *Br = BranchInst::Create(NewBB, PredBB);
Br->setDebugLoc(DL);
} else {
assert(PredVPSuccessors.size() == 2 &&
"Predecessor ending with branch must have two successors.");

View File

@ -70,8 +70,7 @@ define i32 @test_debug_loc_on_branch_in_loop(i32* noalias %src, i32* noalias %ds
; CHECK-NEXT: pred.store.if:
; CHECK-NEXT: [[GEP:%.+]] = getelementptr inbounds i32, i32* %dst, i64 {{.+}}, !dbg [[LOC3]]
; CHECK-NEXT: store i32 0, i32* [[GEP]], align 4, !dbg [[LOC3]]
; CHECK-NEXT: br label %pred.store.continue
; CHECK-NOT: !dbg
; CHECK-NEXT: br label %pred.store.continue, !dbg [[LOC3]]
; CHECK-EMPTY:
;
entry: