Commit graph

363 commits

Author SHA1 Message Date
Martin
e7f26a94b0 Prepare generic x86 TargetABI for proper MSVC support
Based on Rainer's work in
3e36652c2c
2015-12-06 19:09:33 +01:00
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
740a21eb8f Rename DtoIsPassedByRef() to DtoIsInMemoryOnly()
Motivation: issue #937
2015-12-04 22:23:09 +01:00
Johan Engelen
70a6e73188 Cleanup runtime fwd decls and use ABI functiontype rewriting 2015-11-22 01:27:26 +01:00
Martin
71912511a5 Adaptations for recent LLVM 3.8 master changes 2015-11-08 14:06:16 +01:00
Martin
2dfa5e8569 Some more cosmetic fixes
Found by searching for lines > 80 chars.
2015-11-05 19:12:32 +01:00
Martin
04ab1c2441 Clarify semantics of TargetABI::passByVal() 2015-11-02 23:35:27 +01:00
David Nadlinger
05d45350aa clang-tidy: Add readability-else-after-return 2015-11-02 11:30:40 +02: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
Martin
90197d6c72 Simplify working with LLVM attributes 2015-11-01 16:19:27 +01:00
David Nadlinger
6bf9a7c63e Merge pull request #1176 from kinke/cleanup
Drop support for LLVM < 3.5
2015-10-31 19:35:32 +02:00
David Nadlinger
3fb689caea Emit debug info for ref and out parameters
Fixes DMD testcse 'gdb4149'.
2015-10-31 12:34:55 +02:00
Martin
60d676e2a1 Drop support for LLVM < 3.5
This allows to clean up the code a little.
2015-10-30 22:24:05 +01:00
Martin
05c10d9107 Introduce DtoAlignment() and overload DtoAlloca() for VarDeclarations
Trying to get the alignment right by using the first non-default one
in the following order of descending priority:

VarDeclaration::alignment [variables only of course]
Type::alignment()
Type::alignsize()

This fixes `align(x) struct S { ... }`.
2015-10-18 14:38:09 +02:00
Martin
5c68fb25a4 Win64 ABI: pass 'this' before 'sret' for extern (C++) 2015-10-12 22:15:49 +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
Kai Nacke
dc8ff497ac Merge pull request #1082 from klickverbot/empty-structs-linux
x86: Only skip empty structs on OS X
2015-09-19 18:12:33 +02:00
Martin
1a42358cf6 Treat atomic instructions as intrinsics
Whose types aren't rewritten by the regular TargetABI.
2015-09-18 00:02:57 +02:00
Kai Nacke
ab2e8e3646 Refactor new COMDAT code.
Linkage and the COMDAT flag is now returned as std::pair<>.
Also adds more COMDATs.
2015-09-17 21:04:40 +02:00
David Nadlinger
6f83cb2905 x86: Only skip empty structs on OS X 2015-09-16 18:37:48 +02:00
kai
cf8875fad1 Fix for issue #988.
Starting with LLVM 3.7, linkage and COMDAT are 2 different concepts.
This means that LinkageODROnce does not put the object into a COMDAT.
On Windows this resulted in linker error messages.

This PR places all template functions, TypeInfo objects and other
objects into a COMDAT.
2015-09-09 16:46:49 +02:00
David Nadlinger
ee50259dfd C ABI: Do not pass empty structs as parameters at all
This is most visible on x86 (32-bit), where the stack
alignment is off otherwise.

This change is quite messy because many places assumed
that there was always exactly one LLVM parameter per
TypeFunction::parameters entry.
2015-08-22 23:41:56 +02:00
David Nadlinger
410203b37a DtoDeclareFunction: Remove unnecessary indentation (NFC) 2015-08-22 20:42:42 +02:00
David Nadlinger
6555f2776e DtoFunctionType: Use llvm::SmallVector for temporary arg type storage 2015-08-22 19:17:36 +02:00
David Nadlinger
83dc8859cb Cleanup/comments in DtoFunction type (NFC) 2015-08-22 19:14:43 +02:00
David Nadlinger
4bcae9731a The big catch/finally rework, part 2
Now with *almost* working EH codegen. Does not compile Phobos yet
because we run into the "instruction does not dominate all uses"
issue when an r-value result of toElemDtor is used and we need to
run cleanups in between. Should easily be fixed by promoting those
values to allocas.

