summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
diff options
context:
space:
mode:
authorCarlos Alberto Enciso <carlos.alberto.enciso@gmail.com>2018-11-09 09:42:10 +0000
committerCarlos Alberto Enciso <carlos.alberto.enciso@gmail.com>2018-11-09 09:42:10 +0000
commitfa9cf897347c456313834672a54386baca2e8b77 (patch)
treefb2f9860590ea8f6f0cb9c6c0312fe11f713598e /llvm/lib/Transforms/Utils
parent08979cd1250bfea14f9798bd6d153e0debda6e81 (diff)
downloadbcm5719-llvm-fa9cf897347c456313834672a54386baca2e8b77.tar.gz
bcm5719-llvm-fa9cf897347c456313834672a54386baca2e8b77.zip
[DebugInfo][Dexter] Unreachable line stepped onto after SimplifyCFG.
In SimplifyCFG when given a conditional branch that goes to BB1 and BB2, the hoisted common terminator instruction in the two blocks, caused debug line records associated with subsequent select instructions to become ambiguous. It causes the debugger to display unreachable source lines. Differential Revision: https://reviews.llvm.org/D53390 llvm-svn: 346481
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 849f9ee1d19..af9d2eaf253 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1372,6 +1372,14 @@ HoistTerminator:
}
}
+ // As the parent basic block terminator is a branch instruction which is
+ // removed at the end of the current transformation, use its previous
+ // non-debug instruction, as the reference insertion point, which will
+ // provide the debug location for the instruction being hoisted. For BBs
+ // with only debug instructions, use an empty debug location.
+ Instruction *InsertPt =
+ BIParent->getTerminator()->getPrevNonDebugInstruction();
+
// Okay, it is safe to hoist the terminator.
Instruction *NT = I1->clone();
BIParent->getInstList().insert(BI->getIterator(), NT);
@@ -1381,6 +1389,14 @@ HoistTerminator:
NT->takeName(I1);
}
+ // The instruction NT being hoisted, is the terminator for the true branch,
+ // with debug location (DILocation) within that branch. We can't retain
+ // its original debug location value, otherwise 'select' instructions that
+ // are created from any PHI nodes, will take its debug location, giving
+ // the impression that those 'select' instructions are in the true branch,
+ // causing incorrect stepping, affecting the debug experience.
+ NT->setDebugLoc(InsertPt ? InsertPt->getDebugLoc() : DebugLoc());
+
IRBuilder<NoFolder> Builder(NT);
// Hoisting one of the terminators from our successor is a great thing.
// Unfortunately, the successors of the if/else blocks may have PHI nodes in
OpenPOWER on IntegriCloud