summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-04 04:47:41 +0000
committerChris Lattner <sabre@nondot.org>2008-04-04 04:47:41 +0000
commitee1817300a638e014c06b2ab6dae6f99ae11358e (patch)
tree8a8a9a007db5088c2fc968d7ca287cf5fcf5d299 /llvm/lib/ExecutionEngine/ExecutionEngine.cpp
parent5506f8cf4c6e9f606990bf69561abeb83d4100f3 (diff)
downloadbcm5719-llvm-ee1817300a638e014c06b2ab6dae6f99ae11358e.tar.gz
bcm5719-llvm-ee1817300a638e014c06b2ab6dae6f99ae11358e.zip
Make ExecutionEngine::updateGlobalMapping return the old mapping.
llvm-svn: 49206
Diffstat (limited to 'llvm/lib/ExecutionEngine/ExecutionEngine.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/ExecutionEngine.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
index 6c04e868622..a56951d2c52 100644
--- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -109,18 +109,30 @@ void ExecutionEngine::clearAllGlobalMappings() {
/// updateGlobalMapping - Replace an existing mapping for GV with a new
/// address. This updates both maps as required. If "Addr" is null, the
/// entry for the global is removed from the mappings.
-void ExecutionEngine::updateGlobalMapping(const GlobalValue *GV, void *Addr) {
+void *ExecutionEngine::updateGlobalMapping(const GlobalValue *GV, void *Addr) {
MutexGuard locked(lock);
-
+
+ std::map<const GlobalValue*, void *> &Map = state.getGlobalAddressMap(locked);
+
// Deleting from the mapping?
if (Addr == 0) {
- state.getGlobalAddressMap(locked).erase(GV);
+ std::map<const GlobalValue*, void *>::iterator I = Map.find(GV);
+ void *OldVal;
+ if (I == Map.end())
+ OldVal = 0;
+ else {
+ OldVal = I->second;
+ Map.erase(I);
+ }
+
if (!state.getGlobalAddressReverseMap(locked).empty())
state.getGlobalAddressReverseMap(locked).erase(Addr);
- return;
+ return OldVal;
}
- void *&CurVal = state.getGlobalAddressMap(locked)[GV];
+ void *&CurVal = Map[GV];
+ void *OldVal = CurVal;
+
if (CurVal && !state.getGlobalAddressReverseMap(locked).empty())
state.getGlobalAddressReverseMap(locked).erase(CurVal);
CurVal = Addr;
@@ -131,6 +143,7 @@ void ExecutionEngine::updateGlobalMapping(const GlobalValue *GV, void *Addr) {
assert((V == 0 || GV == 0) && "GlobalMapping already established!");
V = GV;
}
+ return OldVal;
}
/// getPointerToGlobalIfAvailable - This returns the address of the specified
OpenPOWER on IntegriCloud