diff options
| author | Hideto Ueno <uenoku.tokotoko@gmail.com> | 2019-09-17 05:45:18 +0000 |
|---|---|---|
| committer | Hideto Ueno <uenoku.tokotoko@gmail.com> | 2019-09-17 05:45:18 +0000 |
| commit | 3bb5cbc20b57116693ac667e803110fa06173cff (patch) | |
| tree | 9e768ce24302e955f6bb12fdde93a014e7708221 /llvm/lib/Transforms/IPO/Attributor.cpp | |
| parent | 73f2dbb7d24d646d6c31fa008911f18844102c98 (diff) | |
| download | bcm5719-llvm-3bb5cbc20b57116693ac667e803110fa06173cff.tar.gz bcm5719-llvm-3bb5cbc20b57116693ac667e803110fa06173cff.zip | |
[Attributor] Create helper struct for handling analysis getters
Summary: This patch introduces a helper struct `AnalysisGetter` to put together analysis getters. In this patch, a getter for `AAResult` is also added for `noalias`.
Reviewers: jdoerfert, sstefan1
Reviewed By: jdoerfert
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67603
llvm-svn: 372072
Diffstat (limited to 'llvm/lib/Transforms/IPO/Attributor.cpp')
| -rw-r--r-- | llvm/lib/Transforms/IPO/Attributor.cpp | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index 9d0e978432e..90b0772a869 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -3845,14 +3845,10 @@ ChangeStatus Attributor::run(Module &M) { return ManifestChange; } -void Attributor::identifyDefaultAbstractAttributes( - Function &F, std::function<TargetLibraryInfo *(Function &)> &TLIGetter) { +void Attributor::identifyDefaultAbstractAttributes(Function &F) { if (!VisitedFunctions.insert(&F).second) return; - if (EnableHeapToStack) - InfoCache.FuncTLIMap[&F] = TLIGetter(F); - IRPosition FPos = IRPosition::function(F); // Check for dead BasicBlocks in every function. @@ -4063,8 +4059,7 @@ void AbstractAttribute::print(raw_ostream &OS) const { /// Pass (Manager) Boilerplate /// ---------------------------------------------------------------------------- -static bool runAttributorOnModule( - Module &M, std::function<TargetLibraryInfo *(Function &)> &TLIGetter) { +static bool runAttributorOnModule(Module &M, AnalysisGetter &AG) { if (DisableAttributor) return false; @@ -4073,7 +4068,7 @@ static bool runAttributorOnModule( // Create an Attributor and initially empty information cache that is filled // while we identify default attribute opportunities. - InformationCache InfoCache(M.getDataLayout()); + InformationCache InfoCache(M.getDataLayout(), AG); Attributor A(InfoCache, DepRecInterval); for (Function &F : M) { @@ -4099,7 +4094,7 @@ static bool runAttributorOnModule( // Populate the Attributor with abstract attribute opportunities in the // function and the information cache with IR information. - A.identifyDefaultAbstractAttributes(F, TLIGetter); + A.identifyDefaultAbstractAttributes(F); } return A.run(M) == ChangeStatus::CHANGED; @@ -4108,12 +4103,8 @@ static bool runAttributorOnModule( PreservedAnalyses AttributorPass::run(Module &M, ModuleAnalysisManager &AM) { auto &FAM = AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager(); - std::function<TargetLibraryInfo *(Function &)> TLIGetter = - [&](Function &F) -> TargetLibraryInfo * { - return &FAM.getResult<TargetLibraryAnalysis>(F); - }; - - if (runAttributorOnModule(M, TLIGetter)) { + AnalysisGetter AG(FAM); + if (runAttributorOnModule(M, AG)) { // FIXME: Think about passes we will preserve and add them here. return PreservedAnalyses::none(); } @@ -4132,10 +4123,9 @@ struct AttributorLegacyPass : public ModulePass { bool runOnModule(Module &M) override { if (skipModule(M)) return false; - std::function<TargetLibraryInfo *(Function &)> TLIGetter = - [&](Function &F) -> TargetLibraryInfo * { return nullptr; }; - return runAttributorOnModule(M, TLIGetter); + AnalysisGetter AG; + return runAttributorOnModule(M, AG); } void getAnalysisUsage(AnalysisUsage &AU) const override { |

