diff options
author | Chris Lattner <sabre@nondot.org> | 2010-07-06 15:59:27 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-07-06 15:59:27 +0000 |
commit | f8bd392dce26226249b99bc1fa8d112602da3e63 (patch) | |
tree | b4fab39ab26b784d4ab85b81956e3d07caec14ad /lib/CodeGen/StackProtector.cpp | |
parent | 5c60386dbc74f1e5e30ead158708fac02fedbb40 (diff) |
tighten up this code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107670 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/StackProtector.cpp')
-rw-r--r-- | lib/CodeGen/StackProtector.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/CodeGen/StackProtector.cpp b/lib/CodeGen/StackProtector.cpp index e318afe2b5..ca5c28ce01 100644 --- a/lib/CodeGen/StackProtector.cpp +++ b/lib/CodeGen/StackProtector.cpp @@ -153,21 +153,16 @@ bool StackProtector::InsertStackProtectors() { // StackGuard = load __stack_chk_guard // call void @llvm.stackprotect.create(StackGuard, StackGuardSlot) // - PointerType *PtrTy = PointerType::getUnqual( - Type::getInt8Ty(RI->getContext())); - + const PointerType *PtrTy = Type::getInt8PtrTy(RI->getContext()); unsigned AddressSpace, Offset; if (TLI->getStackCookieLocation(AddressSpace, Offset)) { - Constant *ASPtr = Constant::getNullValue( - PointerType::get(Type::getInt8Ty(RI->getContext()), AddressSpace)); - APInt OffsetInt(32, Offset); - Constant *OffsetVal = Constant::getIntegerValue( - Type::getInt32Ty(RI->getContext()), OffsetInt); - StackGuardVar = ConstantExpr::getPointerCast( - ConstantExpr::getGetElementPtr(ASPtr, &OffsetVal, 1), - PointerType::get(PtrTy, AddressSpace)); + Constant *OffsetVal = + ConstantInt::get(Type::getInt32Ty(RI->getContext()), Offset); + + StackGuardVar = ConstantExpr::getIntToPtr(OffsetVal, + PointerType::get(PtrTy, AddressSpace)); } else { - StackGuardVar = M->getOrInsertGlobal("__stack_chk_guard", PtrTy); + StackGuardVar = M->getOrInsertGlobal("__stack_chk_guard", PtrTy); } BasicBlock &Entry = F->getEntryBlock(); |