[PATCH] D91278: [Clang][CodeGen][RISCV] Fix hard float ABI for struct with empty struct and complex

Luís Marques via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 7 12:27:15 PST 2020


luismarques updated this revision to Diff 309991.
luismarques added a comment.

Add float Complex case, for regression test completeness.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91278/new/

https://reviews.llvm.org/D91278

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/riscv32-ilp32d-abi.cpp


Index: clang/test/CodeGen/riscv32-ilp32d-abi.cpp
===================================================================
--- clang/test/CodeGen/riscv32-ilp32d-abi.cpp
+++ clang/test/CodeGen/riscv32-ilp32d-abi.cpp
@@ -32,3 +32,19 @@
 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;
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===================================================================
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -10469,7 +10469,6 @@
       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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91278.309991.patch
Type: text/x-patch
Size: 1304 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201207/a5aa360a/attachment-0001.bin>


More information about the cfe-commits mailing list