diff options
author | Luís Marques <luismarques@lowrisc.org> | 2020-12-07 23:50:43 +0000 |
---|---|---|
committer | Tom Stellard <tstellar@redhat.com> | 2020-12-09 11:02:27 -0500 |
commit | b430f94d005276c8588b86dde7759be37a7a3420 (patch) | |
tree | 2579d1aef5852c4c1eca09e08603b76fa39d1073 | |
parent | a4eaecf122e1abbc5bc0f2478e80c6bb7da67cb0 (diff) | |
download | llvm-b430f94d005276c8588b86dde7759be37a7a3420.zip llvm-b430f94d005276c8588b86dde7759be37a7a3420.tar.gz llvm-b430f94d005276c8588b86dde7759be37a7a3420.tar.bz2 |
[Clang][CodeGen][RISCV] Fix hard float ABI for struct with empty struct and complex
Fixes bug 44904.
Differential Revision: https://reviews.llvm.org/D91278
(cherry picked from commit 3af354e863f553ef727967dfc091a64a11500aa5)
-rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 1 | ||||
-rw-r--r-- | clang/test/CodeGen/riscv32-ilp32d-abi.cpp | 16 |
2 files changed, 16 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index c5db098..a061651 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -10395,7 +10395,6 @@ bool RISCVABIInfo::detectFPCCEligibleStructHelper(QualType Ty, CharUnits CurOff, return false; Field1Ty = CGT.ConvertType(EltTy); Field1Off = CurOff; - assert(CurOff.isZero() && "Unexpected offset for first field"); Field2Ty = Field1Ty; Field2Off = Field1Off + getContext().getTypeSizeInChars(EltTy); return true; diff --git a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp index 1018c78..26d968b 100644 --- a/clang/test/CodeGen/riscv32-ilp32d-abi.cpp +++ b/clang/test/CodeGen/riscv32-ilp32d-abi.cpp @@ -32,3 +32,19 @@ struct empty_double_float { struct {}; double f; float g; }; double f_empty_double_float(empty_double_float a) { return a.g; } + +struct empty_complex_f { struct {}; float _Complex fc; }; + +// CHECK: define float @_Z17f_empty_complex_f15empty_complex_f(float %0, float %1) +// CHECK: { [4 x i8], float, float } +float f_empty_complex_f(empty_complex_f a) { + return __imag__ a.fc; +} + +struct empty_complex_d { struct {}; double _Complex fc; }; + +// CHECK: define double @_Z17f_empty_complex_d15empty_complex_d(double %0, double %1) +// CHECK: { [8 x i8], double, double } +double f_empty_complex_d(empty_complex_d a) { + return __imag__ a.fc; +} |