Skip to content

calling convention mismatch for non-POD with trivialv on mingw-w64 #143701

Open
@vtjnash

Description

@vtjnash

@llvm/issue-subscribers-julialang noticed we get calling convention mismatches between i686-w64-mingw32-gcc and llvm targeting that, specifically for types such as std::optional. In particular, GCC says this must always be returned in memory (perhaps due to cxx03 rules) while LLVM says this can be returned in registers (Itanium rules). This seems easy to fix with some flag in the rules, but I cannot find anywhere that says why this particular case is sret, to indicate which flag to set. In general, mingw-w64 claims to be MSVC-compatible with this ABI, implying LLVM should be selecting the MicrosoftCXXABI by default here, but I cannot find any way to corroborate that being the right change to the ABI.

$ ~/julia/deps/srccache/llvm/build/bin/clang -S -x c++ - -o - --target=i686-w64-mingw32  -std=c++17  -O2 << EOF
#include <optional>                
std::optional<void*> foo() { return (void*)0; }
EOF

	.def	@feat.00;
	.scl	3;
	.type	0;
	.endef
	.globl	@feat.00
.set @feat.00, 1
	.file	"-"
	.def	__Z3foov;
	.scl	2;
	.type	32;
	.endef
	.text
	.globl	__Z3foov                        # -- Begin function _Z3foov
	.p2align	4
__Z3foov:                               # @_Z3foov
# %bb.0:                                # %entry
	xorl	%eax, %eax
	movl	$1, %edx
	retl
                                        # -- End function
	.addrsig

$ x86_64-w64-mingw32-g++ -S -x c++ - -o - -std=c++17  -O2 << EOF
#include <optional>                
std::optional<void*> foo() { return (void*)0; }
EOF

	.file	""
	.text
	.p2align 4
	.globl	_Z3foov
	.def	_Z3foov;	.scl	2;	.type	32;	.endef
	.seh_proc	_Z3foov
_Z3foov:
.LFB289:
	.seh_endprologue
	movq	%rcx, %rax
	movq	$0, (%rcx)
	movq	$1, 8(%rcx)
	ret
	.seh_endproc
	.ident	"GCC: (GNU) 10-posix 20220113"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions