AArch64/GlobalISel: Fix assert on call returning 0 sized type

I don't know why this is considered valid IR, but it probably should
not be.
This commit is contained in:
Matt Arsenault 2020-05-31 16:18:52 -04:00 committed by Matt Arsenault
parent a1a93ca48a
commit 9cdc27ffac
3 changed files with 47 additions and 4 deletions

View File

@ -61,7 +61,8 @@ public:
if (!Regs.empty() && Flags.empty())
this->Flags.push_back(ISD::ArgFlagsTy());
// FIXME: We should have just one way of saying "no register".
assert((Ty->isVoidTy() == (Regs.empty() || Regs[0] == 0)) &&
assert(((Ty->isVoidTy() || Ty->isEmptyTy()) ==
(Regs.empty() || Regs[0] == 0)) &&
"only void types should have no register");
}

View File

@ -237,13 +237,13 @@ void AArch64CallLowering::splitToValueTypes(
const AArch64TargetLowering &TLI = *getTLI<AArch64TargetLowering>();
LLVMContext &Ctx = OrigArg.Ty->getContext();
if (OrigArg.Ty->isVoidTy())
return;
SmallVector<EVT, 4> SplitVTs;
SmallVector<uint64_t, 4> Offsets;
ComputeValueVTs(TLI, DL, OrigArg.Ty, SplitVTs, &Offsets, 0);
if (SplitVTs.size() == 0)
return;
if (SplitVTs.size() == 1) {
// No splitting to do, but we want to replace the original type (e.g. [1 x
// double] -> double).

View File

@ -279,3 +279,45 @@ define void @take_split_struct([2 x i64]* %ptr, i64, i64, i64,
store [2 x i64] %in, [2 x i64]* %ptr
ret void
}
%size0type = type { }
declare %size0type @func.returns.size0.struct()
; CHECK-LABEL: name: call_returns_size0_struct
; CHECK: bb.1
; CHECK-NEXT: ADJCALLSTACKDOWN
; CHECK-NEXT: BL
; CHECK-NEXT: ADJCALLSTACKUP
; CHECK-NEXT: RET_ReallyLR
define void @call_returns_size0_struct() {
; FIXME: Why is this valid IR?
%call = call %size0type @func.returns.size0.struct()
ret void
}
declare [0 x i8] @func.returns.size0.array()
; CHECK-LABEL: name: call_returns_size0_array
; CHECK: bb.1
; CHECK-NEXT: ADJCALLSTACKDOWN
; CHECK-NEXT: BL
; CHECK-NEXT: ADJCALLSTACKUP
; CHECK-NEXT: RET_ReallyLR
define void @call_returns_size0_array() {
; FIXME: Why is this valid IR?
%call = call [0 x i8] @func.returns.size0.array()
ret void
}
declare [1 x %size0type] @func.returns.array.size0.struct()
; CHECK-LABEL: name: call_returns_array_size0_struct
; CHECK: bb.1
; CHECK-NEXT: ADJCALLSTACKDOWN
; CHECK-NEXT: BL
; CHECK-NEXT: ADJCALLSTACKUP
; CHECK-NEXT: RET_ReallyLR
define void @call_returns_array_size0_struct() {
; FIXME: Why is this valid IR?
%call = call [1 x %size0type] @func.returns.array.size0.struct()
ret void
}