Reapply r194218 with fix:

Move copying of global initializers below the cloning of functions.

The BlockAddress doesn't have access to the correct basic blocks until the
functions have been cloned. This causes the BlockAddress to point to the old
values. Just wait until the functions have been cloned before copying the
initializers.
PR13163

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199354 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling
2014-01-16 06:29:36 +00:00
parent fab01c1908
commit a950ad4eec
5 changed files with 197 additions and 5 deletions

View File

@ -1249,10 +1249,6 @@ bool ModuleLinker::run() {
for (unsigned i = 0, e = AppendingVars.size(); i != e; ++i)
linkAppendingVarInit(AppendingVars[i]);
// Update the initializers in the DstM module now that all globals that may
// be referenced are in DstM.
linkGlobalInits();
// Link in the function bodies that are defined in the source module into
// DstM.
for (Module::iterator SF = SrcM->begin(), E = SrcM->end(); SF != E; ++SF) {
@ -1290,6 +1286,10 @@ bool ModuleLinker::run() {
if (linkModuleFlagsMetadata())
return true;
// Update the initializers in the DstM module now that all globals that may
// be referenced are in DstM.
linkGlobalInits();
// Process vector of lazily linked in functions.
bool LinkedInAnyFunctions;
do {