diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2008-10-09 06:27:14 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2008-10-09 06:27:14 +0000 |
commit | 03c5fa18f17133f1dd0e75883a0ea8ddb366a68a (patch) | |
tree | c77c85c973394dd0a20d48809690e97b49e4aadc /llvm/lib/Transforms/Utils/CloneModule.cpp | |
parent | 1a84f8627101f9195086d806f9bf3488d1d3bc20 (diff) | |
download | bcm5719-llvm-03c5fa18f17133f1dd0e75883a0ea8ddb366a68a.tar.gz bcm5719-llvm-03c5fa18f17133f1dd0e75883a0ea8ddb366a68a.zip |
Don't drop alignment on globals when cloning.
llvm-svn: 57320
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneModule.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/CloneModule.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneModule.cpp b/llvm/lib/Transforms/Utils/CloneModule.cpp index c94c531b016..337fa8a44bb 100644 --- a/llvm/lib/Transforms/Utils/CloneModule.cpp +++ b/llvm/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 |