diff options
author | Sam Elliott <ashe2@cs.washington.edu> | 2017-08-20 06:55:10 +0000 |
---|---|---|
committer | Sam Elliott <ashe2@cs.washington.edu> | 2017-08-20 06:55:10 +0000 |
commit | 7fe0aaa1409aacec89b07b2abecacc2cd63a2db6 (patch) | |
tree | 0618c810c609abf07139ebaf4a49ecbb7aaf4c3f /llvm/lib/Transforms/IPO/Inliner.cpp | |
parent | 785dd7536915fcb481ccfa205f1e0458bcd1125b (diff) | |
download | bcm5719-llvm-7fe0aaa1409aacec89b07b2abecacc2cd63a2db6.tar.gz bcm5719-llvm-7fe0aaa1409aacec89b07b2abecacc2cd63a2db6.zip |
Revert "Emit only A Single Opt Remark When Inlining"
Reverting due to clang build failure
llvm-svn: 311274
Diffstat (limited to 'llvm/lib/Transforms/IPO/Inliner.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/Inliner.cpp | 85 |
1 files changed, 29 insertions, 56 deletions
diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp index 10a83f48ff4..aca67d4472b 100644 --- a/llvm/lib/Transforms/IPO/Inliner.cpp +++ b/llvm/lib/Transforms/IPO/Inliner.cpp @@ -335,12 +335,10 @@ shouldBeDeferred(Function *Caller, CallSite CS, InlineCost IC, return false; } -/// Return the cost only if the inliner should attempt to inline at the given -/// CallSite. If we return the cost, we will emit an optimisation remark later -/// using that cost, so we won't do so from this function. -static Optional<InlineCost> -shouldInline(CallSite CS, function_ref<InlineCost(CallSite CS)> GetInlineCost, - OptimizationRemarkEmitter &ORE) { +/// Return true if the inliner should attempt to inline at the given CallSite. +static bool shouldInline(CallSite CS, + function_ref<InlineCost(CallSite CS)> GetInlineCost, + OptimizationRemarkEmitter &ORE) { using namespace ore; InlineCost IC = GetInlineCost(CS); Instruction *Call = CS.getInstruction(); @@ -350,7 +348,10 @@ shouldInline(CallSite CS, function_ref<InlineCost(CallSite CS)> GetInlineCost, if (IC.isAlways()) { DEBUG(dbgs() << " Inlining: cost=always" << ", Call: " << *CS.getInstruction() << "\n"); - return IC; + ORE.emit(OptimizationRemarkAnalysis(DEBUG_TYPE, "AlwaysInline", Call) + << NV("Callee", Callee) + << " should always be inlined (cost=always)"); + return true; } if (IC.isNever()) { @@ -360,19 +361,19 @@ shouldInline(CallSite CS, function_ref<InlineCost(CallSite CS)> GetInlineCost, << NV("Callee", Callee) << " not inlined into " << NV("Caller", Caller) << " because it should never be inlined (cost=never)"); - return None; + return false; } if (!IC) { DEBUG(dbgs() << " NOT Inlining: cost=" << IC.getCost() - << ", thres=" << IC.getThreshold() + << ", thres=" << (IC.getCostDelta() + IC.getCost()) << ", Call: " << *CS.getInstruction() << "\n"); ORE.emit(OptimizationRemarkMissed(DEBUG_TYPE, "TooCostly", Call) << NV("Callee", Callee) << " not inlined into " << NV("Caller", Caller) << " because too costly to inline (cost=" - << NV("Cost", IC.getCost()) - << ", threshold=" << NV("Threshold", IC.getThreshold()) << ")"); - return None; + << NV("Cost", IC.getCost()) << ", threshold=" + << NV("Threshold", IC.getCostDelta() + IC.getCost()) << ")"); + return false; } int TotalSecondaryCost = 0; @@ -385,16 +386,18 @@ shouldInline(CallSite CS, function_ref<InlineCost(CallSite CS)> GetInlineCost, << "Not inlining. Cost of inlining " << NV("Callee", Callee) << " increases the cost of inlining " << NV("Caller", Caller) << " in other contexts"); - - // IC does not bool() to false, so get an InlineCost that will. - // This will not be inspected to make an error message. - return None; + return false; } DEBUG(dbgs() << " Inlining: cost=" << IC.getCost() - << ", thres=" << IC.getThreshold() + << ", thres=" << (IC.getCostDelta() + IC.getCost()) << ", Call: " << *CS.getInstruction() << '\n'); - return IC; + ORE.emit(OptimizationRemarkAnalysis(DEBUG_TYPE, "CanBeInlined", Call) + << NV("Callee", Callee) << " can be inlined into " + << NV("Caller", Caller) << " with cost=" << NV("Cost", IC.getCost()) + << " (threshold=" + << NV("Threshold", IC.getCostDelta() + IC.getCost()) << ")"); + return true; } /// Return true if the specified inline history ID @@ -542,10 +545,9 @@ inlineCallsImpl(CallGraphSCC &SCC, CallGraph &CG, // just become a regular analysis dependency. OptimizationRemarkEmitter ORE(Caller); - Optional<InlineCost> OIC = shouldInline(CS, GetInlineCost, ORE); // If the policy determines that we should inline this function, // delete the call instead. - if (!OIC) + if (!shouldInline(CS, GetInlineCost, ORE)) continue; // If this call site is dead and it is to a readonly function, we should @@ -560,7 +562,7 @@ inlineCallsImpl(CallGraphSCC &SCC, CallGraph &CG, ++NumCallsDeleted; } else { // Get DebugLoc to report. CS will be invalid after Inliner. - DebugLoc DLoc = CS->getDebugLoc(); + DebugLoc DLoc = Instr->getDebugLoc(); BasicBlock *Block = CS.getParent(); // Attempt to inline the function. @@ -576,17 +578,10 @@ inlineCallsImpl(CallGraphSCC &SCC, CallGraph &CG, } ++NumInlined; - if (OIC->isAlways()) - ORE.emit(OptimizationRemark(DEBUG_TYPE, "AlwaysInline", DLoc, Block) - << NV("Callee", Callee) << " inlined into " - << NV("Caller", Caller) << " with cost=always"); - else - ORE.emit(OptimizationRemark(DEBUG_TYPE, "Inlined", DLoc, Block) - << NV("Callee", Callee) << " inlined into " - << NV("Caller", Caller) - << " with cost=" << NV("Cost", OIC->getCost()) - << " (threshold=" << NV("Threshold", OIC->getThreshold()) - << ")"); + // Report the inline decision. + ORE.emit(OptimizationRemark(DEBUG_TYPE, "Inlined", DLoc, Block) + << NV("Callee", Callee) << " inlined into " + << NV("Caller", Caller)); // If inlining this function gave us any new call sites, throw them // onto our worklist to process. They are useful inline candidates. @@ -890,9 +885,8 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC, continue; } - Optional<InlineCost> OIC = shouldInline(CS, GetInlineCost, ORE); // Check whether we want to inline this callsite. - if (!OIC) + if (!shouldInline(CS, GetInlineCost, ORE)) continue; // Setup the data structure used to plumb customization into the @@ -902,32 +896,11 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC, &FAM.getResult<BlockFrequencyAnalysis>(*(CS.getCaller())), &FAM.getResult<BlockFrequencyAnalysis>(Callee)); - // Get DebugLoc to report. CS will be invalid after Inliner. - DebugLoc DLoc = CS->getDebugLoc(); - BasicBlock *Block = CS.getParent(); - - using namespace ore; - if (!InlineFunction(CS, IFI)) { - ORE.emit( - OptimizationRemarkMissed(DEBUG_TYPE, "NotInlined", DLoc, Block) - << NV("Callee", &Callee) << " will not be inlined into " - << NV("Caller", &F)); + if (!InlineFunction(CS, IFI)) continue; - } DidInline = true; InlinedCallees.insert(&Callee); - if (OIC->isAlways()) - ORE.emit(OptimizationRemark(DEBUG_TYPE, "AlwaysInline", DLoc, Block) - << NV("Callee", &Callee) << " inlined into " - << NV("Caller", &F) << " with cost=always"); - else - ORE.emit( - OptimizationRemark(DEBUG_TYPE, "Inlined", DLoc, Block) - << NV("Callee", &Callee) << " inlined into " << NV("Caller", &F) - << " with cost=" << NV("Cost", OIC->getCost()) - << " (threshold=" << NV("Threshold", OIC->getThreshold()) << ")"); - // Add any new callsites to defined functions to the worklist. if (!IFI.InlinedCallSites.empty()) { int NewHistoryID = InlineHistory.size(); |