Most of the changes outside of ir/irfunction.{h, cpp} are just
because CreateCallOrInvoke moved locations. I took the
opportunity to also make use of the different arg count
overloads where possible.
2015-08-19 19:56:39 +02:00
David Nadlinger
4236ae9ce5 The big catch/finally rework, part 1
Never generates any landing pads or invoke instructions right now
for simplicity. The code for emitting them will be added back in
the next step.

The "after..." blocks without any precedessors remain for now, as
we need a clean way to suppress any codegen for that block (but
not new blocks, which might resolve labels) before tackling that
one.

Builds druntime/Phobos on OS X x86_64 (albeit without EH, of course).
2015-08-19 19:56:39 +02:00
David Nadlinger
bfc20df4c8 Remove IRScope::end
Specifying the basic block before which to insert the new one
is not mandatory when calling llvm::BasicBlock::Create. This
was the only use of the tracked "end" block. The concept was
phony anyway because there is no single "end" to a scope with
unwinding and so on.

For prettying up the IR, it is possible to change the order
of basic blocks using move{Before, After}().
2015-08-19 19:56:39 +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
Kai Nacke
d1e764cec1 Backport of "Avoid using llvm::Linker" to master.
See pull request #974 for the original code.
2015-06-27 22:08:44 +02:00
David Nadlinger
0922254dd1 Directly emit IR into same llvm::Module instead of using Linker
GitHub: Fixes #970.
2015-06-14 21:36:35 +02:00
David Nadlinger
de73a30f05 Factor out inline IR handling code into gen/inlineir.{cpp, h}
It is the only part that will continue to use the IR linker.
2015-06-14 21:27:21 +02:00
David Nadlinger
bfdd93cdb7 Remove dead code 2015-06-14 21:27:21 +02:00
David Nadlinger
6190382c3b Move module ctor/dtor/unittest lists to IrModule 2015-06-14 21:27:21 +02:00
David Nadlinger
fb39a5fb9d Remove unused IRState::emitMain 2015-06-14 21:27:21 +02:00
Kai Nacke
cddb59f7b7 Merge branch 'master' into merge-2.067 2015-06-04 22:02:52 +02:00
Kai Nacke
b301407f9c DebugInfo: Use the IRBuilder to create a ret instruction.
This ensures that a previous set debug location will be set on the
return instruction.
2015-06-04 21:22:38 +02:00
Kai Nacke
80acadc841 Merge branch 'master' into merge-2.067 2015-06-04 20:48:38 +02:00
Kai Nacke
104e7c991f DebugInfo: Remove most calls to EmitFuncEnd()
Debug information is based on static lexical blocks. Most calls to
EmitFuncEnd() are done if control flow reaches the end of the
function which is quite different.
2015-06-04 20:19:54 +02:00
Kai Nacke
fe2b9d445d Merge branch 'master' into merge-2.067 2015-06-04 16:24:31 +02:00
Kai Nacke
15b1ee1576 DebugInfo: Output the underlying delegate for lazy parameters.
This fixes issue #959.
2015-06-04 15:09:29 +02:00
Kai Nacke
ccd8dd06c5 Merge branch 'master' into merge-2.067 2015-05-23 23:53:36 +02:00
Kai Nacke
f1c4cf92ff Possible fix for issue #938.
The functions for all arrayops are compiler-generated but the functions
which are also defined in druntime are never emitted. This prevents
inlining of the function body and causes issue #938.

The fix is to emit the arrayops if inlining is enabled and otherwise
use the druntime provided implementations.

An alternative approach could be to always emit the arrayops and
never use the druntime version.
2015-05-23 23:02:17 +02:00
Kai Nacke
23303140fe Merge branch 'master' into merge-2.067 2015-05-22 21:44:33 +02:00
Kai Nacke
8d0fada2c2 LLVM 3.7: The signature of CreateCall() has changed.
The method now takes an array with the argument values.
2015-05-22 21:25:14 +02:00
Martin
6c645649ed Enable passing binAssign expressions as ref/out arguments.
Fixes runnable/testassign.d.
2015-04-24 00:40:01 +02:00
Martin
f656477bf8 Watch out for functions returning "ref void".
The 2.067 front-end doesn't rewrite these to void anymore, so let's
rewrite in DtoFunctionType().

This issue has surfaced in a std.conv unit test, where
std.range.primitives.front() is instantiated for const(void)[].
The template refuses void[] but accepts this const(void)[]...
2015-03-23 22:36:33 +01:00