summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2019-05-05 18:59:12 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2019-05-05 18:59:12 +0000
commite5be660e25774e4a769be52a9b7817a1917b7ff7 (patch)
tree3ac1eb093f593dc89a0663d282b1fbe1a052bec7 /llvm/lib/Transforms
parent693551d76779822077b57bf5987f7f67a98ca744 (diff)
downloadbcm5719-llvm-e5be660e25774e4a769be52a9b7817a1917b7ff7.tar.gz
bcm5719-llvm-e5be660e25774e4a769be52a9b7817a1917b7ff7.zip
[NFC][Utils] deleteDeadLoop(): add an assert that exit block has some non-PHI instruction
Summary: If `deleteDeadLoop()` is called on such a loop, that has "bad" exit block, one that e.g. has no terminator instruction, the `DIBuilder::insertDbgValueIntrinsic()` will be told to insert the Dbg Value Intrinsic after `nullptr` (since there is no first non-PHI instruction), which will cause it to not insert those instructions into any basic block. The instructions will be parent-less, and IR verifier will complain. It is rather obvious to track down the root cause when that happens, so let's just assert it never happens. Reviewers: sanjoy, davide, vsk Reviewed By: vsk Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61008 llvm-svn: 359993
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUtils.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index 045cb6284c4..16971b2edbb 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -584,10 +584,14 @@ void llvm::deleteDeadLoop(Loop *L, DominatorTree *DT = nullptr,
// dbg.value truncates the range of any dbg.value before the loop where the
// loop used to be. This is particularly important for constant values.
DIBuilder DIB(*ExitBlock->getModule());
+ Instruction *InsertDbgValueBefore = ExitBlock->getFirstNonPHI();
+ assert(InsertDbgValueBefore &&
+ "There should be a non-PHI instruction in exit block, else these "
+ "instructions will have no parent.");
for (auto *DVI : DeadDebugInst)
- DIB.insertDbgValueIntrinsic(
- UndefValue::get(Builder.getInt32Ty()), DVI->getVariable(),
- DVI->getExpression(), DVI->getDebugLoc(), ExitBlock->getFirstNonPHI());
+ DIB.insertDbgValueIntrinsic(UndefValue::get(Builder.getInt32Ty()),
+ DVI->getVariable(), DVI->getExpression(),
+ DVI->getDebugLoc(), InsertDbgValueBefore);
// Remove the block from the reference counting scheme, so that we can
// delete it freely later.
OpenPOWER on IntegriCloud