aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils/CloneFunction.cpp
diff options
context:
space:
mode:
authorPekka Jaaskelainen <pekka.jaaskelainen@tut.fi>2013-03-07 16:46:43 +0000
committerPekka Jaaskelainen <pekka.jaaskelainen@tut.fi>2013-03-07 16:46:43 +0000
commit784ae47413e1adf3b64ed5546f88b39ab52a9281 (patch)
tree295a5445b258e0c7e1b3767366dca308a0c34a89 /lib/Transforms/Utils/CloneFunction.cpp
parentcc22640c4c8f0bc5d1e37b4ddcdf9e7c873e4383 (diff)
downloadexternal_llvm-784ae47413e1adf3b64ed5546f88b39ab52a9281.zip
external_llvm-784ae47413e1adf3b64ed5546f88b39ab52a9281.tar.gz
external_llvm-784ae47413e1adf3b64ed5546f88b39ab52a9281.tar.bz2
Fixed a crash when cloning a function into a function with
different size argument list and without attributes in the arguments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176632 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/CloneFunction.cpp')
-rw-r--r--lib/Transforms/Utils/CloneFunction.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp
index a309bce..63d7a1d 100644
--- a/lib/Transforms/Utils/CloneFunction.cpp
+++ b/lib/Transforms/Utils/CloneFunction.cpp
@@ -94,9 +94,12 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
//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]))
- Anew->addAttr(OldFunc->getAttributes()
- .getParamAttributes(I->getArgNo() + 1));
+ 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,