summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO/InferFunctionAttrs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/IPO/InferFunctionAttrs.cpp')
-rw-r--r--lib/Transforms/IPO/InferFunctionAttrs.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/Transforms/IPO/InferFunctionAttrs.cpp b/lib/Transforms/IPO/InferFunctionAttrs.cpp
index 7f5511e008e1..d1a68b28bd33 100644
--- a/lib/Transforms/IPO/InferFunctionAttrs.cpp
+++ b/lib/Transforms/IPO/InferFunctionAttrs.cpp
@@ -18,24 +18,28 @@ using namespace llvm;
#define DEBUG_TYPE "inferattrs"
-static bool inferAllPrototypeAttributes(Module &M,
- const TargetLibraryInfo &TLI) {
+static bool inferAllPrototypeAttributes(
+ Module &M, function_ref<TargetLibraryInfo &(Function &)> GetTLI) {
bool Changed = false;
for (Function &F : M.functions())
// We only infer things using the prototype and the name; we don't need
// definitions.
if (F.isDeclaration() && !F.hasOptNone())
- Changed |= inferLibFuncAttributes(F, TLI);
+ Changed |= inferLibFuncAttributes(F, GetTLI(F));
return Changed;
}
PreservedAnalyses InferFunctionAttrsPass::run(Module &M,
ModuleAnalysisManager &AM) {
- auto &TLI = AM.getResult<TargetLibraryAnalysis>(M);
+ FunctionAnalysisManager &FAM =
+ AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
+ auto GetTLI = [&FAM](Function &F) -> TargetLibraryInfo & {
+ return FAM.getResult<TargetLibraryAnalysis>(F);
+ };
- if (!inferAllPrototypeAttributes(M, TLI))
+ if (!inferAllPrototypeAttributes(M, GetTLI))
// If we didn't infer anything, preserve all analyses.
return PreservedAnalyses::all();
@@ -60,8 +64,10 @@ struct InferFunctionAttrsLegacyPass : public ModulePass {
if (skipModule(M))
return false;
- auto &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
- return inferAllPrototypeAttributes(M, TLI);
+ auto GetTLI = [this](Function &F) -> TargetLibraryInfo & {
+ return this->getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
+ };
+ return inferAllPrototypeAttributes(M, GetTLI);
}
};
}