aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/CloneModule.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-05-26 19:58:59 +0000
committerDuncan Sands <baldrick@free.fr>2008-05-26 19:58:59 +0000
commitdd7daee8506356432a613b5266d54994305e9951 (patch)
treeb724ee240b36fe3b2e1a9d65ad2514c3a6feeb0d /llvm/lib/Transforms/Utils/CloneModule.cpp
parentdf649f3da55f6efebfec2114c6392961d506f9f8 (diff)
downloadllvm-dd7daee8506356432a613b5266d54994305e9951.zip
llvm-dd7daee8506356432a613b5266d54994305e9951.tar.gz
llvm-dd7daee8506356432a613b5266d54994305e9951.tar.bz2
Factor code to copy global value attributes like
the section or the visibility from one global value to another: copyAttributesFrom. This is particularly useful for duplicating functions: previously this was done by explicitly copying each attribute in turn at each place where a new function was created out of an old one, with the result that obscure attributes were regularly forgotten (like the collector or the section). Hopefully now everything is uniform and nothing is forgotten. llvm-svn: 51567
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneModule.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/CloneModule.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneModule.cpp b/llvm/lib/Transforms/Utils/CloneModule.cpp
index e75f915..c94c531 100644
--- a/llvm/lib/Transforms/Utils/CloneModule.cpp
+++ b/llvm/lib/Transforms/Utils/CloneModule.cpp
@@ -65,10 +65,7 @@ Module *llvm::CloneModule(const Module *M,
Function *NF =
Function::Create(cast<FunctionType>(I->getType()->getElementType()),
GlobalValue::ExternalLinkage, I->getName(), New);
- NF->setCallingConv(I->getCallingConv());
- NF->setParamAttrs(I->getParamAttrs());
- if (I->hasCollector())
- NF->setCollector(I->getCollector());
+ NF->copyAttributesFrom(I);
ValueMap[I]= NF;
}