[llvm-commits] CVS: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h

Chris Lattner lattner at cs.uiuc.edu
Mon Nov 22 08:55:08 PST 2004



Changes in directory llvm/include/llvm/ExecutionEngine:

ExecutionEngine.h updated: 1.29 -> 1.30
---
Log message:

This is the proper code for this method, thanks to Reid for getting CVS working
again.


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

Index: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h
diff -u llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:1.29 llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:1.30
--- llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:1.29	Mon Nov 22 06:38:36 2004
+++ llvm/include/llvm/ExecutionEngine/ExecutionEngine.h	Mon Nov 22 10:54:54 2004
@@ -93,11 +93,20 @@
     }
   }
 
-  /// FIXME: I have no idea if this is right, I just implemented it to get
-  /// the build to compile because it is called by JIT/Emitter.cpp.
-  void updateGlobalMapping(const GlobalValue *GV, void*Addr) {
-    GlobalAddressMap[GV] = Addr;
-    GlobalAddressReverseMap[Addr] = GV;
+  /// updateGlobalMapping - Replace an existing mapping for GV with a new
+  /// address.  This updates both maps as required.
+  void updateGlobalMapping(const GlobalValue *GV, void *Addr) {
+    void *&CurVal = GlobalAddressMap[GV];
+    if (CurVal && !GlobalAddressReverseMap.empty())
+      GlobalAddressReverseMap.erase(CurVal);
+    CurVal = Addr;
+
+    // If we are using the reverse mapping, add it too
+    if (!GlobalAddressReverseMap.empty()) {
+      const GlobalValue *&V = GlobalAddressReverseMap[Addr];
+      assert((V == 0 || GV == 0) && "GlobalMapping already established!");
+      V = GV;
+    }
   }
 
   /// getPointerToGlobalIfAvailable - This returns the address of the specified






More information about the llvm-commits mailing list