pengfei created this revision. pengfei added reviewers: dyung, LuoYuanke. pengfei requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
This fixes pr52011. Repository: rG LLVM Github Monorepo 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,13 @@ // CHECK-CPP: define{{.*}} @_Z3fs26shalf2(double {{.*}} return s.a; }; + +#ifndef __cplusplus +struct { + float a; + struct {}; + double b +} pr52011() { + // CHECK-C: define{{.*}} { float, double } @pr52011 +} +#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,13 @@ // CHECK-CPP: define{{.*}} @_Z3fs26shalf2(double {{.*}} return s.a; }; + +#ifndef __cplusplus +struct { + float a; + struct {}; + double b +} pr52011() { + // CHECK-C: define{{.*}} { float, double } @pr52011 +} +#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 cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits