pengfei updated this revision to Diff 378082.
pengfei marked an inline comment as done.
pengfei added a comment.
Add more tests. NFC.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111037/new/
https://reviews.llvm.org/D111037
Files:
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/X86/avx512fp16-abi.c
Index: clang/test/CodeGen/X86/avx512fp16-abi.c
===================================================================
--- clang/test/CodeGen/X86/avx512fp16-abi.c
+++ clang/test/CodeGen/X86/avx512fp16-abi.c
@@ -197,3 +197,37 @@
// CHECK-CPP: define{{.*}} @_Z3fs26shalf2(double {{.*}}
return s.a;
};
+
+#ifndef __cplusplus
+struct {
+ float a;
+ struct {};
+ double b;
+} pr52011() {
+ // CHECK-C: define{{.*}} { float, double } @pr52011
+}
+
+struct {
+ _Float16 a;
+ struct {};
+ double b;
+} pr52011_2() {
+ // CHECK-C: define{{.*}} { half, double } @pr52011_2
+}
+
+struct {
+ _Float16 a;
+ struct {};
+ float b;
+} pr52011_3() {
+ // CHECK-C: define{{.*}} <4 x half> @pr52011_3
+}
+
+struct {
+ float a;
+ double b;
+ struct {};
+} pr52011_4() {
+ // CHECK-C: define{{.*}} { float, double } @pr52011_4
+}
+#endif
Index: clang/lib/CodeGen/TargetInfo.cpp
===================================================================
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -3415,6 +3415,9 @@
// If this is a struct, recurse into the field at the specified offset.
if (llvm::StructType *STy = dyn_cast<llvm::StructType>(IRType)) {
+ if (!STy->getNumContainedTypes())
+ return nullptr;
+
const llvm::StructLayout *SL = TD.getStructLayout(STy);
unsigned Elt = SL->getElementContainingOffset(IROffset);
IROffset -= SL->getElementOffset(Elt);
Index: clang/test/CodeGen/X86/avx512fp16-abi.c
===================================================================
--- clang/test/CodeGen/X86/avx512fp16-abi.c
+++ clang/test/CodeGen/X86/avx512fp16-abi.c
@@ -197,3 +197,37 @@
// CHECK-CPP: define{{.*}} @_Z3fs26shalf2(double {{.*}}
return s.a;
};
+
+#ifndef __cplusplus
+struct {
+ float a;
+ struct {};
+ double b;
+} pr52011() {
+ // CHECK-C: define{{.*}} { float, double } @pr52011
+}
+
+struct {
+ _Float16 a;
+ struct {};
+ double b;
+} pr52011_2() {
+ // CHECK-C: define{{.*}} { half, double } @pr52011_2
+}
+
+struct {
+ _Float16 a;
+ struct {};
+ float b;
+} pr52011_3() {
+ // CHECK-C: define{{.*}} <4 x half> @pr52011_3
+}
+
+struct {
+ float a;
+ double b;
+ struct {};
+} pr52011_4() {
+ // CHECK-C: define{{.*}} { float, double } @pr52011_4
+}
+#endif
Index: clang/lib/CodeGen/TargetInfo.cpp
===================================================================
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -3415,6 +3415,9 @@
// If this is a struct, recurse into the field at the specified offset.
if (llvm::StructType *STy = dyn_cast<llvm::StructType>(IRType)) {
+ if (!STy->getNumContainedTypes())
+ return nullptr;
+
const llvm::StructLayout *SL = TD.getStructLayout(STy);
unsigned Elt = SL->getElementContainingOffset(IROffset);
IROffset -= SL->getElementOffset(Elt);
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits