[llvm] 9cdc27f - AArch64/GlobalISel: Fix assert on call returning 0 sized type
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 3 16:56:20 PDT 2020
Author: Matt Arsenault
Date: 2020-06-03T19:56:07-04:00
New Revision: 9cdc27ffac48acfc458d4d6ae9db1f90757645a1
URL: https://github.com/llvm/llvm-project/commit/9cdc27ffac48acfc458d4d6ae9db1f90757645a1
DIFF: https://github.com/llvm/llvm-project/commit/9cdc27ffac48acfc458d4d6ae9db1f90757645a1.diff
LOG: 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.
Added:
Modified:
llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
llvm/lib/Target/AArch64/AArch64CallLowering.cpp
llvm/test/CodeGen/AArch64/GlobalISel/call-translator.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h b/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
index 439837760663..88a1837665aa 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
@@ -61,7 +61,8 @@ class CallLowering {
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");
}
diff --git a/llvm/lib/Target/AArch64/AArch64CallLowering.cpp b/llvm/lib/Target/AArch64/AArch64CallLowering.cpp
index f6daa5f7f9e2..9f37efc0951b 100644
--- a/llvm/lib/Target/AArch64/AArch64CallLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64CallLowering.cpp
@@ -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).
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/call-translator.ll b/llvm/test/CodeGen/AArch64/GlobalISel/call-translator.ll
index e60360fdee68..ad38b2bb8b9c 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/call-translator.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/call-translator.ll
@@ -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
+}
More information about the llvm-commits
mailing list