Extend the StartPassTimer and StopPassTimer functions so that the
code that stops the timer doesn't have to search to find the timer
object before it stops the timer. This avoids a lock acquisition
and a few other things done with the timer running.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82949 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/IPA/CallGraphSCCPass.cpp b/lib/Analysis/IPA/CallGraphSCCPass.cpp
index 801ae19..a96a5c5 100644
--- a/lib/Analysis/IPA/CallGraphSCCPass.cpp
+++ b/lib/Analysis/IPA/CallGraphSCCPass.cpp
@@ -96,9 +96,9 @@
       CallGraphUpToDate = true;
     }
 
-    StartPassTimer(CGSP);
+    Timer *T = StartPassTimer(CGSP);
     Changed = CGSP->runOnSCC(CurSCC);
-    StopPassTimer(CGSP);
+    StopPassTimer(CGSP, T);
     
     // After the CGSCCPass is done, when assertions are enabled, use
     // RefreshCallGraph to verify that the callgraph was correctly updated.
@@ -110,7 +110,6 @@
     return Changed;
   }
   
-  StartPassTimer(P);
   FPPassManager *FPP = dynamic_cast<FPPassManager *>(P);
   assert(FPP && "Invalid CGPassManager member");
   
@@ -118,10 +117,11 @@
   for (unsigned i = 0, e = CurSCC.size(); i != e; ++i) {
     if (Function *F = CurSCC[i]->getFunction()) {
       dumpPassInfo(P, EXECUTION_MSG, ON_FUNCTION_MSG, F->getName());
+      Timer *T = StartPassTimer(FPP);
       Changed |= FPP->runOnFunction(*F);
+      StopPassTimer(FPP, T);
     }
   }
-  StopPassTimer(P);
   
   // The function pass(es) modified the IR, they may have clobbered the
   // callgraph.
diff --git a/lib/Analysis/LoopPass.cpp b/lib/Analysis/LoopPass.cpp
index c9515f6..f3686fe 100644
--- a/lib/Analysis/LoopPass.cpp
+++ b/lib/Analysis/LoopPass.cpp
@@ -232,10 +232,10 @@
       LoopPass *LP = dynamic_cast<LoopPass *>(P);
       {
         PassManagerPrettyStackEntry X(LP, *CurrentLoop->getHeader());
-        StartPassTimer(P);
         assert(LP && "Invalid LPPassManager member");
+        Timer *T = StartPassTimer(P);
         Changed |= LP->runOnLoop(CurrentLoop, *this);
-        StopPassTimer(P);
+        StopPassTimer(P, T);
       }
 
       if (Changed)