summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorYevgeny Rouban <yevgeny.rouban@azul.com>2019-02-01 10:44:43 +0000
committerYevgeny Rouban <yevgeny.rouban@azul.com>2019-02-01 10:44:43 +0000
commit15b17d0a7ccdc150e775df5589ebfb67566854f0 (patch)
treebbe230cabd40dd6ce6f017c800e002a15d09f1f4 /llvm/lib/Transforms
parent212833ce766fb9b747672b249667e0161e52968c (diff)
downloadbcm5719-llvm-15b17d0a7ccdc150e775df5589ebfb67566854f0.tar.gz
bcm5719-llvm-15b17d0a7ccdc150e775df5589ebfb67566854f0.zip
Provide reason messages for unviable inlining
InlineCost's isInlineViable() is changed to return InlineResult instead of bool. This provides messages for failure reasons and allows to get more specific messages for cases where callsites are not viable for inlining. Reviewed By: xbolva00, anemet Differential Revision: https://reviews.llvm.org/D57089 llvm-svn: 352849
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/AlwaysInliner.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/IPO/AlwaysInliner.cpp b/llvm/lib/Transforms/IPO/AlwaysInliner.cpp
index c7697556530..0058bb9832a 100644
--- a/llvm/lib/Transforms/IPO/AlwaysInliner.cpp
+++ b/llvm/lib/Transforms/IPO/AlwaysInliner.cpp
@@ -145,11 +145,20 @@ InlineCost AlwaysInlinerLegacyPass::getInlineCost(CallSite CS) {
Function *Callee = CS.getCalledFunction();
// Only inline direct calls to functions with always-inline attributes
- // that are viable for inlining. FIXME: We shouldn't even get here for
- // declarations.
- if (Callee && !Callee->isDeclaration() &&
- CS.hasFnAttr(Attribute::AlwaysInline) && isInlineViable(*Callee))
- return InlineCost::getAlways("always inliner");
+ // that are viable for inlining.
+ if (!Callee)
+ return InlineCost::getNever("indirect call");
- return InlineCost::getNever("always inliner");
+ // FIXME: We shouldn't even get here for declarations.
+ if (Callee->isDeclaration())
+ return InlineCost::getNever("no definition");
+
+ if (!CS.hasFnAttr(Attribute::AlwaysInline))
+ return InlineCost::getNever("no alwaysinline attribute");
+
+ auto IsViable = isInlineViable(*Callee);
+ if (!IsViable)
+ return InlineCost::getNever(IsViable.message);
+
+ return InlineCost::getAlways("always inliner");
}
OpenPOWER on IntegriCloud