diff options
author | David L Kreitzer <david.l.kreitzer@intel.com> | 2016-10-04 20:31:32 +0000 |
---|---|---|
committer | David L Kreitzer <david.l.kreitzer@intel.com> | 2016-10-04 20:31:32 +0000 |
commit | fedb9b67ca82babec0ed9aa68935d4474561f36b (patch) | |
tree | 4753fcbecbafa50d06824d9f9a1ef9a50c334c56 /llvm/lib/CodeGen/SafeStack.cpp | |
parent | bab7943c6cf41a5f751cd64faa32622d58224c4e (diff) | |
download | llvm-fedb9b67ca82babec0ed9aa68935d4474561f36b.zip llvm-fedb9b67ca82babec0ed9aa68935d4474561f36b.tar.gz llvm-fedb9b67ca82babec0ed9aa68935d4474561f36b.tar.bz2 |
[safestack] Requires a valid TargetMachine to be passed to the SafeStack pass.
Patch by Michael LeMay
Differential revision: http://reviews.llvm.org/D24896
llvm-svn: 283248
Diffstat (limited to 'llvm/lib/CodeGen/SafeStack.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SafeStack.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/SafeStack.cpp b/llvm/lib/CodeGen/SafeStack.cpp index 4a1b995..7fc46c2 100644 --- a/llvm/lib/CodeGen/SafeStack.cpp +++ b/llvm/lib/CodeGen/SafeStack.cpp @@ -358,9 +358,8 @@ bool SafeStack::IsSafeStackAlloca(const Value *AllocaPtr, uint64_t AllocaSize) { Value *SafeStack::getOrCreateUnsafeStackPtr(IRBuilder<> &IRB, Function &F) { // Check if there is a target-specific location for the unsafe stack pointer. - if (TL) - if (Value *V = TL->getSafeStackPointerLocation(IRB)) - return V; + if (Value *V = TL->getSafeStackPointerLocation(IRB)) + return V; // Otherwise, assume the target links with compiler-rt, which provides a // thread-local variable with a magic name. @@ -393,9 +392,7 @@ Value *SafeStack::getOrCreateUnsafeStackPtr(IRBuilder<> &IRB, Function &F) { } Value *SafeStack::getStackGuard(IRBuilder<> &IRB, Function &F) { - Value *StackGuardVar = nullptr; - if (TL) - StackGuardVar = TL->getIRStackGuard(IRB); + Value *StackGuardVar = TL->getIRStackGuard(IRB); if (!StackGuardVar) StackGuardVar = F.getParent()->getOrInsertGlobal("__stack_chk_guard", StackPtrTy); @@ -752,7 +749,9 @@ bool SafeStack::runOnFunction(Function &F) { return false; } - TL = TM ? TM->getSubtargetImpl(F)->getTargetLowering() : nullptr; + if (!TM) + report_fatal_error("Target machine is required"); + TL = TM->getSubtargetImpl(F)->getTargetLowering(); SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE(); ++NumFunctions; |