aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuís Marques <luismarques@lowrisc.org>2020-12-07 23:50:42 +0000
committerTom Stellard <tstellar@redhat.com>2020-12-09 11:02:27 -0500
commita4eaecf122e1abbc5bc0f2478e80c6bb7da67cb0 (patch)
tree70ea5cce89e538a6577082aa143725662611b5c3
parentba223fa19d35d41ad9eeade8978ab1a17d6aafe1 (diff)
downloadllvm-a4eaecf122e1abbc5bc0f2478e80c6bb7da67cb0.zip
llvm-a4eaecf122e1abbc5bc0f2478e80c6bb7da67cb0.tar.gz
llvm-a4eaecf122e1abbc5bc0f2478e80c6bb7da67cb0.tar.bz2
[Clang][CodeGen][RISCV] Fix hard float ABI test cases with empty struct
The code seemed not to account for the field 1 offset. Differential Revision: https://reviews.llvm.org/D91270 (cherry picked from commit fa8f5bfa4e8cff042c9730320c74e97fab152ae1)
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp10
-rw-r--r--clang/test/CodeGen/riscv32-ilp32d-abi.cpp9
2 files changed, 8 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index f10f8e5..c5db098 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -10490,7 +10490,7 @@ bool RISCVABIInfo::detectFPCCEligibleStruct(QualType Ty, llvm::Type *&Field1Ty,
NeededArgFPRs++;
else if (Field2Ty)
NeededArgGPRs++;
- return IsCandidate;
+ return true;
}
// Call getCoerceAndExpand for the two-element flattened struct described by
@@ -10516,15 +10516,15 @@ ABIArgInfo RISCVABIInfo::coerceAndExpandFPCCEligibleStruct(
CharUnits Field2Align =
CharUnits::fromQuantity(getDataLayout().getABITypeAlignment(Field2Ty));
- CharUnits Field1Size =
+ CharUnits Field1End = Field1Off +
CharUnits::fromQuantity(getDataLayout().getTypeStoreSize(Field1Ty));
- CharUnits Field2OffNoPadNoPack = Field1Size.alignTo(Field2Align);
+ CharUnits Field2OffNoPadNoPack = Field1End.alignTo(Field2Align);
CharUnits Padding = CharUnits::Zero();
if (Field2Off > Field2OffNoPadNoPack)
Padding = Field2Off - Field2OffNoPadNoPack;
- else if (Field2Off != Field2Align && Field2Off > Field1Size)
- Padding = Field2Off - Field1Size;
+ else if (Field2Off != Field2Align && Field2Off > Field1End)
+ Padding = Field2Off - Field1End;
bool IsPacked = !Field2Off.isMultipleOf(Field2Align);
diff --git a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
index ffebb05..1018c78 100644
--- a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
+++ b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp
@@ -4,8 +4,7 @@
struct empty_float2 { struct {}; float f; float g; };
// CHECK: define float @_Z14f_empty_float212empty_float2(float %0, float %1)
-// FIXME: Extraneous padding before the second float
-// CHECK: { [4 x i8], float, [4 x i8], float }
+// CHECK: { [4 x i8], float, float }
float f_empty_float2(empty_float2 a) {
return a.g;
}
@@ -13,8 +12,7 @@ float f_empty_float2(empty_float2 a) {
struct empty_double2 { struct {}; double f; double g; };
// CHECK: define double @_Z15f_empty_double213empty_double2(double %0, double %1)
-// FIXME: Extraneous padding before the second double
-// CHECK: { [8 x i8], double, [8 x i8], double }
+// CHECK: { [8 x i8], double, double }
double f_empty_double2(empty_double2 a) {
return a.g;
}
@@ -30,8 +28,7 @@ double f_empty_float_double(empty_float_double a) {
struct empty_double_float { struct {}; double f; float g; };
// CHECK: define double @_Z20f_empty_double_float18empty_double_float(double %0, float %1)
-// FIXME: Extraneous padding before the float
-// CHECK: { [8 x i8], double, [8 x i8], float }
+// CHECK: { [8 x i8], double, float }
double f_empty_double_float(empty_double_float a) {
return a.g;
}