[PATCH] D111037: [X86] Check if struct is blank before getting the inner types
Pengfei Wang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 7 20:38:58 PDT 2021
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111037.378082.patch
Type: text/x-patch
Size: 1417 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211008/45f252d7/attachment.bin>
More information about the cfe-commits
mailing list