diff options
author | Ahmed Bougacha <ahmed.bougacha@gmail.com> | 2017-05-10 00:39:25 +0000 |
---|---|---|
committer | Ahmed Bougacha <ahmed.bougacha@gmail.com> | 2017-05-10 00:39:25 +0000 |
commit | 8c358e301691e3bca486cf26a624b184080bee7f (patch) | |
tree | 399ff0308143199cf11f246f0319c291d13626fc /llvm/lib | |
parent | 00d68222783a1592f3bf9d55b9a1f8f7b8e42733 (diff) | |
download | bcm5719-llvm-8c358e301691e3bca486cf26a624b184080bee7f.tar.gz bcm5719-llvm-8c358e301691e3bca486cf26a624b184080bee7f.zip |
[CodeGen] Compute DT/LI lazily in SafeStackLegacyPass. NFC.
We currently require SCEV, which requires DT/LI. Those are expensive to
compute, but the pass only runs for functions that have the safestack
attribute.
Compute DT/LI to build SCEV lazily, only when the pass is actually going
to transform the function.
Differential Revision: https://reviews.llvm.org/D31302
llvm-svn: 302610
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/SafeStack.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SafeStack.cpp b/llvm/lib/CodeGen/SafeStack.cpp index f0663ebde82..08b3d345f68 100644 --- a/llvm/lib/CodeGen/SafeStack.cpp +++ b/llvm/lib/CodeGen/SafeStack.cpp @@ -774,7 +774,8 @@ public: 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 @@ public: 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(); } |