Implement PR3495: local spiller optimization. The local spiller can now keep availabi...
[oota-llvm.git] / lib / CodeGen / StackProtector.cpp
index 10b5d6d07f85e93f3127bd87f5915d9a83ead86d..7c4d22df8bfc43f5a3c3b9122c1648969243ea41 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->getTypePaddedSize(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.
@@ -177,7 +177,7 @@ bool StackProtector::InsertStackProtectors() {
     //   return:
     //     ...
     //     %1 = load __stack_chk_guard
-    //     %2 = call i8* @llvm.stackprotect.check(StackGuardSlot)
+    //     %2 = load StackGuardSlot
     //     %3 = cmp i1 %1, %2
     //     br i1 %3, label %SP_return, label %CallStackCheckFailBlk
     //
@@ -196,11 +196,9 @@ bool StackProtector::InsertStackProtectors() {
     NewBB->moveAfter(BB);
 
     // Generate the stack protector instructions in the old basic block.
-    LoadInst *LI = new LoadInst(StackGuardVar, "", false, BB);
-    CallInst *CI = CallInst::
-      Create(Intrinsic::getDeclaration(M, Intrinsic::stackprotector_check),
-             AI, "", BB);
-    ICmpInst *Cmp = new ICmpInst(CmpInst::ICMP_EQ, CI, LI, "", BB);
+    LoadInst *LI1 = new LoadInst(StackGuardVar, "", false, BB);
+    LoadInst *LI2 = new LoadInst(AI, "", true, BB);
+    ICmpInst *Cmp = new ICmpInst(CmpInst::ICMP_EQ, LI1, LI2, "", BB);
     BranchInst::Create(NewBB, FailBB, Cmp, BB);
   }