diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2007-07-10 19:07:35 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2007-07-10 19:07:35 +0000 |
commit | 76547349c148926d69be105d4cb30b16cc3d704e (patch) | |
tree | 68ade25e27001a107d7c967184c3bed3c1ad22ee /llvm/lib/Transforms/Utils/CloneModule.cpp | |
parent | 1fa6132e8578531b92f77ae158b6e3fe53641f1c (diff) | |
download | llvm-76547349c148926d69be105d4cb30b16cc3d704e.zip llvm-76547349c148926d69be105d4cb30b16cc3d704e.tar.gz llvm-76547349c148926d69be105d4cb30b16cc3d704e.tar.bz2 |
During module cloning copy aliases too. This fixes PR1544
llvm-svn: 38505
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneModule.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/CloneModule.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneModule.cpp b/llvm/lib/Transforms/Utils/CloneModule.cpp index dbe40a3..d64d58f 100644 --- a/llvm/lib/Transforms/Utils/CloneModule.cpp +++ b/llvm/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; } |