Don't inline @llvm.icall.branch.funnel
Summary: @llvm.icall.branch.funnel is musttail with variable number of
arguments. After inlining current backend can't separate call targets from call
arguments.
Reviewers: pcc
Subscribers: hiraditya, llvm-commits
Differential Revision: https://reviews.llvm.org/D45116
llvm-svn: 329235
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index ff69b2c..2a479e9 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -135,7 +135,7 @@
bool ContainsNoDuplicateCall;
bool HasReturn;
bool HasIndirectBr;
- bool HasFrameEscape;
+ bool HasUninlineableIntrinsic;
bool UsesVarArgs;
/// Number of bytes allocated statically by the callee.
@@ -281,12 +281,13 @@
IsCallerRecursive(false), IsRecursiveCall(false),
ExposesReturnsTwice(false), HasDynamicAlloca(false),
ContainsNoDuplicateCall(false), HasReturn(false), HasIndirectBr(false),
- HasFrameEscape(false), UsesVarArgs(false), AllocatedSize(0), NumInstructions(0),
- NumVectorInstructions(0), VectorBonus(0), SingleBBBonus(0),
- EnableLoadElimination(true), LoadEliminationCost(0), NumConstantArgs(0),
- NumConstantOffsetPtrArgs(0), NumAllocaArgs(0), NumConstantPtrCmps(0),
- NumConstantPtrDiffs(0), NumInstructionsSimplified(0),
- SROACostSavings(0), SROACostSavingsLost(0) {}
+ HasUninlineableIntrinsic(false), UsesVarArgs(false), AllocatedSize(0),
+ NumInstructions(0), NumVectorInstructions(0), VectorBonus(0),
+ SingleBBBonus(0), EnableLoadElimination(true), LoadEliminationCost(0),
+ NumConstantArgs(0), NumConstantOffsetPtrArgs(0), NumAllocaArgs(0),
+ NumConstantPtrCmps(0), NumConstantPtrDiffs(0),
+ NumInstructionsSimplified(0), SROACostSavings(0),
+ SROACostSavingsLost(0) {}
bool analyzeCall(CallSite CS);
@@ -1231,8 +1232,9 @@
disableLoadElimination();
// SROA can usually chew through these intrinsics, but they aren't free.
return false;
+ case Intrinsic::icall_branch_funnel:
case Intrinsic::localescape:
- HasFrameEscape = true;
+ HasUninlineableIntrinsic = true;
return false;
case Intrinsic::vastart:
case Intrinsic::vaend:
@@ -1572,7 +1574,7 @@
using namespace ore;
// If the visit this instruction detected an uninlinable pattern, abort.
if (IsRecursiveCall || ExposesReturnsTwice || HasDynamicAlloca ||
- HasIndirectBr || HasFrameEscape || UsesVarArgs) {
+ HasIndirectBr || HasUninlineableIntrinsic || UsesVarArgs) {
if (ORE)
ORE->emit([&]() {
return OptimizationRemarkMissed(DEBUG_TYPE, "NeverInline",
@@ -2044,6 +2046,9 @@
switch (CS.getCalledFunction()->getIntrinsicID()) {
default:
break;
+ // Disallow inlining of @llvm.icall.branch.funnel because current
+ // backend can't separate call targets from call arguments.
+ case llvm::Intrinsic::icall_branch_funnel:
// Disallow inlining functions that call @llvm.localescape. Doing this
// correctly would require major changes to the inliner.
case llvm::Intrinsic::localescape: