summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-03-25 03:29:25 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-03-25 03:29:25 +0000
commit0c72e3f469baaa7468be94337ea4cf1081cb3e2c (patch)
treeba4ac038d380b37dc052ad303563e4caaa7836fc /llvm/lib
parent074f8151489fa7d3dd1b9ad86efbe6d34a41972c (diff)
downloadbcm5719-llvm-0c72e3f469baaa7468be94337ea4cf1081cb3e2c.tar.gz
bcm5719-llvm-0c72e3f469baaa7468be94337ea4cf1081cb3e2c.zip
Add an asserting ValueHandle to the block simplification code which will
fire if anything ever invalidates the assumption of a terminator instruction being unchanged throughout the routine. I've convinced myself that the current definition of simplification precludes such a transformation, so I think getting some asserts coverage that we don't violate this agreement is sufficient to make this code safe for the foreseeable future. Comments to the contrary or other suggestions are of course welcome. =] The bots are now happy with this code though, so it appears the bug here has indeed been fixed. llvm-svn: 153401
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 96c69337333..b51dd29b57d 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -355,6 +355,15 @@ bool llvm::RecursivelyDeleteDeadPHINode(PHINode *PN) {
/// instructions in other blocks as well in this block.
bool llvm::SimplifyInstructionsInBlock(BasicBlock *BB, const TargetData *TD) {
bool MadeChange = false;
+
+#ifndef NDEBUG
+ // In debug builds, ensure that the terminator of the block is never replaced
+ // or deleted by these simplifications. The idea of simplification is that it
+ // cannot introduce new instructions, and there is no way to replace the
+ // terminator of a block without introducing a new instruction.
+ AssertingVH<Instruction> TerminatorVH(--BB->end());
+#endif
+
for (BasicBlock::iterator BI = BB->begin(), E = --BB->end(); BI != E; ) {
assert(!BI->isTerminator());
Instruction *Inst = BI++;
OpenPOWER on IntegriCloud