Skip to content

Commit b430f94

Browse files
luismarqueststellar
authored andcommitted
[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 3af354e)
1 parent a4eaecf commit b430f94

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

clang/lib/CodeGen/TargetInfo.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10395,7 +10395,6 @@ bool RISCVABIInfo::detectFPCCEligibleStructHelper(QualType Ty, CharUnits CurOff,
1039510395
return false;
1039610396
Field1Ty = CGT.ConvertType(EltTy);
1039710397
Field1Off = CurOff;
10398-
assert(CurOff.isZero() && "Unexpected offset for first field");
1039910398
Field2Ty = Field1Ty;
1040010399
Field2Off = Field1Off + getContext().getTypeSizeInChars(EltTy);
1040110400
return true;

clang/test/CodeGen/riscv32-ilp32d-abi.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,19 @@ struct empty_double_float { struct {}; double f; float g; };
3232
double f_empty_double_float(empty_double_float a) {
3333
return a.g;
3434
}
35+
36+
struct empty_complex_f { struct {}; float _Complex fc; };
37+
38+
// CHECK: define float @_Z17f_empty_complex_f15empty_complex_f(float %0, float %1)
39+
// CHECK: { [4 x i8], float, float }
40+
float f_empty_complex_f(empty_complex_f a) {
41+
return __imag__ a.fc;
42+
}
43+
44+
struct empty_complex_d { struct {}; double _Complex fc; };
45+
46+
// CHECK: define double @_Z17f_empty_complex_d15empty_complex_d(double %0, double %1)
47+
// CHECK: { [8 x i8], double, double }
48+
double f_empty_complex_d(empty_complex_d a) {
49+
return __imag__ a.fc;
50+
}

0 commit comments

Comments
 (0)