mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:50:30 +00:00
fix PR8807 by making transformConstExprCastCall aware of byval arguments.
llvm-svn: 122238
This commit is contained in:
parent
a3fea736c1
commit
b27b5d0a3a
@ -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