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
This commit is contained in:
Duncan Sands
2008-05-26 19:58:59 +00:00
parent 78ecf0d7b1
commit 28c3cff825
12 changed files with 59 additions and 42 deletions

View File

@ -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.