diff options
author | Evandro Menezes <e.menezes@samsung.com> | 2019-04-03 21:27:03 +0000 |
---|---|---|
committer | Evandro Menezes <e.menezes@samsung.com> | 2019-04-03 21:27:03 +0000 |
commit | 7c711ccf36e0a818f76d711715956ffe831f53b6 (patch) | |
tree | cfbd36f2d353a8c2eed5a47196fb39821ac5ec1f /llvm/lib/Transforms | |
parent | 4d50879d9c93cdadfd6b0918931907c821d06520 (diff) | |
download | bcm5719-llvm-7c711ccf36e0a818f76d711715956ffe831f53b6.tar.gz bcm5719-llvm-7c711ccf36e0a818f76d711715956ffe831f53b6.zip |
[IR] Create new method in `Function` class (NFC)
Create method `optForNone()` testing for the function level equivalent of
`-O0` and refactor appropriately.
Differential revision: https://reviews.llvm.org/D59852
llvm-svn: 357638
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionAttrs.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/HotColdSplitting.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/InferFunctionAttrs.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/Inliner.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/WarnMissedTransforms.cpp | 2 |
6 files changed, 8 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp index 77e98ecd910..d396882cc7e 100644 --- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp @@ -1366,8 +1366,7 @@ PreservedAnalyses PostOrderFunctionAttrsPass::run(LazyCallGraph::SCC &C, bool HasUnknownCall = false; for (LazyCallGraph::Node &N : C) { Function &F = N.getFunction(); - if (F.hasFnAttribute(Attribute::OptimizeNone) || - F.hasFnAttribute(Attribute::Naked)) { + if (F.optForNone() || F.hasFnAttribute(Attribute::Naked)) { // Treat any function we're trying not to optimize as if it were an // indirect call and omit it from the node set used below. HasUnknownCall = true; @@ -1440,8 +1439,7 @@ static bool runImpl(CallGraphSCC &SCC, AARGetterT AARGetter) { bool ExternalNode = false; for (CallGraphNode *I : SCC) { Function *F = I->getFunction(); - if (!F || F->hasFnAttribute(Attribute::OptimizeNone) || - F->hasFnAttribute(Attribute::Naked)) { + if (!F || F->optForNone() || F->hasFnAttribute(Attribute::Naked)) { // External node or function we're trying not to optimize - we both avoid // transform them and avoid leveraging information they provide. ExternalNode = true; diff --git a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp index 5d6add54319..c4348c3685e 100644 --- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp +++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp @@ -149,7 +149,7 @@ static bool mayExtractBlock(const BasicBlock &BB) { /// module has profile data), set entry count to 0 to ensure treated as cold. /// Return true if the function is changed. static bool markFunctionCold(Function &F, bool UpdateEntryCount = false) { - assert(!F.hasFnAttribute(Attribute::OptimizeNone) && "Can't mark this cold"); + assert(!F.optForNone() && "Can't mark this cold"); bool Changed = false; if (!F.hasFnAttribute(Attribute::Cold)) { F.addFnAttr(Attribute::Cold); @@ -673,7 +673,7 @@ bool HotColdSplitting::run(Module &M) { continue; // Do not modify `optnone` functions. - if (F.hasFnAttribute(Attribute::OptimizeNone)) + if (F.optForNone()) continue; // Detect inherently cold functions and mark them as such. diff --git a/llvm/lib/Transforms/IPO/InferFunctionAttrs.cpp b/llvm/lib/Transforms/IPO/InferFunctionAttrs.cpp index cac83f5aecb..dfe375de65d 100644 --- a/llvm/lib/Transforms/IPO/InferFunctionAttrs.cpp +++ b/llvm/lib/Transforms/IPO/InferFunctionAttrs.cpp @@ -25,7 +25,7 @@ static bool inferAllPrototypeAttributes(Module &M, for (Function &F : M.functions()) // We only infer things using the prototype and the name; we don't need // definitions. - if (F.isDeclaration() && !F.hasFnAttribute((Attribute::OptimizeNone))) + if (F.isDeclaration() && !F.optForNone()) Changed |= inferLibFuncAttributes(F, TLI); return Changed; diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp index 8ea6d154be5..b647b27642c 100644 --- a/llvm/lib/Transforms/IPO/Inliner.cpp +++ b/llvm/lib/Transforms/IPO/Inliner.cpp @@ -973,7 +973,7 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC, LazyCallGraph::Node &N = *CG.lookup(F); if (CG.lookupSCC(N) != C) continue; - if (F.hasFnAttribute(Attribute::OptimizeNone)) { + if (F.optForNone()) { setInlineRemark(Calls[i].first, "optnone attribute"); continue; } diff --git a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp index 79c219aeed5..c9e3a15267f 100644 --- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp +++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp @@ -393,9 +393,7 @@ static bool promoteIndirectCalls(Module &M, ProfileSummaryInfo *PSI, } bool Changed = false; for (auto &F : M) { - if (F.isDeclaration()) - continue; - if (F.hasFnAttribute(Attribute::OptimizeNone)) + if (F.isDeclaration() || F.optForNone()) continue; std::unique_ptr<OptimizationRemarkEmitter> OwnedORE; diff --git a/llvm/lib/Transforms/Scalar/WarnMissedTransforms.cpp b/llvm/lib/Transforms/Scalar/WarnMissedTransforms.cpp index 73687e1e5df..bcb877acfcd 100644 --- a/llvm/lib/Transforms/Scalar/WarnMissedTransforms.cpp +++ b/llvm/lib/Transforms/Scalar/WarnMissedTransforms.cpp @@ -92,7 +92,7 @@ PreservedAnalyses WarnMissedTransformationsPass::run(Function &F, FunctionAnalysisManager &AM) { // Do not warn about not applied transformations if optimizations are // disabled. - if (F.hasFnAttribute(Attribute::OptimizeNone)) + if (F.optForNone()) return PreservedAnalyses::all(); auto &ORE = AM.getResult<OptimizationRemarkEmitterAnalysis>(F); |