Remove the stackprotector_check intrinsic. Use a volatile load instead.

llvm-svn: 59504
This commit is contained in:
Bill Wendling 2008-11-18 07:30:57 +00:00
parent ee4fa9cfbb
commit 7235002bd1
3 changed files with 6 additions and 24 deletions

View File

@ -180,14 +180,11 @@ def int_pcmarker : Intrinsic<[llvm_void_ty], [llvm_i32_ty]>;
def int_readcyclecounter : Intrinsic<[llvm_i64_ty]>; def int_readcyclecounter : Intrinsic<[llvm_i64_ty]>;
// Stack Protector Intrinsics - The stackprotector_create writes the stack guard // Stack Protector Intrinsic - The stackprotector_create writes the stack guard
// to the correct place on the stack frame. The stackprotector_check reads back // to the correct place on the stack frame.
// the stack guard that the stackprotector_create stored.
def int_stackprotector_create : Intrinsic<[llvm_void_ty], def int_stackprotector_create : Intrinsic<[llvm_void_ty],
[llvm_ptr_ty, llvm_ptrptr_ty], [llvm_ptr_ty, llvm_ptrptr_ty],
[IntrWriteMem]>; [IntrWriteMem]>;
def int_stackprotector_check : Intrinsic<[llvm_ptr_ty], [llvm_ptrptr_ty],
[IntrReadMem]>;
//===------------------- Standard C Library Intrinsics --------------------===// //===------------------- Standard C Library Intrinsics --------------------===//
// //

View File

@ -4041,19 +4041,6 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
DAG.setRoot(Result); DAG.setRoot(Result);
return 0; 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: case Intrinsic::var_annotation:
// Discard annotate attributes // Discard annotate attributes
return 0; return 0;

View File

@ -177,7 +177,7 @@ bool StackProtector::InsertStackProtectors() {
// return: // return:
// ... // ...
// %1 = load __stack_chk_guard // %1 = load __stack_chk_guard
// %2 = call i8* @llvm.stackprotect.check(StackGuardSlot) // %2 = load StackGuardSlot
// %3 = cmp i1 %1, %2 // %3 = cmp i1 %1, %2
// br i1 %3, label %SP_return, label %CallStackCheckFailBlk // br i1 %3, label %SP_return, label %CallStackCheckFailBlk
// //
@ -196,11 +196,9 @@ bool StackProtector::InsertStackProtectors() {
NewBB->moveAfter(BB); NewBB->moveAfter(BB);
// Generate the stack protector instructions in the old basic block. // Generate the stack protector instructions in the old basic block.
LoadInst *LI = new LoadInst(StackGuardVar, "", false, BB); LoadInst *LI1 = new LoadInst(StackGuardVar, "", false, BB);
CallInst *CI = CallInst:: LoadInst *LI2 = new LoadInst(AI, "", true, BB);
Create(Intrinsic::getDeclaration(M, Intrinsic::stackprotector_check), ICmpInst *Cmp = new ICmpInst(CmpInst::ICMP_EQ, LI1, LI2, "", BB);
AI, "", BB);
ICmpInst *Cmp = new ICmpInst(CmpInst::ICMP_EQ, CI, LI, "", BB);
BranchInst::Create(NewBB, FailBB, Cmp, BB); BranchInst::Create(NewBB, FailBB, Cmp, BB);
} }