[llvm-commits] CVS: reopt/lib/LightWtProfiling/TraceToFunction.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Sat May 15 19:25:01 PDT 2004


Changes in directory reopt/lib/LightWtProfiling:

TraceToFunction.cpp updated: 1.32 -> 1.33

---
Log message:

Extract first-level trigger call detector out into isFirstTriggerCall();
isFirstLevelInstrumentationBlock is going to use it.


---
Diffs of the changes:  (+25 -14)

Index: reopt/lib/LightWtProfiling/TraceToFunction.cpp
diff -u reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.32 reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.33
--- reopt/lib/LightWtProfiling/TraceToFunction.cpp:1.32	Sat May 15 19:00:52 2004
+++ reopt/lib/LightWtProfiling/TraceToFunction.cpp	Sat May 15 19:24:08 2004
@@ -288,6 +288,23 @@
   }
 }
 
+/// isFirstTriggerCall - Returns true iff I is a call instruction which appears
+/// to call into the first-level trigger function.
+///
+static bool isFirstTriggerCall (Instruction &I) {
+  if (CallInst *CI = dyn_cast<CallInst> (&I)) {
+    Function *CF = CI->getCalledFunction ();
+    // Look for an external function call with no args to "llvm_first_trigger".
+    if (CF && CF->isExternal () && CF->hasName()
+        && CF->getName () == "llvm_first_trigger" && CF->asize () == 0) {
+      DEBUG(std::cerr << " (Found a call instruction " << *CI
+            << " ... Smells like llvm_first_trigger.)\n");
+      return true;
+    }
+  }
+  return false;
+}
+
 static void fixupPhisAndCalls (BasicBlock *dstB, ValueMap &O2CMap) {
   std::vector<Instruction *> goners;
   Function *F = dstB->getParent ();
@@ -349,19 +366,9 @@
 
   // Remove calls to first-level instrumentation if we find them.
   for (BasicBlock::iterator BI = dstB->begin (), BE = dstB->end ();
-       BI != BE; ++BI) {
-    Instruction &I = *BI;
-    if (CallInst *CI = dyn_cast<CallInst> (&I)) {
-      Function *CF = CI->getCalledFunction ();
-      
-      if (CF && CF->isExternal () && CF->hasName()
-	  && CF->getName () == "llvm_first_trigger") {
-	DEBUG(std::cerr << " (Found a call instruction " << *CI
-	      << " ... Smells like llvm_first_trigger.)\n");
-	goners.push_back (BI);
-      }
-    }
-  }
+       BI != BE; ++BI)
+    if (isFirstTriggerCall (*BI))
+      goners.push_back (BI);
 
   while (!goners.empty ()) {
     assert (goners.back ()->use_size () == 0
@@ -407,7 +414,11 @@
 /// inserted by the first-level instrumentation (-instloops) pass.
 ///
 static bool isFirstLevelInstrumentationBlock (BasicBlock *BB) {
-  // not yet implemented
+  BasicBlock::iterator i = BB->begin ();
+  if (!isFirstTriggerCall (*i))
+    return false;
+  ++i;
+  // FIXME
   return false;
 }
 





More information about the llvm-commits mailing list