[llvm-commits] [llvm] r53557 - in /llvm/trunk: include/llvm/Transforms/Utils/InlineCost.h lib/Transforms/Utils/InlineCost.cpp
Chris Lattner
sabre at nondot.org
Mon Jul 14 10:32:59 PDT 2008
Author: lattner
Date: Mon Jul 14 12:32:59 2008
New Revision: 53557
URL: http://llvm.org/viewvc/llvm-project?rev=53557&view=rev
Log:
Reapply r53540, now with the matching header!
Modified:
llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h
llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
Modified: llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h?rev=53557&r1=53556&r2=53557&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/InlineCost.h Mon Jul 14 12:32:59 2008
@@ -38,6 +38,10 @@
// FunctionInfo - For each function, calculate the size of it in blocks and
// instructions.
struct FunctionInfo {
+ /// NeverInline - True if this callee should never be inlined into a
+ /// caller.
+ bool NeverInline;
+
/// NumInsts, NumBlocks - Keep track of how large each function is, which
/// is used to estimate the code size cost of inlining it.
unsigned NumInsts, NumBlocks;
@@ -53,7 +57,8 @@
/// entry here.
std::vector<ArgInfo> ArgumentWeights;
- FunctionInfo() : NumInsts(0), NumBlocks(0), NumVectorInsts(0) {}
+ FunctionInfo() : NeverInline(false), NumInsts(0), NumBlocks(0),
+ NumVectorInsts(0) {}
/// analyzeFunction - Fill in the current structure with information
/// gleaned from the specified function.
Modified: llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineCost.cpp?rev=53557&r1=53556&r2=53557&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineCost.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineCost.cpp Mon Jul 14 12:32:59 2008
@@ -100,9 +100,27 @@
for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
for (BasicBlock::const_iterator II = BB->begin(), E = BB->end();
II != E; ++II) {
- if (isa<DbgInfoIntrinsic>(II)) continue; // Debug intrinsics don't count.
if (isa<PHINode>(II)) continue; // PHI nodes don't count.
+ // Special handling for calls.
+ if (isa<CallInst>(II) || isa<InvokeInst>(II)) {
+ if (isa<DbgInfoIntrinsic>(II))
+ continue; // Debug intrinsics don't count as size.
+
+ CallSite CS = CallSite::get(const_cast<Instruction*>(&*II));
+
+ // If this function contains a call to setjmp or _setjmp, never inline
+ // it. This is a hack because we depend on the user marking their local
+ // variables as volatile if they are live across a setjmp call, and they
+ // probably won't do this in callers.
+ if (Function *F = CS.getCalledFunction())
+ if (F->isDeclaration() &&
+ (F->isName("setjmp") || F->isName("_setjmp"))) {
+ NeverInline = true;
+ return;
+ }
+ }
+
if (isa<ExtractElementInst>(II) || isa<VectorType>(II->getType()))
++NumVectorInsts;
@@ -194,6 +212,10 @@
// If we haven't calculated this information yet, do so now.
if (CalleeFI.NumBlocks == 0)
CalleeFI.analyzeFunction(Callee);
+
+ // If we should never inline this, return a huge cost.
+ if (CalleeFI.NeverInline)
+ return 2000000000;
// Add to the inline quality for properties that make the call valuable to
// inline. This includes factors that indicate that the result of inlining
More information about the llvm-commits
mailing list