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

Brian Gaeke gaeke at cs.uiuc.edu
Tue Jun 8 13:55:15 PDT 2004


Changes in directory reopt/lib/LightWtProfiling:

ValueAllocState.cpp updated: 1.2 -> 1.3

---
Log message:

Never let getValueAllocStateKeys abort; just return (-1,-1) if it
couldn't come up with the right keys.  Fix callers to deal with this by
returning a bogus AllocInfo object instead of aborting.


---
Diffs of the changes:  (+22 -22)

Index: reopt/lib/LightWtProfiling/ValueAllocState.cpp
diff -u reopt/lib/LightWtProfiling/ValueAllocState.cpp:1.2 reopt/lib/LightWtProfiling/ValueAllocState.cpp:1.3
--- reopt/lib/LightWtProfiling/ValueAllocState.cpp:1.2	Mon May 31 00:51:44 2004
+++ reopt/lib/LightWtProfiling/ValueAllocState.cpp	Tue Jun  8 13:53:57 2004
@@ -93,19 +93,17 @@
 ///
 static void getValueAllocStateKeys (Function *F, Value *V, int &InstructionKey,
                                     int &OperandKey, bool preferLiveIn) {
+  InstructionKey = -1; OperandKey = -1;
   if (Argument *Arg = dyn_cast<Argument> (V)) {
-    InstructionKey = -1;
     OperandKey = getNumberOfFunctionArg (F, Arg);
   } else if (Instruction *Inst = dyn_cast<Instruction> (V)) {
     InstructionKey = getSavedStateIndexOfInstruction (F, Inst);
     if (isa<PHINode> (Inst) && preferLiveIn
         && Inst->getParent() == TraceEntryBB)
-      OperandKey = -2; // look for PhiCpRes
-    else
-      OperandKey = -1;
+      OperandKey = -2; // look for PhiCpRes instead.
   } else {
-    std::cerr << "getValueAllocStateKeys: can't look up state for " << *V;
-    abort();
+    DEBUG (std::cerr << "getValueAllocStateKeys: keys not known for "
+           << F->getName () << ":" << *V << "\n");
   }
 }
 
@@ -116,12 +114,15 @@
 ///
 static AllocInfo getValueAllocStateFromModule (Function *F, Value *V,
                                                bool preferLiveIn) {
+  int InstructionKey = -1, OperandKey = -1;
+  getValueAllocStateKeys (F, V, InstructionKey, OperandKey, preferLiveIn);
+  if (InstructionKey == -1 && OperandKey == -1)
+    return AllocInfo();
+
   unsigned FI = getLLVMFunctionPositionInfo (F);
   FunctionAllocState *FAllocState = _llvm_regAllocState.functions[FI];
   assert (FAllocState->numTuples > 0
           && "Reg. alloc state for function is empty");
-  int InstructionKey = -1, OperandKey = -1;
-  getValueAllocStateKeys (F, V, InstructionKey, OperandKey, preferLiveIn);
   // Reconstruct the AllocInfo for V by searching
   // _llvm_regAllocState.functions[FI] for a tuple that starts with
   // (InstructionKey, OperandKey, ...):
@@ -136,12 +137,10 @@
       return AI;
     }
   }
-  // By this time we had better have found it, otherwise we are about to do bad
-  // things.
-  std::cerr << "ERROR: No saved AllocInfo found for "
-            << F->getName () << "()'s value " << *V
-            << " in getValueAllocStateFromModule()\n";
-  abort ();
+  DEBUG (std::cerr << "Alloc state saved in module for " << F->getName ()
+         << ":" << V->getName () << " (key = " << InstructionKey << ","
+         << OperandKey << ") NOT FOUND\n");
+  return AllocInfo();
 }
 
 /// Returns the register number or stack position where V can be found in the
@@ -150,11 +149,14 @@
 ///
 static AllocInfo getValueAllocStateFromGlobal (Function *F, Value *V,
                                                bool preferLiveIn) {
+  int InstructionKey = -1, OperandKey = -1;
+  getValueAllocStateKeys (F, V, InstructionKey, OperandKey, preferLiveIn);
+  if (InstructionKey == -1 && OperandKey == -1)
+    return AllocInfo();
+
   // Get the saved PhyRegAlloc state for F out of ExportedFnAllocState:
   std::vector<AllocInfo> &FState = ExportedFnAllocState[F];
   assert (FState.size () > 0 && "Reg. alloc state for function is empty");
-  int InstructionKey = -1, OperandKey = -1;
-  getValueAllocStateKeys (F, V, InstructionKey, OperandKey, preferLiveIn);
   // Reconstruct the AllocInfo for V by searching
   // FState for a tuple that starts with (InstructionKey, OperandKey, ...):
   for (unsigned i = 0, s = FState.size (); i < s; ++i) {
@@ -166,12 +168,10 @@
       return T;
     }
   }
-  // By this time we had better have found it, otherwise we are about to do bad
-  // things.
-  std::cerr << "ERROR: No saved AllocInfo found for "
-            << F->getName () << "()'s value " << *V
-            << " in getValueAllocStateFromGlobal()\n";
-  abort ();
+  DEBUG (std::cerr << "Alloc state saved in global for " << F->getName ()
+         << ":" << V->getName () << " (key = " << InstructionKey << ","
+         << OperandKey << ") NOT FOUND\n");
+  return AllocInfo();
 }
 
 /// GetValueAllocState - Returns a pair <MatrixState,TraceState> containing the





More information about the llvm-commits mailing list