llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Daniil (kin4stat) <details> <summary>Changes</summary> MSVC normally has a bunch of restrictions on returning values directly which don't apply to passing values directly. (This roughly corresponds to the definition of a C++14 aggregate.) However, these restrictions don't apply to HVAs and HFAs; make sure we check for that. Fixes llvm/llvm-project#<!-- -->63417 --- Full diff: https://github.com/llvm/llvm-project/pull/113104.diff 2 Files Affected: - (modified) clang/lib/CodeGen/MicrosoftCXXABI.cpp (+4) - (modified) clang/test/CodeGenCXX/homogeneous-aggregates.cpp (+19) ``````````diff diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 0b0b45ffead92f..fa5d83243f60fe 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -1110,6 +1110,10 @@ static bool isTrivialForMSVC(const CXXRecordDecl *RD, QualType Ty, isa<VectorType>(Base)) { return true; } + if (CGM.getTarget().getTriple().isX86() && + CGM.getABIInfo().isHomogeneousAggregate(Ty, Base, NumElts)) { + return true; + } // We use the C++14 definition of an aggregate, so we also // check for: diff --git a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp b/clang/test/CodeGenCXX/homogeneous-aggregates.cpp index 63ffc6b5bfac84..cf8019d2f18964 100644 --- a/clang/test/CodeGenCXX/homogeneous-aggregates.cpp +++ b/clang/test/CodeGenCXX/homogeneous-aggregates.cpp @@ -302,3 +302,22 @@ struct test2 : base2 { test2(double); protected: double v2;}; test2 f(test2 *x) { return *x; } // WOA64: define dso_local void @"?f@pr62223@@YA?AUtest2@1@PEAU21@@Z"(ptr dead_on_unwind inreg noalias writable sret(%"struct.pr62223::test2") align 8 %{{.*}}, ptr noundef %{{.*}}) } + +namespace pr113104 { +struct HFA { + float a; + float b; +}; + +using HVA = float __attribute__((__vector_size__(16), __aligned__(16))); + +struct base_hfa { HFA v1; }; +struct test_hfa : base_hfa { test_hfa(double); protected: HFA v2;}; +test_hfa CC f(test_hfa *x) { return *x; } +// X64: define dso_local x86_vectorcallcc %"struct.pr113104::test_hfa" @"\01_ZN8pr1131041fEPNS_8test_hfaE@@8"(ptr noundef %x) + +struct base_hva { HVA v1; }; +struct test_hva : base_hva { test_hva(double); protected: HVA v2;}; +test_hva CC f(test_hva *x) { return *x; } +// X64: define dso_local x86_vectorcallcc %"struct.pr113104::test_hva" @"\01_ZN8pr1131041fEPNS_8test_hvaE@@8"(ptr noundef %x) +} \ No newline at end of file `````````` </details> https://github.com/llvm/llvm-project/pull/113104 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits