about summary refs log tree commit diff homepage
path: root/lib/Module
diff options
context:
space:
mode:
authorMichael Bryman <mbryman@gmail.com>2019-03-26 11:30:01 -0400
committerCristian Cadar <c.cadar@imperial.ac.uk>2019-08-14 22:17:49 +0100
commitaa8e754262c347fa2988cf21635179ec03392cf3 (patch)
treeeccaa5df7c9cceeaab9ae597e5b42128290d5d71 /lib/Module
parent0012e87b747dc9a46cec4ed5708e72afc1eb8d3c (diff)
downloadklee-aa8e754262c347fa2988cf21635179ec03392cf3.tar.gz
fixed bug in IntrinsicCleaner trap cleaner
Diffstat (limited to 'lib/Module')
-rw-r--r--lib/Module/IntrinsicCleaner.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp
index e2ed3f39..19683ab4 100644
--- a/lib/Module/IntrinsicCleaner.cpp
+++ b/lib/Module/IntrinsicCleaner.cpp
@@ -207,6 +207,14 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
 
         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();
+        }
+
         dirty = true;
         break;
       }