Author: Reid Kleckner Date: 2020-09-24T16:29:48-07:00 New Revision: ecfc9b971269a86b101cddf1fd9f0976be4096d0
URL: https://github.com/llvm/llvm-project/commit/ecfc9b971269a86b101cddf1fd9f0976be4096d0 DIFF: https://github.com/llvm/llvm-project/commit/ecfc9b971269a86b101cddf1fd9f0976be4096d0.diff LOG: [MS] For unknown ISAs, pass non-trivially copyable arguments indirectly Passing them directly is likely to be non-conforming, since it usually involves copying the bytes of the record. For unknown architectures, we don't know what MSVC does or will do, but we should at least try to conform as well as we can. Added: clang/test/CodeGenCXX/microsoft-abi-unknown-arch.cpp Modified: clang/lib/CodeGen/MicrosoftCXXABI.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index 5fcb892f7fb8..cae79099dd6b 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -825,7 +825,7 @@ MicrosoftCXXABI::getRecordArgABI(const CXXRecordDecl *RD) const { switch (CGM.getTarget().getTriple().getArch()) { default: // FIXME: Implement for other architectures. - return RAA_Default; + return RAA_Indirect; case llvm::Triple::thumb: // Pass things indirectly for now because it is simple. diff --git a/clang/test/CodeGenCXX/microsoft-abi-unknown-arch.cpp b/clang/test/CodeGenCXX/microsoft-abi-unknown-arch.cpp new file mode 100644 index 000000000000..bb0364186eb4 --- /dev/null +++ b/clang/test/CodeGenCXX/microsoft-abi-unknown-arch.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=ppc64-windows-msvc | FileCheck %s + +// The purpose of this test is to see that we do something reasonable for +// architectures where we haven't checked what MSVC does. + +struct A { + A() : a(42) {} + A(const A &o) : a(o.a) {} + ~A() {} + int a; +}; + +struct B { + A foo(A o); +}; + +A B::foo(A x) { + return x; +} + +// CHECK-LABEL: define void @"?foo@B@@QEAA?AUA@@U2@@Z"(%struct.B* %this, %struct.A* noalias sret align 4 %agg.result, %struct.A* %x) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits