[llvm] r176632 - Fixed a crash when cloning a function into a function with

Pekka Jaaskelainen pekka.jaaskelainen at tut.fi
Thu Mar 7 08:46:43 PST 2013


Author: pjaaskel
Date: Thu Mar  7 10:46:43 2013
New Revision: 176632

URL: http://llvm.org/viewvc/llvm-project?rev=176632&view=rev
Log:
Fixed a crash when cloning a function into a function with
different size argument list and without attributes in the
arguments.

Modified:
    llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp

Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=176632&r1=176631&r2=176632&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Thu Mar  7 10:46:43 2013
@@ -94,9 +94,12 @@ void llvm::CloneFunctionInto(Function *N
     //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,





More information about the llvm-commits mailing list