summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-11-22 16:54:54 +0000
committerChris Lattner <sabre@nondot.org>2004-11-22 16:54:54 +0000
commitf5feaf4fe381476b0ea567d7837c64b6590133e9 (patch)
tree8afbc72d6f5094aff4a09db77c3549866d99e42d /include
parent8fb51e4800fe4c490329c92c876cf4441d36a780 (diff)
downloadllvm-f5feaf4fe381476b0ea567d7837c64b6590133e9.tar.gz
llvm-f5feaf4fe381476b0ea567d7837c64b6590133e9.tar.bz2
llvm-f5feaf4fe381476b0ea567d7837c64b6590133e9.tar.xz
This is the proper code for this method, thanks to Reid for getting CVS working
again. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18103 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/ExecutionEngine/ExecutionEngine.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h
index adc2b2f5c7..dd83a8a522 100644
--- a/include/llvm/ExecutionEngine/ExecutionEngine.h
+++ b/include/llvm/ExecutionEngine/ExecutionEngine.h
@@ -93,11 +93,20 @@ public:
}
}
- /// 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