[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 23:24:46 PDT 2021
pengfei updated this revision to Diff 378102.
pengfei added a comment.
Use named struct to check CPP as well.
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,44 @@
// CHECK-CPP: define{{.*}} @_Z3fs26shalf2(double {{.*}}
return s.a;
};
+
+struct fsd {
+ float a;
+ struct {};
+ double b;
+};
+
+struct fsd pr52011() {
+ // CHECK: define{{.*}} { float, double } @
+}
+
+struct hsd {
+ _Float16 a;
+ struct {};
+ double b;
+};
+
+struct hsd pr52011_2() {
+ // CHECK: define{{.*}} { half, double } @
+}
+
+struct hsf {
+ _Float16 a;
+ struct {};
+ float b;
+};
+
+struct hsf pr52011_3() {
+ // CHECK: define{{.*}} <4 x half> @
+}
+
+struct fds {
+ float a;
+ double b;
+ struct {};
+};
+
+struct fds pr52011_4() {
+ // CHECK-C: define{{.*}} { float, double } @pr52011_4
+ // CHECK-CPP: define{{.*}} void @_Z9pr52011_4v({{.*}} sret
+}
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.378102.patch
Type: text/x-patch
Size: 1495 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211008/1798a38a/attachment.bin>
More information about the cfe-commits
mailing list