mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-29 14:40:25 +00:00
fix PR8807 by making transformConstExprCastCall aware of byval arguments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122238 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ab215bc371
commit
2b9375e44b
@ -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.
|
||||
|
@ -285,3 +285,16 @@ entry:
|
||||
store i32 %19, i32* undef, align 8
|
||||
unreachable
|
||||
}
|
||||
|
||||
|
||||
; PR8807
|
||||
declare i32 @test14f(i8* (i8*)*) nounwind
|
||||
|
||||
define void @test14() nounwind readnone {
|
||||
entry:
|
||||
%tmp = bitcast i32 (i8* (i8*)*)* @test14f to i32 (i32*)*
|
||||
%call10 = call i32 %tmp(i32* byval undef)
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user