x86_stdcallcc and extra name mangling on Windows

Hi all,

I'm currently working on getting our (LDC) compiler to run on
Win32/MinGW, now that DW2-style EH is available for it. The D
programming language has a feature equivalent to LLVM module level
inline assembly, so we need to at least partly follow the x86 D
calling convention (Application Binary Interface - D Programming Language).

Most notably, the ABI mandates that the callee cleans the stack. On
the various Posixen, we use x86_stdcallcc as a basis and apply some
rewrites at the IR level to make things work just well enough.
However, on Windows targets this does not work because of the extra
name mangling applied.

My question: Is there an easy way of disabling the name-mangling part
but keep the rest of the CC that I missed? Because I couldn't find
anything to that regard, I threw together a quick patch to add a
custom calling convention (see attachment). It seems to work for now,
but is there a better solution?

Thanks,
David

llvm-3.2-x86-d.diff (5.86 KB)

Hi David,

I'm currently working on getting our (LDC) compiler to run on
Win32/MinGW, now that DW2-style EH is available for it. The D
programming language has a feature equivalent to LLVM module level
inline assembly, so we need to at least partly follow the x86 D
calling convention (http://dlang.org/abi.html).

Most notably, the ABI mandates that the callee cleans the stack. On
the various Posixen, we use x86_stdcallcc as a basis and apply some
rewrites at the IR level to make things work just well enough.
However, on Windows targets this does not work because of the extra
name mangling applied.

My question: Is there an easy way of disabling the name-mangling part
but keep the rest of the CC that I missed? Because I couldn't find
anything to that regard, I threw together a quick patch to add a
custom calling convention (see attachment). It seems to work for now,
but is there a better solution?

if you use "\1" + "usual name", it will disable name mangling if you are
lucky. A leading \1 is LLVM's way of saying: leave this name alone!

Ciao, Duncan.