Commit graph

99 commits

Author SHA1 Message Date
Martin
7c544be9d1 Respect explicit type alignments for LL args passed im- and explicitly by value
And for sret args too, except for MSVC targets.

At least on Win64, the sret align attributes lead to ICEs for std.bitmanip
and std.uni (release only), when computing the known alignment in the LLVM
inliner pass:

Assertion failed: I->getParent()->getParent() ==
Q.CxtI->getParent()->getParent() && "Got assumption for the wrong function!",
file C:\LDC\llvm\lib\Analysis\ValueTracking.cpp, line 711
2015-12-04 23:25:06 +01:00
Martin
ddfaac10b3 Rename DtoAggrCopy/ZeroInit() to DtoMemCpy/SetZero() overloads
And replace some obvious load->store combos by a memcpy.
2015-12-04 22:23:09 +01:00
Martin
fa48cabedc Some more cosmetic fixes 2015-11-02 19:54:18 +01:00
Martin
fae3650f40 Fix 2 aesthetic clang-tidy glitches 2015-11-02 19:28:20 +01:00
David Nadlinger
9df487edff gen/ir: clang-tidy the world 2015-11-02 11:30:40 +02:00
David Nadlinger
44b0f7b615 driver/gen/ir: clang-format the world
This uses the LLVM style, which makes sense for sharing code
with other LLVM projects. The DMD code we use will soon all
be in D anyway.
2015-11-02 00:28:01 +02:00
David Nadlinger
0b4bcbc28c Merge pull request #1181 from kinke/attribs
Simplify working with LLVM attributes
2015-11-01 17:52:45 +02:00
Martin
90197d6c72 Simplify working with LLVM attributes 2015-11-01 16:19:27 +01:00
Martin
2d959ea540 Make use of C++11 range-based for
Should be available now that support for LLVM < 3.5 has been dropped.
2015-11-01 14:49:04 +01:00
Martin
b13565c17e Refactor common i1ToI8(voidToI8(DtoType(...))) code occurrences 2015-10-03 22:58:00 +02:00
Martin
80c677be46 Slightly refactor ABIRewrite interface for clarification
* put(): pass DValue alone, without explicit D type
* get(): pass LLValue instead of a faked DValue
2015-09-26 00:30:24 +02:00
Martin
9e194bfe2c Refactor store-to-new-alloca code occurrences. 2015-09-25 17:12:42 +02:00
Martin
4b6bd7ab52 Merge branch 'master' into merge-2.067 2015-07-18 16:02:51 +02:00
Kai Nacke
4cf4690ab0 Use C calling convention for variadic functions on x86.
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.
2015-07-15 21:34:00 +02:00
David Nadlinger
7af77ab141 Fix va_list mangling for System V AMD64 2015-06-07 19:18:58 +02:00
Kai Nacke
1dacce4e53 Merge pull request #856 from kinke/win64abi
Win64 ABI fix: return non-POD structs via sret.
2015-04-08 21:12:49 +02:00
Martin
66fd55afc1 SysV ABI: don't pass delegates partially in registers, partially in memory. 2015-03-15 14:18:12 +01:00
Martin
01e3e372fa Win64 ABI fix: return non-POD structs via sret.
And get rid of obsolete integer rewrites on Win64 and PPC.
2015-02-28 22:51:51 +01:00
Martin
8a3a51e599 SysV ABI: remove support for VALIDATE_AGAINST_OLD_LDC_VERSION. 2015-02-23 22:52:12 +01:00
Martin
dbe801ddff Refactor ABI rewrites. 2015-02-23 22:52:12 +01:00
Martin
079e60fee8 SysV ABI: filter out irrelevant ABI mismatches wrt. to previous implementation. 2015-02-23 22:52:12 +01:00
Martin
af18df953f SysV ABI: fix X86_64_C_struct_rewrite.
Don't attempt to store past the end of alloca()ted memory.
This is important for structs passed in registers whose size
is not a power of 2.
Fix: alloca()te another sufficiently sized chunk, store into
it and then memcpy() the relevant bytes to the target chunk.
2015-02-23 22:52:12 +01:00
Martin
7376a0ca8e SysV ABI: fix ExplicitByValRewrite for D structs and static D arrays. 2015-02-23 22:52:12 +01:00
Martin
bc63b4e1f2 SysV ABI: get rid of some more superfluous rewrites.
Ignore pointer type mismatches as long as both types are pointers;
the element type has no effect on the memory layout.

The RegCount constructor had to be improved to handle more complex
types correctly (e.g., nested structs such as { { i64, i32* } }) as
these are not rewritten anymore.
2015-02-23 22:52:12 +01:00
Martin
2663ae325f SysV ABI: make sure all potential padding bytes of a struct are copied.
For structs > 8 bytes passed in registers.
2015-02-23 22:52:11 +01:00
Martin
76d65d45b5 Never rewrite varargs passed by value. 2015-02-23 22:52:11 +01:00
Martin
90223622c7 SysV ABI: only rewrite function arguments if really necessary.
E.g., don't rewrite named struct types to equivalent unnamed ones.
2015-02-23 22:52:11 +01:00
Martin
3cac22de36 Some more SysV ABI fixes.
Debug unittests: only std.range-debug failing.

