[llvm-commits] [llvm] r153401 - /llvm/trunk/lib/Transforms/Utils/Local.cpp

Chandler Carruth chandlerc at gmail.com
Sat Mar 24 20:29:25 PDT 2012


Author: chandlerc
Date: Sat Mar 24 22:29:25 2012
New Revision: 153401

URL: http://llvm.org/viewvc/llvm-project?rev=153401&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/Transforms/Utils/Local.cpp

Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=153401&r1=153400&r2=153401&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Sat Mar 24 22:29:25 2012
@@ -355,6 +355,15 @@
 /// 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++;





More information about the llvm-commits mailing list