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 | dde2ba0b604e9b77c9a8cfe494b315f29cced8ab (patch) | |
tree | 2100ec0609813135e81fcd1c15c716f51d9a86f3 /llvm/lib/CodeGen/StackProtector.cpp | |
parent | 83cec97479d301a56624174b686effeafb3bbc19 (diff) | |
download | llvm-dde2ba0b604e9b77c9a8cfe494b315f29cced8ab.zip llvm-dde2ba0b604e9b77c9a8cfe494b315f29cced8ab.tar.gz llvm-dde2ba0b604e9b77c9a8cfe494b315f29cced8ab.tar.bz2 |
tighten up this code.
llvm-svn: 107670
Diffstat (limited to 'llvm/lib/CodeGen/StackProtector.cpp')
-rw-r--r-- | llvm/lib/CodeGen/StackProtector.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp index e318afe..ca5c28c 100644 --- a/llvm/lib/CodeGen/StackProtector.cpp +++ b/llvm/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(); |