summaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2007-07-10 19:07:35 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2007-07-10 19:07:35 +0000
commita289511090b2b48e0824349865e5bc9cb4b7d33c (patch)
treeefb9b3dc8653ebc8b58b787907b69e767399af99 /lib/Transforms/Utils
parent06b6e82f79a30e0cc16c736875069f0f64cc400a (diff)
downloadexternal_llvm-a289511090b2b48e0824349865e5bc9cb4b7d33c.zip
external_llvm-a289511090b2b48e0824349865e5bc9cb4b7d33c.tar.gz
external_llvm-a289511090b2b48e0824349865e5bc9cb4b7d33c.tar.bz2
During module cloning copy aliases too. This fixes PR1544
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38505 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/CloneModule.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp
index dbe40a3..d64d58f 100644
--- a/lib/Transforms/Utils/CloneModule.cpp
+++ b/lib/Transforms/Utils/CloneModule.cpp
@@ -69,6 +69,12 @@ Module *llvm::CloneModule(const Module *M,
ValueMap[I]= NF;
}
+ // Loop over the aliases in the module
+ for (Module::const_alias_iterator I = M->alias_begin(), E = M->alias_end();
+ I != E; ++I)
+ ValueMap[I] = new GlobalAlias(I->getType(), GlobalAlias::ExternalLinkage,
+ I->getName(), NULL, New);
+
// Now that all of the things that global variable initializer can refer to
// have been created, loop through and copy the global variable referrers
// over... We also set the attributes on the global now.
@@ -103,6 +109,15 @@ Module *llvm::CloneModule(const Module *M,
F->setLinkage(I->getLinkage());
}
+ // And aliases
+ for (Module::const_alias_iterator I = M->alias_begin(), E = M->alias_end();
+ I != E; ++I) {
+ GlobalAlias *GA = cast<GlobalAlias>(ValueMap[I]);
+ GA->setLinkage(I->getLinkage());
+ if (const Constant* C = I->getAliasee())
+ GA->setAliasee(cast<Constant>(MapValue(C, ValueMap)));
+ }
+
return New;
}