[llvm] r283248 - [safestack] Requires a valid TargetMachine to be passed to the SafeStack pass.

David L Kreitzer via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 4 13:31:32 PDT 2016


Author: dlkreitz
Date: Tue Oct  4 15:31:32 2016
New Revision: 283248

URL: http://llvm.org/viewvc/llvm-project?rev=283248&view=rev
Log:
[safestack] Requires a valid TargetMachine to be passed to the SafeStack pass.

Patch by Michael LeMay

Differential revision: http://reviews.llvm.org/D24896

Modified:
    llvm/trunk/lib/CodeGen/SafeStack.cpp

Modified: llvm/trunk/lib/CodeGen/SafeStack.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SafeStack.cpp?rev=283248&r1=283247&r2=283248&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SafeStack.cpp (original)
+++ llvm/trunk/lib/CodeGen/SafeStack.cpp Tue Oct  4 15:31:32 2016
@@ -358,9 +358,8 @@ bool SafeStack::IsSafeStackAlloca(const
 
 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::getOrCreateUnsafeStack
 }
 
 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 &
     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;




More information about the llvm-commits mailing list