From d149c053cdbb406b7b5dff24127b4c509420893e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 23 Sep 2002 18:14:15 +0000 Subject: [PATCH] Insert resolved constants into the global map so they are reused correctly. This bug was exposed linking the SPEC benchmark suite. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3888 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Linker/LinkModules.cpp | 9 ++++++--- lib/Transforms/Utils/Linker.cpp | 9 ++++++--- lib/VMCore/Linker.cpp | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index beab3d5a847..6753f51657c 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -81,7 +81,7 @@ static void PrintMap(const map &M) { // automatically handle constant references correctly as well... // static Value *RemapOperand(const Value *In, map &LocalMap, - const map *GlobalMap = 0) { + map *GlobalMap = 0) { map::const_iterator I = LocalMap.find(In); if (I != LocalMap.end()) return I->second; @@ -148,7 +148,10 @@ static Value *RemapOperand(const Value *In, map &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 &GlobalMap, + map &GlobalMap, string *Err = 0) { assert(Src && Dest && Dest->isExternal() && !Src->isExternal()); map LocalMap; // Map for function local values diff --git a/lib/Transforms/Utils/Linker.cpp b/lib/Transforms/Utils/Linker.cpp index beab3d5a847..6753f51657c 100644 --- a/lib/Transforms/Utils/Linker.cpp +++ b/lib/Transforms/Utils/Linker.cpp @@ -81,7 +81,7 @@ static void PrintMap(const map &M) { // automatically handle constant references correctly as well... // static Value *RemapOperand(const Value *In, map &LocalMap, - const map *GlobalMap = 0) { + map *GlobalMap = 0) { map::const_iterator I = LocalMap.find(In); if (I != LocalMap.end()) return I->second; @@ -148,7 +148,10 @@ static Value *RemapOperand(const Value *In, map &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 &GlobalMap, + map &GlobalMap, string *Err = 0) { assert(Src && Dest && Dest->isExternal() && !Src->isExternal()); map LocalMap; // Map for function local values diff --git a/lib/VMCore/Linker.cpp b/lib/VMCore/Linker.cpp index beab3d5a847..6753f51657c 100644 --- a/lib/VMCore/Linker.cpp +++ b/lib/VMCore/Linker.cpp @@ -81,7 +81,7 @@ static void PrintMap(const map &M) { // automatically handle constant references correctly as well... // static Value *RemapOperand(const Value *In, map &LocalMap, - const map *GlobalMap = 0) { + map *GlobalMap = 0) { map::const_iterator I = LocalMap.find(In); if (I != LocalMap.end()) return I->second; @@ -148,7 +148,10 @@ static Value *RemapOperand(const Value *In, map &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 &GlobalMap, + map &GlobalMap, string *Err = 0) { assert(Src && Dest && Dest->isExternal() && !Src->isExternal()); map LocalMap; // Map for function local values -- 2.34.1