0.15.1 used stdcall convention everywhere. But the ABI change in 0.15.2
requires use of the C calling convention for variadic calls on x86
because the stdcall convention does not support vararg functions.
Solution is to check the llvm::FunctionType if the function has varargs.
This commit also makes the C calling convention the global default
because according to the LLVM documentation the fastcc convention used
for D linkage does not support varargs.
This fixes issue #1000.
See http://llvm.org/bugs/show_bug.cgi?id=21087:
Static arrays were passed as e.g. [2 x i16]. The LLVM lowering uses a register for each entry,
extending it to 64bit. This is not the expected behaviour.
To work around this problem the PPC ABI now uses the byval-workaround from the Win64 ABI:
The struct/array is copied to some private memory and a pointer to this memory is passed to the function.
Structs/arrays of size 1/2/4/8 are cast to an integer and passed as integer.
This fixes all codegen crashes on Linux/PPC64le.
1. Main include corresponding to .cpp file, if any.
2. DMD and LDC includes.
3. LLVM includes.
4. System includes.
Also updated a few include guards to match the default format.
The generic ABI works well with PPC64 except for LLVM PR 14779.
(http://llvm.org/bugs/show_bug.cgi?id=14779)
The new ABI infrastucture is based on the UnknownTargetABI. The
PPC64 specific parts coming soon.