about summary refs log tree commit diff homepage
path: root/lib
diff options
context:
space:
mode:
authorMartin Nowack <m.nowack@imperial.ac.uk>2019-08-06 10:16:42 +0100
committerCristian Cadar <c.cadar@imperial.ac.uk>2019-08-14 22:17:49 +0100
commit8c99f6e1ba894ee1b10fdbc290b8834ef3a6550c (patch)
tree4286a4ea8f00e53fec1a80ad11b13f3a32d3a033 /lib
parentaa8e754262c347fa2988cf21635179ec03392cf3 (diff)
downloadklee-8c99f6e1ba894ee1b10fdbc290b8834ef3a6550c.tar.gz
Update basic block iterator after deleting instruction; add test case
Diffstat (limited to 'lib')
-rw-r--r--lib/Module/IntrinsicCleaner.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp
index 19683ab4..92107f4f 100644
--- a/lib/Module/IntrinsicCleaner.cpp
+++ b/lib/Module/IntrinsicCleaner.cpp
@@ -205,14 +205,15 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
         Builder.CreateCall(F);
         Builder.CreateUnreachable();
 
-        ii->eraseFromParent();
-
-       	//check if the instruction after the one we just replaced is not the end of the basic block
-        //and if it is not (i.e. it is a valid instruction), delete it and all remaining 
-        //because the cleaner just introduced a terminating instruction (unreachable)
-        //otherwise llvm will assert in Verifier::visitTerminatorInstr
-        while(i != ie){  // i was already incremented above.
-          (i++)->eraseFromParent();
+        i = ii->eraseFromParent();
+
+        // check if the instruction after the one we just replaced is not the
+        // end of the basic block and if it is not (i.e. it is a valid
+        // instruction), delete it and all remaining because the cleaner just
+        // introduced a terminating instruction (unreachable) otherwise llvm will
+        // assert in Verifier::visitTerminatorInstr
+        while (i != ie) { // i was already incremented above.
+          i = i->eraseFromParent();
         }
 
         dirty = true;