summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/CloneModule.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2008-10-09 06:27:14 +0000
committerNick Lewycky <nicholas@mxc.ca>2008-10-09 06:27:14 +0000
commita6bf66d0d6c1ed9bb657f72bc89c432c4ee96f63 (patch)
tree7ce228476bf332a2532afa59c18f5570c6b388a7 /lib/Transforms/Utils/CloneModule.cpp
parentd2a27ee974053ff3c1a81dab8f340a125f29ac36 (diff)
downloadllvm-a6bf66d0d6c1ed9bb657f72bc89c432c4ee96f63.tar.gz
llvm-a6bf66d0d6c1ed9bb657f72bc89c432c4ee96f63.tar.bz2
llvm-a6bf66d0d6c1ed9bb657f72bc89c432c4ee96f63.tar.xz
Don't drop alignment on globals when cloning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57320 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/CloneModule.cpp')
-rw-r--r--lib/Transforms/Utils/CloneModule.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp
index c94c531b01..337fa8a44b 100644
--- a/lib/Transforms/Utils/CloneModule.cpp
+++ b/lib/Transforms/Utils/CloneModule.cpp
@@ -55,10 +55,14 @@ Module *llvm::CloneModule(const Module *M,
// 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 @@ Module *llvm::CloneModule(const Module *M,
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