diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -3395,6 +3395,10 @@ if (CallerPAL.hasParamAttr(i, Attribute::SwiftError)) return false; + if (!CallerPAL.hasParamAttr(i, Attribute::ByVal) && + Callee->getAttributes().hasParamAttr(i, Attribute::ByVal)) + return false; // Cannot transform to byval. + // If the parameter is passed as a byval argument, then we have to have a // sized type and the sized type has to have the same size as the old type. if (ParamTy != ActTy && CallerPAL.hasParamAttr(i, Attribute::ByVal)) {