[PATCH] D24896: [safestack] Require TargetMachine to be provided.

Michael LeMay via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 26 14:20:33 PDT 2016


mlemay-intel updated this revision to Diff 72567.
mlemay-intel added a comment.

Convert assert to report_fatal_error.


https://reviews.llvm.org/D24896

Files:
  lib/CodeGen/SafeStack.cpp

Index: lib/CodeGen/SafeStack.cpp
===================================================================
--- lib/CodeGen/SafeStack.cpp
+++ lib/CodeGen/SafeStack.cpp
@@ -358,9 +358,8 @@
 
 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::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 @@
     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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24896.72567.patch
Type: text/x-patch
Size: 1297 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160926/579ebd57/attachment.bin>


More information about the llvm-commits mailing list