[PATCH] D31302: [CodeGen] Compute DT/LI lazily in SafeStackLegacyPass. NFC.

Ahmed Bougacha via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 9 17:52:44 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL302610: [CodeGen] Compute DT/LI lazily in SafeStackLegacyPass. NFC. (authored by ab).

Changed prior to commit:
  https://reviews.llvm.org/D31302?vs=92855&id=98381#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31302

Files:
  llvm/trunk/lib/CodeGen/SafeStack.cpp
  llvm/trunk/test/CodeGen/X86/O0-pipeline.ll


Index: llvm/trunk/test/CodeGen/X86/O0-pipeline.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/trunk/test/CodeGen/X86/O0-pipeline.ll
@@ -27,9 +27,6 @@
 ; CHECK-NEXT:     FunctionPass Manager
 ; CHECK-NEXT:       Dominator Tree Construction
 ; CHECK-NEXT:       Exception handling preparation
-; CHECK-NEXT:       Dominator Tree Construction
-; CHECK-NEXT:       Natural Loop Information
-; CHECK-NEXT:       Scalar Evolution Analysis
 ; CHECK-NEXT:       Safe Stack instrumentation pass
 ; CHECK-NEXT:       Insert stack protectors
 ; CHECK-NEXT:       Module Verifier
Index: llvm/trunk/lib/CodeGen/SafeStack.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/SafeStack.cpp
+++ llvm/trunk/lib/CodeGen/SafeStack.cpp
@@ -774,7 +774,8 @@
   SafeStackLegacyPass() : SafeStackLegacyPass(nullptr) {}
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
-    AU.addRequired<ScalarEvolutionWrapperPass>();
+    AU.addRequired<TargetLibraryInfoWrapperPass>();
+    AU.addRequired<AssumptionCacheTracker>();
   }
 
   bool runOnFunction(Function &F) override {
@@ -799,7 +800,19 @@
       report_fatal_error("TargetLowering instance is required");
 
     auto *DL = &F.getParent()->getDataLayout();
-    auto &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE();
+    auto &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
+    auto &ACT = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
+
+    // Compute DT and LI only for functions that have the attribute.
+    // This is only useful because the legacy pass manager doesn't let us
+    // compute analyzes lazily.
+    // In the backend pipeline, nothing preserves DT before SafeStack, so we
+    // would otherwise always compute it wastefully, even if there is no
+    // function with the safestack attribute.
+    DominatorTree DT(F);
+    LoopInfo LI(DT);
+
+    ScalarEvolution SE(F, TLI, ACT, DT, LI);
 
     return SafeStack(F, *TL, *DL, SE).run();
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31302.98381.patch
Type: text/x-patch
Size: 2070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170510/b66ea774/attachment.bin>


More information about the llvm-commits mailing list