Commit graph

335 commits

Author SHA1 Message Date
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
kai
95806fd7cd Merge branch 'master' into merge-2.067
Conflicts:
	runtime/druntime
2015-03-15 20:35:44 +01:00
Martin
de783557bb ABI fix: let lazy parameters (i.e., delegates) be rewritten.
Implying that when allocating storage for the D delegate argument,
we need to allocate a LL struct representing the D delegate instead
of an instance of the actually passed LL type, which may have been
rewritten.
2015-03-15 14:18:12 +01:00
kai
f61327c149 Replace AsmBlockStatement with CompoundAsmStatement. 2015-03-01 16:40:44 +01:00
Martin
92d9ade0d1 Rework LLVM attributes abstraction. 2015-02-24 13:42:22 +01:00
Martin
c3f2e19c53 Fix AttrSet struct for LLVM 3.1 and 3.2.
Use a map instead of a vector as the attribute index may get as
high as 0xFFFFFFFF (LLVM 3.1), apparently for function attributes.
2015-02-23 22:53:09 +01:00
Martin
76d65d45b5 Never rewrite varargs passed by value. 2015-02-23 22:52:11 +01:00
Martin
e7bfb78632 Refactor attributes system.
By introducing abstractions for attribute builder and set since they differ
greatly between LLVM 3.1-3.3.
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
a41a31d535 Get rid of obsolete DtoVariadicArgument(). 2015-02-23 22:52:11 +01:00
Martin
f5592048e5 Get rid of obsolete TargetABI::newFunctionType() and doneWithFunctionType(). 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
9839cfb889 Experimental varargs fix 2015-02-23 22:52:10 +01:00
kai
024b14cd7f Fix some warnings.
These are easy to solve and reduce the noise in the Travis build.
2014-12-26 15:59:23 +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
kai
e5745f5bb1 Fix compile error with LLVM 3.6.
The llvm::Linker class now uses diagnostic messages.
2014-10-25 18:11:49 +02:00
kai
332480460c Revert "Fix compile error with LLVM 3.6."
This reverts commit cc829485cc.
2014-10-25 18:02:26 +02:00
kai
cc829485cc Fix compile error with LLVM 3.6.
The llvm::Linker class now uses diagnostic messages.
2014-10-25 17:39:42 +02:00
David Nadlinger
bb1ad7e324 Clean up linkage handling.
Since the change to the symbol emission strategy, a lot of the
previous attempts to derive the linkage for a symbol from its
AST node has been superfluous. This cleans up all the related
code, as it is really not doing much anymore.

The code to opportunistically internalize symbols is now gone
entirely. It was commented out anyway due to problems with
making it work reliably in the face of the not-so-stable
structure of the AST we get from the frontend (regarding the
modules certain symbols end up in). But in any case internal
linkage woudl also be troublesome for cross-module inlining,
so I gave up on making this work for the time being.

The only (minor) change in the emitted code should be in
.offTi generation, which is untested and disabled by default
anyway (GENERATE_OFFTI).
2014-10-08 20:55:19 +02:00
Alexey Prokhin
4e2d45a409 Move irFty fields to backend ir classes 2014-10-05 16:55:22 +04:00
Alexey Prokhin
66a392a5c2 Rename Type::irtype to ctype for consistency with dmd and gdc 2014-10-05 16:55:12 +04:00
Alexey Prokhin
0f7a3b64c5 Make FuncDeclaration::isIntrinsic and FuncDeclaration::isVaIntrinsic free functions 2014-10-05 16:08:58 +04:00
David Nadlinger
3d1be20470 Remove availableExternally logic and extra inlining semantic passes.
Turns out that since the change to use DMD's symbol emission
logic a few releases back we didn't actually ever emit code
for the extra modules. Thus, all the effort for the extra
semantic passes went to waste.

If we want to implement DMD-style cross-module inlining, we
need to add the extra semantic3s back in, and then iterate
over all the non-root modules with a codegen visitor that
only emits symbols as available_externally.

We probably won't need the availableExternally members if
we start with a clean design in the new symbol emission
framework. Thus, remove everything in the meantime. This
will make some release builds a bit faster, and should not
negatively affect generated code.
2014-10-04 20:02:13 +02:00
David Nadlinger
8fafb59157 [cleanup] Slight comment improvements. 2014-09-15 23:19:52 +02:00
David Nadlinger
9b9d6035aa [cleanup] Remove unused DtoBaseFunctionType. 2014-09-14 18:13:43 +02:00
David Nadlinger
73735dd98c Fix assertions-enabled build.
needsCodegen was moved to TemplateInstance in 2.066.1.
2014-09-14 18:13:19 +02:00
David Nadlinger
28f4bce28c Merge DMD 2.066.1-rc1 plus dmd#3985.
This corresponds to DMD commit 9ca87d2855e30a42c65aea0be93a93449f82400c,
which will likely be released as 2.066.1.
2014-09-14 16:07:19 +02:00
David Nadlinger
e1ffd58732 Merge branch 'master' into merge-2.066
Conflicts:
	gen/functions.cpp
2014-09-14 15:29:43 +02:00
David Nadlinger
934c67dc75 Emit functions as available_externally instead of skipping them.
This finally fixes the performance regression due to missing
inlining after the switch to the DMD-style symbol emission
logic (what later became FuncDeclaration::needsCodegen).

In my tests, this slightly increased compile times in release
mode (~7% for a set of small-ish programs) due to the extra
codegen. The impact is that small because we were doing all the
extra semantic{2, 3}s anyway (only to throw their results away)
and still get to avoid the LLVM backend. The performance gains
are, depending on the benchmark, spectacular, as this was
responsible for things like std.array.front not getting inlined.
2014-09-14 14:54:17 +02:00