Not allowing dynamic arrays to be split seems to have fixed
std.stream-debug and also works for dynamic-array varargs crossing the
registers/stack boundary and extracted using core.vararg.va_arg!T().

Not sure about associative arrays and delegates yet. Delegates cannot
be rewritten using ExplicitByvalRewrite; that triggers type mismatches
somewhere.
2015-02-23 22:52:11 +01:00
Martin
a67c6a3f30 SysV ABI: exclude validation against old LDC implementation by default.
It's quite a bit of optional code.
2015-02-23 22:52:11 +01:00
Martin
97dfd89127 SysV ABI: prevent varargs from being only partially passed in registers. 2015-02-23 22:52:11 +01:00
Martin
6bb2c30c05 SysV ABI: prevent structs from being only partially passed in registers.
Only for formal parameters for now, optional args still need to be fixed.
2015-02-23 22:52:11 +01:00
Martin
9cb1e9465d Refactor and revise SysV AMD64 ABI.
I had another look at the official ABI specs and fixed some issues of
our classify()-based version, e.g.:

* upper half X87Up, but lower half not X87
  => pass whole argument in memory
* choose a fitting (integer/struct) type for structs/static arrays of
  sizes 3,5,6,7,11,13,14,15 bytes
2015-02-23 22:52:11 +01:00
Martin
3f02467d31 Improve some ABI rewrites.
Support structs/static arrays and basic types in X86_64_C_struct_rewrite.
2015-02-23 22:52:11 +01:00
Martin
c19550ad39 Fix va_arg intrinsic. 2015-02-23 22:52:11 +01:00
Martin
995ab00295 SysV AMD64 ABI: fix classify() for void and empty structs.
Their size is 1, so classify as byte.
2015-02-23 22:52:11 +01:00
Martin
7dcadc299a SysV AMD64 ABI: don't rewrite to a single bit.
Otherwise std.uni cannot be compiled:
getAbiType(BitPacked!(bool, 1LU)) mismatch: i1 vs. i8
gen/tollvm.cpp:527: void DtoStore(llvm::Value*, llvm::Value*): Assertion `src->getType() != llvm::Type::getInt1Ty(gIR->context()) && "Should store bools as i8 instead of i1."' failed.
2015-02-23 22:52:11 +01:00
Martin
12aa7864d4 System V AMD64 ABI: don't use CompositeToInt rewrite.
Hope for toArgTypes() to get it right and otherwise be compatible with DMD.
2015-02-23 22:52:11 +01:00
Martin
aa38fe06ec Refactoring: move ABI-specific variadic stuff to TargetABI type. 2015-02-23 22:52:11 +01:00
Martin
7388861686 Validate new toArgTypes()-based System V implementation against
previous version.
2015-02-23 22:52:11 +01:00
Martin
e05b5d2691 Fix System V AMD64 ABI and facilitate debugging.
Fix: void type's size isn't 0 and so must be filtered out in returnInArg()
before calling passByVal().
2015-02-23 22:52:11 +01:00
Martin
a00c2b5732 Rewrite suited structs/static arrays as integers for extern(C) too. 2015-02-23 22:52:11 +01:00
Martin
e5deefb1dd Re-implement __va_list struct allocation for System V AMD64 varargs ABI. 2015-02-23 22:52:11 +01:00
Martin
5e3785159f Re-reverse parameter order for extern(D). 2015-02-23 22:52:11 +01:00
Martin
c6c05f1585 Daring, untested attempt to simplify the System V AMD64 ABI.
Rely on LLVM to assign the registers, for D linkage too.
2015-02-23 22:52:11 +01:00
Martin
9c9d0f66c7 Don't swap real and imaginary parts of complex numbers.
Rely on LLVM to select a sane order, don't use DMD as reference anymore.
2015-02-23 22:52:10 +01:00
kai
dbbbe0092b Fix for issue #637.
In case of a ctor `this` is passed to the function and is also the
return value. This is the perfect case for the `Returned` attribute.
But the x86_64 ABI missed the fact that the return value was a pointer
to a struct and did a struct rewrite, resulting in an bitcast
incompatible type.
2014-11-13 02:06:57 +01:00
Alexey Prokhin
a6f358c59b Remove LINKintrisic 2014-07-10 18:10:46 +04:00
kai
2b6dbb03f4 Add IF_LOG to more logging statements.
Evaluating arguments which call toChars() or toPrettyChars() are much more expensive then checking Logger::enabled().
2014-06-26 06:54:38 +02:00
David Nadlinger
cb341586e3 First merge of 2.064 beta.
This corresponds to DMD commit a913ce4bc59a94a022a27e390fc841f4aededffb.

Doesn't build Phobos yet.
2013-10-29 19:21:15 +01:00
Alexey Prokhin
b819975c84 Eliminate the need for TypeFunction::funcdecl 2013-10-05 19:03:03 +04:00