summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAdam Nemet <anemet@apple.com>2016-08-26 20:21:05 +0000
committerAdam Nemet <anemet@apple.com>2016-08-26 20:21:05 +0000
commitcef33141560c42cf81b4284cef25777bb7e2f11e (patch)
treed9f6d731a76f587934dad64d16148d730f71ec6e /llvm/lib
parent7775c3310c44af877f2132130e2e018dab232177 (diff)
downloadbcm5719-llvm-cef33141560c42cf81b4284cef25777bb7e2f11e.tar.gz
bcm5719-llvm-cef33141560c42cf81b4284cef25777bb7e2f11e.zip
[Inliner] Report when inlining fails because callee's def is unavailable
Summary: This is obviously an interesting case because it may motivate code restructuring or LTO. Reporting this requires instantiation of ORE in the loop where the call sites are first gathered. I've checked compile-time overhead *with* -Rpass-with-hotness and the worst slow-down was 6% in mcf and quickly tailing off. As before without -Rpass-with-hotness there is no overhead. Because this could be a pretty noisy diagnostics, it is currently qualified as 'verbose'. As of this patch, 'verbose' diagnostics are only emitted with -Rpass-with-hotness, i.e. when the output is expected to be filtered. Reviewers: eraman, chandlerc, davidxl, hfinkel Subscribers: tejohnson, Prazek, davide, llvm-commits Differential Revision: https://reviews.llvm.org/D23415 llvm-svn: 279860
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/OptimizationDiagnosticInfo.cpp23
-rw-r--r--llvm/lib/Transforms/IPO/Inliner.cpp13
2 files changed, 24 insertions, 12 deletions
diff --git a/llvm/lib/Analysis/OptimizationDiagnosticInfo.cpp b/llvm/lib/Analysis/OptimizationDiagnosticInfo.cpp
index e150d9d2d82..09a4ce51472 100644
--- a/llvm/lib/Analysis/OptimizationDiagnosticInfo.cpp
+++ b/llvm/lib/Analysis/OptimizationDiagnosticInfo.cpp
@@ -68,29 +68,32 @@ void OptimizationRemarkEmitter::emitOptimizationRemark(const char *PassName,
void OptimizationRemarkEmitter::emitOptimizationRemarkMissed(
const char *PassName, const DebugLoc &DLoc, const Value *V,
- const Twine &Msg) {
+ const Twine &Msg, bool IsVerbose) {
LLVMContext &Ctx = F->getContext();
- Ctx.diagnose(DiagnosticInfoOptimizationRemarkMissed(PassName, *F, DLoc, Msg,
- computeHotness(V)));
+ if (!IsVerbose || shouldEmitVerbose())
+ Ctx.diagnose(DiagnosticInfoOptimizationRemarkMissed(PassName, *F, DLoc, Msg,
+ computeHotness(V)));
}
void OptimizationRemarkEmitter::emitOptimizationRemarkMissed(
- const char *PassName, Loop *L, const Twine &Msg) {
- emitOptimizationRemarkMissed(PassName, L->getStartLoc(), L->getHeader(), Msg);
+ const char *PassName, Loop *L, const Twine &Msg, bool IsVerbose) {
+ emitOptimizationRemarkMissed(PassName, L->getStartLoc(), L->getHeader(), Msg,
+ IsVerbose);
}
void OptimizationRemarkEmitter::emitOptimizationRemarkAnalysis(
const char *PassName, const DebugLoc &DLoc, const Value *V,
- const Twine &Msg) {
+ const Twine &Msg, bool IsVerbose) {
LLVMContext &Ctx = F->getContext();
- Ctx.diagnose(DiagnosticInfoOptimizationRemarkAnalysis(PassName, *F, DLoc, Msg,
- computeHotness(V)));
+ if (!IsVerbose || shouldEmitVerbose())
+ Ctx.diagnose(DiagnosticInfoOptimizationRemarkAnalysis(
+ PassName, *F, DLoc, Msg, computeHotness(V)));
}
void OptimizationRemarkEmitter::emitOptimizationRemarkAnalysis(
- const char *PassName, Loop *L, const Twine &Msg) {
+ const char *PassName, Loop *L, const Twine &Msg, bool IsVerbose) {
emitOptimizationRemarkAnalysis(PassName, L->getStartLoc(), L->getHeader(),
- Msg);
+ Msg, IsVerbose);
}
void OptimizationRemarkEmitter::emitOptimizationRemarkAnalysisFPCommute(
diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp
index 86781b3fe33..befadb63db5 100644
--- a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/lib/Transforms/IPO/Inliner.cpp
@@ -452,9 +452,10 @@ inlineCallsImpl(CallGraphSCC &SCC, CallGraph &CG,
for (CallGraphNode *Node : SCC) {
Function *F = Node->getFunction();
- if (!F)
+ if (!F || F->isDeclaration())
continue;
+ OptimizationRemarkEmitter ORE(F);
for (BasicBlock &BB : *F)
for (Instruction &I : BB) {
CallSite CS(cast<Value>(&I));
@@ -467,8 +468,16 @@ inlineCallsImpl(CallGraphSCC &SCC, CallGraph &CG,
// it. If it is an indirect call, inlining may resolve it to be a
// direct call, so we keep it.
if (Function *Callee = CS.getCalledFunction())
- if (Callee->isDeclaration())
+ if (Callee->isDeclaration()) {
+ ORE.emitOptimizationRemarkMissedAndAnalysis(
+ DEBUG_TYPE, &I,
+ Twine(Callee->getName()) + " will not be inlined into " +
+ CS.getCaller()->getName(),
+ Twine("definition of ") + Callee->getName() +
+ " is not available",
+ /*Verbose=*/true);
continue;
+ }
CallSites.push_back(std::make_pair(CS, -1));
}
OpenPOWER on IntegriCloud