Change FunctionInfo from being an annotation put on Functions to be
authorChris Lattner <sabre@nondot.org>
Wed, 17 Sep 2003 17:26:22 +0000 (17:26 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 17 Sep 2003 17:26:22 +0000 (17:26 +0000)
something which is mapped from functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8580 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/Interpreter/Execution.cpp
lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h
lib/ExecutionEngine/Interpreter/Interpreter.h

index 4570f1a239e4c140a9131ffb913a2fb1ce044517..d3818063d00017ded4a190c4ed4d0aa3e7fe44d3 100644 (file)
@@ -120,8 +120,6 @@ static void SetValue(Value *V, GenericValue Val, ExecutionContext &SF) {
 
 void Interpreter::initializeExecutionEngine() {
   TheEE = this;
-  AnnotationManager::registerAnnotationFactory(FunctionInfoAID,
-                                               &FunctionInfo::Create);
   initializeSignalHandlers();
 }
 
@@ -899,7 +897,7 @@ void Interpreter::visitVarArgInst(VarArgInst &I) {
 //                        Dispatch and Execution Code
 //===----------------------------------------------------------------------===//
 
-FunctionInfo::FunctionInfo(Function *F) : Annotation(FunctionInfoAID) {
+FunctionInfo::FunctionInfo(Function *F) {
   // Assign slot numbers to the function arguments...
   for (Function::const_aiterator AI = F->abegin(), E = F->aend(); AI != E; ++AI)
     AI->addAnnotation(new SlotNumber(getValueSlot(AI)));
@@ -959,11 +957,12 @@ void Interpreter::callFunction(Function *F,
   // the function.  Also calculate the number of values for each type slot
   // active.
   //
-  FunctionInfo *FuncInfo =
-    (FunctionInfo*)F->getOrCreateAnnotation(FunctionInfoAID);
-  ECStack.push_back(ExecutionContext());         // Make a new stack frame...
+  FunctionInfo *&FuncInfo = FunctionInfoMap[F];
+  if (!FuncInfo) FuncInfo = new FunctionInfo(F);
 
-  ExecutionContext &StackFrame = ECStack.back(); // Fill it in...
+  // Make a new stack frame... and fill it in.
+  ECStack.push_back(ExecutionContext());
+  ExecutionContext &StackFrame = ECStack.back();
   StackFrame.CurFunction = F;
   StackFrame.CurBB     = F->begin();
   StackFrame.CurInst   = StackFrame.CurBB->begin();
index e17aa4b3552bf5b24dfa8e50479422d305376b55..cca1233ea3e7e488e6f6d8f5803ca030b9602c94 100644 (file)
 // information about the function, including the number of types present in the
 // function, and the number of values for each type.
 //
-// This annotation object is created on demand, and attaches other annotation
-// objects to the instructions in the function when it's created.
-//
-static AnnotationID FunctionInfoAID(
-                   AnnotationManager::getID("Interpreter::FunctionInfo"));
-
-struct FunctionInfo : public Annotation {
+struct FunctionInfo {
   FunctionInfo(Function *F);
   std::vector<unsigned> NumPlaneElements;
 
-  // Create - Factory function to allow FunctionInfo annotations to be
-  // created on demand.
-  //
-  static Annotation *Create(AnnotationID AID, const Annotable *O, void *) {
-    assert(AID == FunctionInfoAID);
-    return new FunctionInfo(cast<Function>((Value*)O));
-  }
-
 private:
   unsigned getValueSlot(const Value *V);
 };
index 26ed2dc6d156141cc89ff682433cc0b16db88c0d..61d391a360a7bc849ad3d634b4a32f25ac622cc5 100644 (file)
@@ -82,6 +82,8 @@ class Interpreter : public ExecutionEngine, public InstVisitor<Interpreter> {
   // AtExitHandlers - List of functions to call when the program exits,
   // registered with the atexit() library function.
   std::vector<Function*> AtExitHandlers;
+
+  std::map<Function*, FunctionInfo*> FunctionInfoMap;
 public:
   Interpreter(Module *M, bool isLittleEndian, bool isLongPointer,
               bool TraceMode);