When we split a basic block, there's a default branch to the newly created BB.
[oota-llvm.git] / lib / CodeGen / StackProtector.cpp
index 7c4d22df8bfc43f5a3c3b9122c1648969243ea41..c333acd42a8b543e2ba23f33a266b16ef4a5d568 100644 (file)
@@ -191,6 +191,9 @@ bool StackProtector::InsertStackProtectors() {
     // Split the basic block before the return instruction.
     BasicBlock *NewBB = BB->splitBasicBlock(RI, "SP_return");
 
+    // Remove default branch instruction to the new BB.
+    BB->getTerminator()->eraseFromParent();
+
     // Move the newly created basic block to the point right after the old basic
     // block so that it's in the "fall through" position.
     NewBB->moveAfter(BB);