mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-17 21:35:07 +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,10 +1015,23 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
|||||||
if (!CastInst::isCastable(ActTy, ParamTy))
|
if (!CastInst::isCastable(ActTy, ParamTy))
|
||||||
return false; // Cannot transform this parameter value.
|
return false; // Cannot transform this parameter value.
|
||||||
|
|
||||||
if (CallerPAL.getParamAttributes(i + 1)
|
unsigned Attrs = CallerPAL.getParamAttributes(i + 1);
|
||||||
& Attribute::typeIncompatible(ParamTy))
|
if (Attrs & Attribute::typeIncompatible(ParamTy))
|
||||||
return false; // Attribute not compatible with transformed value.
|
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
|
// 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.
|
// integer of the same size is safe even if we do not have a body.
|
||||||
bool isConvertible = ActTy == ParamTy ||
|
bool isConvertible = ActTy == ParamTy ||
|
||||||
|
@ -285,3 +285,16 @@ entry:
|
|||||||
store i32 %19, i32* undef, align 8
|
store i32 %19, i32* undef, align 8
|
||||||
unreachable
|
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…
x
Reference in New Issue
Block a user