summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorJoey Gouly <joey.gouly@arm.com>2013-04-10 10:37:38 +0000
committerJoey Gouly <joey.gouly@arm.com>2013-04-10 10:37:38 +0000
commit81259294be6fd9c0c875886f6f56d847290c80aa (patch)
tree85b8e3705de7167a43103091b09008c9df267676 /llvm/lib/Transforms
parenta3ff45ebedd83a3e8eab4803a0da838915182f18 (diff)
downloadbcm5719-llvm-81259294be6fd9c0c875886f6f56d847290c80aa.tar.gz
bcm5719-llvm-81259294be6fd9c0c875886f6f56d847290c80aa.zip
Change CloneFunctionInto to always clone Argument attributes induvidually,
rather than checking if the source and destination have the same number of arguments and copying the attributes over directly. llvm-svn: 179169
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Utils/CloneFunction.cpp41
1 files changed, 19 insertions, 22 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index 63d7a1d52aa..be8d39e128a 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -87,29 +87,26 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
assert(VMap.count(I) && "No mapping from source argument specified!");
#endif
- // Clone any attributes.
- if (NewFunc->arg_size() == OldFunc->arg_size())
- NewFunc->copyAttributesFrom(OldFunc);
- else {
- //Some arguments were deleted with the VMap. Copy arguments one by one
- for (Function::const_arg_iterator I = OldFunc->arg_begin(),
- E = OldFunc->arg_end(); I != E; ++I)
- if (Argument* Anew = dyn_cast<Argument>(VMap[I])) {
- AttributeSet attrs = OldFunc->getAttributes()
- .getParamAttributes(I->getArgNo() + 1);
- if (attrs.getNumSlots() > 0)
- Anew->addAttr(attrs);
- }
- NewFunc->setAttributes(NewFunc->getAttributes()
- .addAttributes(NewFunc->getContext(),
- AttributeSet::ReturnIndex,
- OldFunc->getAttributes()));
- NewFunc->setAttributes(NewFunc->getAttributes()
- .addAttributes(NewFunc->getContext(),
- AttributeSet::FunctionIndex,
- OldFunc->getAttributes()));
+ AttributeSet OldAttrs = OldFunc->getAttributes();
+ // Clone any argument attributes that are present in the VMap.
+ for (Function::const_arg_iterator I = OldFunc->arg_begin(),
+ E = OldFunc->arg_end();
+ I != E; ++I)
+ if (Argument *Anew = dyn_cast<Argument>(VMap[I])) {
+ AttributeSet attrs =
+ OldAttrs.getParamAttributes(I->getArgNo() + 1);
+ if (attrs.getNumSlots() > 0)
+ Anew->addAttr(attrs);
+ }
- }
+ NewFunc->setAttributes(NewFunc->getAttributes()
+ .addAttributes(NewFunc->getContext(),
+ AttributeSet::ReturnIndex,
+ OldAttrs.getRetAttributes()));
+ NewFunc->setAttributes(NewFunc->getAttributes()
+ .addAttributes(NewFunc->getContext(),
+ AttributeSet::FunctionIndex,
+ OldAttrs.getFnAttributes()));
// 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
OpenPOWER on IntegriCloud