summaryrefslogtreecommitdiffstats
path: root/llvm/lib
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
commit093cf41e86a9b7700ee9c1b82d127d638c7ed9b2 (patch)
treed13756c3e539ab9702eff87b7c2d0054f4bdaf71 /llvm/lib
parent4f05d7143f5cf831e39e5ed16d33a19dc6da9dcd (diff)
downloadbcm5719-llvm-093cf41e86a9b7700ee9c1b82d127d638c7ed9b2.tar.gz
bcm5719-llvm-093cf41e86a9b7700ee9c1b82d127d638c7ed9b2.zip
Fixed a crash when cloning a function into a function with
different size argument list and without attributes in the arguments. llvm-svn: 176632
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Utils/CloneFunction.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index a309bce5448..63d7a1d52aa 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/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,
OpenPOWER on IntegriCloud