From: Alexey Samsonov Date: Mon, 29 Jun 2015 21:30:14 +0000 (+0000) Subject: [LoopSimplify] Set proper debug location in loop backedge blocks. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=93dd711033a224fb54de157fd5270967627affe5;p=oota-llvm.git [LoopSimplify] Set proper debug location in loop backedge blocks. Set debug location for terminator instruction in loop backedge block (which is an unconditional jump to loop header). We can't copy debug location from original backedges, as there can be several of them, with different debug info locations. So, we follow the approach of SplitBlockPredecessors, and copy the debug info from first non-PHI instruction in the header (i.e. destination block). This is yet another change for PR23837. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240999 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp index d8f7c9176f5..2e7d21cb171 100644 --- a/lib/Transforms/Utils/LoopSimplify.cpp +++ b/lib/Transforms/Utils/LoopSimplify.cpp @@ -386,8 +386,9 @@ static BasicBlock *insertUniqueBackedgeBlock(Loop *L, BasicBlock *Preheader, // Create and insert the new backedge block... BasicBlock *BEBlock = BasicBlock::Create(Header->getContext(), - Header->getName()+".backedge", F); + Header->getName() + ".backedge", F); BranchInst *BETerminator = BranchInst::Create(Header, BEBlock); + BETerminator->setDebugLoc(Header->getFirstNonPHI()->getDebugLoc()); DEBUG(dbgs() << "LoopSimplify: Inserting unique backedge block " << BEBlock->getName() << "\n"); diff --git a/test/Transforms/LoopSimplify/single-backedge.ll b/test/Transforms/LoopSimplify/single-backedge.ll index aedd6f23091..92fbdca8a6d 100644 --- a/test/Transforms/LoopSimplify/single-backedge.ll +++ b/test/Transforms/LoopSimplify/single-backedge.ll @@ -5,19 +5,35 @@ ; RUN: opt < %s -indvars -S | FileCheck %s ; CHECK: Loop.backedge: ; CHECK-NOT: br -; CHECK: br label %Loop +; CHECK: br label %Loop, !dbg [[BACKEDGE_LOC:![0-9]+]] + +; CHECK: [[BACKEDGE_LOC]] = !DILocation(line: 101, column: 1, scope: !{{.*}}) define i32 @test(i1 %C) { ;