[InlineCost] Mark functions accessing varargs as not viable.
This prevents functions accessing varargs from being inlined if they
have the alwaysinline attribute.
Reviewers: efriedma, rnk, davide
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D42556
llvm-svn: 323619
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 0e7be52..b0e0acd 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -2040,12 +2040,18 @@
cast<CallInst>(CS.getInstruction())->canReturnTwice())
return false;
- // Disallow inlining functions that call @llvm.localescape. Doing this
- // correctly would require major changes to the inliner.
- if (CS.getCalledFunction() &&
- CS.getCalledFunction()->getIntrinsicID() ==
- llvm::Intrinsic::localescape)
- return false;
+ if (CS.getCalledFunction())
+ switch (CS.getCalledFunction()->getIntrinsicID()) {
+ default:
+ break;
+ // Disallow inlining functions that call @llvm.localescape. Doing this
+ // correctly would require major changes to the inliner.
+ case llvm::Intrinsic::localescape:
+ // Disallow inlining of functions that access VarArgs.
+ case llvm::Intrinsic::vastart:
+ case llvm::Intrinsic::vaend:
+ return false;
+ }
}
}