[llvm-commits] [llvm] r94589 - /llvm/trunk/lib/Analysis/InlineCost.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Tue Jan 26 13:31:24 PST 2010


Author: stoklund
Date: Tue Jan 26 15:31:24 2010
New Revision: 94589

URL: http://llvm.org/viewvc/llvm-project?rev=94589&view=rev
Log:
Skip calculation of ArgumentWeights if it will never be used.

Save a few bytes by allocating the correct size vector.

No functional change intended.

Modified:
    llvm/trunk/lib/Analysis/InlineCost.cpp

Modified: llvm/trunk/lib/Analysis/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=94589&r1=94588&r2=94589&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/InlineCost.cpp (original)
+++ llvm/trunk/lib/Analysis/InlineCost.cpp Tue Jan 26 15:31:24 2010
@@ -223,8 +223,14 @@
   if (Metrics.NumRets==1)
     --Metrics.NumInsts;
 
+  // Don't bother calculating argument weights if we are never going to inline
+  // the function anyway.
+  if (Metrics.NeverInline)
+    return;
+
   // Check out all of the arguments to the function, figuring out how much
   // code can be eliminated if one of the arguments is a constant.
+  ArgumentWeights.reserve(F->arg_size());
   for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I)
     ArgumentWeights.push_back(ArgInfo(CountCodeReductionForConstant(I),
                                       CountCodeReductionForAlloca(I)));





More information about the llvm-commits mailing list