[llvm-commits] [llvm] r47945 - /llvm/trunk/lib/Linker/LinkModules.cpp
Anton Korobeynikov
asl at math.spbu.ru
Wed Mar 5 07:27:21 PST 2008
Author: asl
Date: Wed Mar 5 09:27:21 2008
New Revision: 47945
URL: http://llvm.org/viewvc/llvm-project?rev=47945&view=rev
Log:
Remember the source->dest mapping when copying aliases. This fixes PR2054
Modified:
llvm/trunk/lib/Linker/LinkModules.cpp
Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=47945&r1=47944&r2=47945&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Wed Mar 5 09:27:21 2008
@@ -567,7 +567,9 @@
// 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 @@
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 @@
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 @@
// 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;
More information about the llvm-commits
mailing list