[llvm-commits] [llvm] r57320 - /llvm/trunk/lib/Transforms/Utils/CloneModule.cpp
Nick Lewycky
nicholas at mxc.ca
Wed Oct 8 23:27:14 PDT 2008
Author: nicholas
Date: Thu Oct 9 01:27:14 2008
New Revision: 57320
URL: http://llvm.org/viewvc/llvm-project?rev=57320&view=rev
Log:
Don't drop alignment on globals when cloning.
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=57320&r1=57319&r2=57320&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneModule.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CloneModule.cpp Thu Oct 9 01:27:14 2008
@@ -55,10 +55,14 @@
// don't worry about attributes or initializers, they will come later.
//
for (Module::const_global_iterator I = M->global_begin(), E = M->global_end();
- I != E; ++I)
- ValueMap[I] = new GlobalVariable(I->getType()->getElementType(), false,
- GlobalValue::ExternalLinkage, 0,
- I->getName(), New);
+ I != E; ++I) {
+ GlobalVariable *GV = new GlobalVariable(I->getType()->getElementType(),
+ false,
+ GlobalValue::ExternalLinkage, 0,
+ I->getName(), New);
+ GV->setAlignment(I->getAlignment());
+ ValueMap[I] = GV;
+ }
// Loop over the functions in the module, making external functions as before
for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) {
@@ -66,7 +70,7 @@
Function::Create(cast<FunctionType>(I->getType()->getElementType()),
GlobalValue::ExternalLinkage, I->getName(), New);
NF->copyAttributesFrom(I);
- ValueMap[I]= NF;
+ ValueMap[I] = NF;
}
// Loop over the aliases in the module
More information about the llvm-commits
mailing list