diff options
author | Duncan Sands <baldrick@free.fr> | 2008-05-26 19:58:59 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2008-05-26 19:58:59 +0000 |
commit | 0cc9058a792d86876b5ea532eb8be6842b407123 (patch) | |
tree | 7228a30f4d1d804257ae14016a3b4c254de30c06 /lib/Transforms/Utils | |
parent | 7c322f4eade0de60dccae49c21023aceff24d86b (diff) | |
download | external_llvm-0cc9058a792d86876b5ea532eb8be6842b407123.zip external_llvm-0cc9058a792d86876b5ea532eb8be6842b407123.tar.gz external_llvm-0cc9058a792d86876b5ea532eb8be6842b407123.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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51567 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r-- | lib/Transforms/Utils/CloneFunction.cpp | 11 | ||||
-rw-r--r-- | lib/Transforms/Utils/CloneModule.cpp | 5 |
2 files changed, 5 insertions, 11 deletions
diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp index 5736914..9e3fe32 100644 --- a/lib/Transforms/Utils/CloneFunction.cpp +++ b/lib/Transforms/Utils/CloneFunction.cpp @@ -80,11 +80,8 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc, assert(ValueMap.count(I) && "No mapping from source argument specified!"); #endif - // Clone the parameter attributes - NewFunc->setParamAttrs(OldFunc->getParamAttrs()); - - // Clone the calling convention - NewFunc->setCallingConv(OldFunc->getCallingConv()); + // Clone any attributes. + NewFunc->copyAttributesFrom(OldFunc); // Loop over all of the basic blocks in the function, cloning them as // appropriate. Note that we save BE this way in order to handle cloning of @@ -339,8 +336,8 @@ void llvm::CloneAndPruneFunctionInto(Function *NewFunc, const Function *OldFunc, E = OldFunc->arg_end(); II != E; ++II) assert(ValueMap.count(II) && "No mapping from source argument specified!"); #endif - - PruningFunctionCloner PFC(NewFunc, OldFunc, ValueMap, Returns, + + PruningFunctionCloner PFC(NewFunc, OldFunc, ValueMap, Returns, NameSuffix, CodeInfo, TD); // Clone the entry block, and anything recursively reachable from it. diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp index e75f915..c94c531 100644 --- a/lib/Transforms/Utils/CloneModule.cpp +++ b/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; } |