diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-12-20 08:36:38 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-12-20 08:36:38 +0000 |
| commit | 27ca8ebd4bde39a7c0d9c2b6cf549b4d1cc910cd (patch) | |
| tree | 89e889d5d2ea43ac09ef645a9917703e0a11be9f /llvm/lib/Transforms | |
| parent | 7398965b679e3019d9b4b9d61cb5bb2df2d857ef (diff) | |
| download | bcm5719-llvm-27ca8ebd4bde39a7c0d9c2b6cf549b4d1cc910cd.tar.gz bcm5719-llvm-27ca8ebd4bde39a7c0d9c2b6cf549b4d1cc910cd.zip | |
fix PR8807 by making transformConstExprCastCall aware of byval arguments.
llvm-svn: 122238
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 57510ddca13..f872a9b5aef 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -1015,9 +1015,22 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { if (!CastInst::isCastable(ActTy, ParamTy)) return false; // Cannot transform this parameter value. - if (CallerPAL.getParamAttributes(i + 1) - & Attribute::typeIncompatible(ParamTy)) + unsigned Attrs = CallerPAL.getParamAttributes(i + 1); + if (Attrs & Attribute::typeIncompatible(ParamTy)) return false; // Attribute not compatible with transformed value. + + // 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 && (Attrs & Attribute::ByVal)) { + const PointerType *ParamPTy = dyn_cast<PointerType>(ParamTy); + if (ParamPTy == 0 || !ParamPTy->getElementType()->isSized() || TD == 0) + return false; + + const Type *CurElTy = cast<PointerType>(ActTy)->getElementType(); + if (TD->getTypeAllocSize(CurElTy) != + TD->getTypeAllocSize(ParamPTy->getElementType())) + return false; + } // Converting from one pointer type to another or between a pointer and an // integer of the same size is safe even if we do not have a body. |

