aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoey Gouly <joey.gouly@arm.com>2013-04-17 17:45:28 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-04-17 17:45:28 -0700
commitffb69c62ac54b0af5768ae9486b93b39a6c6b94c (patch)
treebad37b9b452a91b0494c2d645cdc8382458d1590 /lib
parentfa2befcc1d9fdf4ce0c5632e94cddb0061501dfe (diff)
parent37307850d8fa6510e7385f62374a6fadb68fd1a2 (diff)
downloadexternal_llvm-ffb69c62ac54b0af5768ae9486b93b39a6c6b94c.zip
external_llvm-ffb69c62ac54b0af5768ae9486b93b39a6c6b94c.tar.gz
external_llvm-ffb69c62ac54b0af5768ae9486b93b39a6c6b94c.tar.bz2
am 37307850: am b84f869c: 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.
* commit '37307850d8fa6510e7385f62374a6fadb68fd1a2': 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.
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Utils/CloneFunction.cpp41
1 files changed, 19 insertions, 22 deletions
diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp
index 63d7a1d..be8d39e 100644
--- a/lib/Transforms/Utils/CloneFunction.cpp
+++ b/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