[llvm] r359253 - [GlobalOpt] Swap the expensive check for cold calls with the cheap TTI check

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 25 17:12:50 PDT 2019


Author: bogner
Date: Thu Apr 25 17:12:50 2019
New Revision: 359253

URL: http://llvm.org/viewvc/llvm-project?rev=359253&view=rev
Log:
[GlobalOpt] Swap the expensive check for cold calls with the cheap TTI check

isValidCandidateForColdCC is much more expensive than
TTI.useColdCCForColdCall, which by default just returns false. Avoid
doing this work if we're not going to look at the answer anyway.

This change is NFC, but I see significant compile time improvements on
some code with pathologically many functions.

Modified:
    llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp

Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=359253&r1=359252&r2=359253&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Thu Apr 25 17:12:50 2019
@@ -2295,8 +2295,8 @@ OptimizeFunctions(Module &M, TargetLibra
       // cold at all call sites and the callers contain no other non coldcc
       // calls.
       if (EnableColdCCStressTest ||
-          (isValidCandidateForColdCC(*F, GetBFI, AllCallsCold) &&
-           TTI.useColdCCForColdCall(*F))) {
+          (TTI.useColdCCForColdCall(*F) &&
+           isValidCandidateForColdCC(*F, GetBFI, AllCallsCold))) {
         F->setCallingConv(CallingConv::Cold);
         changeCallSitesToColdCC(F);
         Changed = true;




More information about the llvm-commits mailing list