aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Linker/LinkModules.cpp
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2008-03-05 15:27:21 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2008-03-05 15:27:21 +0000
commit3cfecfde268532c903322fc53b9228d152be7c4b (patch)
tree27fdf357a0294b552953a65747ee6a5736819d61 /lib/Linker/LinkModules.cpp
parent2d4fd78e3d5370e4d5d462121d6d77cfbeabe4fb (diff)
downloadexternal_llvm-3cfecfde268532c903322fc53b9228d152be7c4b.zip
external_llvm-3cfecfde268532c903322fc53b9228d152be7c4b.tar.gz
external_llvm-3cfecfde268532c903322fc53b9228d152be7c4b.tar.bz2
Remember the source->dest mapping when copying aliases. This fixes PR2054
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47945 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker/LinkModules.cpp')
-rw-r--r--lib/Linker/LinkModules.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index 260bcb4..dd2b4f6 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -567,7 +567,9 @@ static bool LinkGlobals(Module *Dest, Module *Src,
// LinkAlias - Loop through the alias in the src module and link them into the
// dest module.
-static bool LinkAlias(Module *Dest, const Module *Src, std::string *Err) {
+static bool LinkAlias(Module *Dest, const Module *Src,
+ std::map<const Value*, Value*> &ValueMap,
+ std::string *Err) {
// FIXME: Desptie of the name, this function currently does not 'link' stuff,
// but only copies aliases from one Module to another.
@@ -588,6 +590,8 @@ static bool LinkAlias(Module *Dest, const Module *Src, std::string *Err) {
GlobalAlias *NewGA = new GlobalAlias(GA->getType(), GA->getLinkage(),
GA->getName(), NewAliasee, Dest);
CopyGVAttributes(NewGA, GA);
+
+ ValueMap.insert(std::make_pair(GA, NewGA));
}
return false;
}
@@ -1033,6 +1037,11 @@ Linker::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) {
if (LinkFunctionProtos(Dest, Src, ValueMap, ErrorMsg))
return true;
+ // If there were any alias, link them now. We really need to do this now,
+ // because all of the aliases that may be referenced need to be available in
+ // ValueMap
+ if (LinkAlias(Dest, Src, ValueMap, ErrorMsg)) return true;
+
// Update the initializers in the Dest module now that all globals that may
// be referenced are in Dest.
if (LinkGlobalInits(Dest, Src, ValueMap, ErrorMsg)) return true;
@@ -1045,9 +1054,6 @@ Linker::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) {
// If there were any appending global variables, link them together now.
if (LinkAppendingVars(Dest, AppendingVars, ErrorMsg)) return true;
- // If there were any alias, link them now.
- if (LinkAlias(Dest, Src, ErrorMsg)) return true;
-
// If the source library's module id is in the dependent library list of the
// destination library, remove it since that module is now linked in.
sys::Path modId;