summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/Linker.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-09-23 18:14:15 +0000
committerChris Lattner <sabre@nondot.org>2002-09-23 18:14:15 +0000
commit4037a261d876f6359fa8b23c15f1ebc6863d5a5b (patch)
treeddd335502933b5360d977d10b36657ccfca6658a /llvm/lib/Transforms/Utils/Linker.cpp
parent6b9be6f95af27b7942866d6862deab5ebfc876c5 (diff)
downloadbcm5719-llvm-4037a261d876f6359fa8b23c15f1ebc6863d5a5b.tar.gz
bcm5719-llvm-4037a261d876f6359fa8b23c15f1ebc6863d5a5b.zip
Insert resolved constants into the global map so they are reused correctly.
This bug was exposed linking the SPEC benchmark suite. llvm-svn: 3888
Diffstat (limited to 'llvm/lib/Transforms/Utils/Linker.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Linker.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/Linker.cpp b/llvm/lib/Transforms/Utils/Linker.cpp
index beab3d5a847..6753f51657c 100644
--- a/llvm/lib/Transforms/Utils/Linker.cpp
+++ b/llvm/lib/Transforms/Utils/Linker.cpp
@@ -81,7 +81,7 @@ static void PrintMap(const map<const Value*, Value*> &M) {
// automatically handle constant references correctly as well...
//
static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
- const map<const Value*, Value*> *GlobalMap = 0) {
+ map<const Value*, Value*> *GlobalMap = 0) {
map<const Value*,Value*>::const_iterator I = LocalMap.find(In);
if (I != LocalMap.end()) return I->second;
@@ -148,7 +148,10 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
}
// Cache the mapping in our local map structure...
- LocalMap.insert(std::make_pair(In, Result));
+ if (GlobalMap)
+ GlobalMap->insert(std::make_pair(In, Result));
+ else
+ LocalMap.insert(std::make_pair(In, Result));
return Result;
}
@@ -314,7 +317,7 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
// function, and that Src is not.
//
static bool LinkFunctionBody(Function *Dest, const Function *Src,
- const map<const Value*, Value*> &GlobalMap,
+ map<const Value*, Value*> &GlobalMap,
string *Err = 0) {
assert(Src && Dest && Dest->isExternal() && !Src->isExternal());
map<const Value*, Value*> LocalMap; // Map for function local values
OpenPOWER on IntegriCloud