ELF Code Emitter now uses CurBufferPtr, BufferBegin and BufferEnd, as do JIT and
[oota-llvm.git] / lib / CodeGen / StackProtector.cpp
index 8fe6529ef44894033c658802169ec6d1baa4b359..c179f1e3df97cea83db1dd22641ffcb36c5e6988 100644 (file)
@@ -114,7 +114,7 @@ bool StackProtector::RequiresStackProtector() const {
         if (const ArrayType *AT = dyn_cast<ArrayType>(AI->getAllocatedType()))
           // If an array has more than SSPBufferSize bytes of allocated space,
           // then we emit stack protectors.
-          if (SSPBufferSize <= TD->getABITypeSize(AT))
+          if (SSPBufferSize <= TD->getTypeAllocSize(AT))
             return true;
       }
   }
@@ -159,7 +159,7 @@ bool StackProtector::InsertStackProtectors() {
 
       Value *Args[] = { LI, AI };
       CallInst::
-        Create(Intrinsic::getDeclaration(M, Intrinsic::stackprotector_create),
+        Create(Intrinsic::getDeclaration(M, Intrinsic::stackprotector),
                &Args[0], array_endof(Args), "", InsPt);
 
       // Create the basic block to jump to when the guard check fails.
@@ -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);