[llvm-commits] [llvm] r38505 - /llvm/trunk/lib/Transforms/Utils/CloneModule.cpp
Anton Korobeynikov
asl at math.spbu.ru
Tue Jul 10 12:07:35 PDT 2007
Author: asl
Date: Tue Jul 10 14:07:35 2007
New Revision: 38505
URL: http://llvm.org/viewvc/llvm-project?rev=38505&view=rev
Log:
During module cloning copy aliases too. This fixes PR1544
Modified:
llvm/trunk/lib/Transforms/Utils/CloneModule.cpp
Modified: llvm/trunk/lib/Transforms/Utils/CloneModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneModule.cpp?rev=38505&r1=38504&r2=38505&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneModule.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CloneModule.cpp Tue Jul 10 14:07:35 2007
@@ -69,6 +69,12 @@
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 @@
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;
}
More information about the llvm-commits
mailing list