Remove the stackprotector_check intrinsic. Use a volatile load instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59504 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
index 4a93452..140b856 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
@@ -4041,19 +4041,6 @@
     DAG.setRoot(Result);
     return 0;
   }
-  case Intrinsic::stackprotector_check: {
-    // Emit code into the DAG to retrieve the stack guard off of the stack.
-    MachineFunction &MF = DAG.getMachineFunction();
-    MachineFrameInfo *MFI = MF.getFrameInfo();
-    MVT PtrTy = TLI.getPointerTy();
-
-    // Load the value stored on the stack.
-    int FI = MFI->getStackProtectorIndex();
-    SDValue FIN = DAG.getFrameIndex(MFI->getStackProtectorIndex(), PtrTy);
-    setValue(&I, DAG.getLoad(PtrTy, getRoot(), FIN,
-                             PseudoSourceValue::getFixedStack(FI), 0, true));
-    return 0;
-  }
   case Intrinsic::var_annotation:
     // Discard annotate attributes
     return 0;
diff --git a/lib/CodeGen/StackProtector.cpp b/lib/CodeGen/StackProtector.cpp
index 10b5d6d..8fe6529 100644
--- a/lib/CodeGen/StackProtector.cpp
+++ b/lib/CodeGen/StackProtector.cpp
@@ -177,7 +177,7 @@
     //   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 @@
     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);
   }