Commit graph

446 commits

Author SHA1 Message Date
David Nadlinger
1242be25d0 Remove unused, empty Ir type.
The codegen parameter was changed to IRState instead of
removing it to set the stage for an eventual eradication
of the gIR global.
2013-10-13 19:44:29 +02:00
David Nadlinger
4fee629c4d Prefer more specific functions to DtoResolveDsymbol.
The remaining ones should also be easy to remove with a
closer look at the situation.

Ideally, we would get rid of all of them at some point and
use safe wrapper functions for accessing the IrDsymbol
associated with a given declaration (which would emit the
declarations on the fly if not already present).
2013-10-13 19:18:24 +02:00
David Nadlinger
787c147986 Use Module::members -> Dsymbol::codegen to define symbols.
This commit fundamentally changes the way symbol emission in
LDC works: Previously, whenever a declaration was used in some
way, the compiler would check whether it actually needs to be
defined in the currently processed module, based only on the
symbol itself. This lack of contextual information proved to
be a major problem in correctly handling emission of templates
(see e.g. #454).

Now, the DtoResolve…() family of functions and similar only
ever declare the symbols, and definition is handled by doing
a single pass over Module::members for the root module. This
is the same strategy that DMD uses as well, which should
also reduce the maintainance burden down the road (which is
important as during the last few releases, there was pretty
much always a symbol emission related problem slowing us
down).

Our old approach might have been a bit better tuned w.r.t.
avoiding emission of unneeded template instances, but 2.064
will bring improvements here (DMD: FuncDeclaration::toObjFile).
Barring such issues, the change shoud also marginally improve
compile times because of declarations no longer being emitted
when they are not needed.

In the future, we should also consider refactoring the code
so that it no longer directly accesses Dsymbol::ir but uses
wrapper functions that ensure that the appropriate
DtoResolve…() function has been called.

GitHub: Fixes #454.
2013-10-13 19:18:24 +02:00
David Nadlinger
4987894468 Also make storage for immutable array const initializers constant/unnamed_addr. 2013-10-09 05:32:41 +02:00
David Nadlinger
0cdb74aae7 Do not heap-allocate immutable array literals. 2013-10-09 04:07:46 +02:00
David Nadlinger
60cdf58168 Combine ArrayLiteralExp::toConstElem and initializeArrayLiteral implementations. 2013-10-09 04:07:46 +02:00
David Nadlinger
eb3261f93c Do not GC-allocate temporary for static array initialization. 2013-10-09 01:51:45 +02:00
David Nadlinger
9866e5a14f Comment typo fix. 2013-10-09 01:51:45 +02:00
David Nadlinger
44f60199ad Factored actual literal building code out of ArrayLiteralExp::toElem. 2013-10-09 01:51:45 +02:00
David Nadlinger
71c67457c3 Cleanup: Kill backend_init/term. 2013-10-06 01:33:28 +02:00
Alexey Prokhin
b819975c84 Eliminate the need for TypeFunction::funcdecl 2013-10-05 19:03:03 +04:00
David Nadlinger
f35176efad Fix SymOffExp::toConstElem.
I am surprised and horrified at the same time that the test suite
(on platforms other than Windows, where the code path is triggered
in core.stdc.stdio) did not catch this at all.

The elemSize-dependent path probably doesn't make too much sense for
global variables, as it always refers to the total size of the global.
Should add a special case for arrays for clearer codegen in those cases.

GitHub: Fixes #477.
2013-09-21 18:53:26 +02:00
David Nadlinger
b17a6421a4 Merge pull request #475 from klickverbot/assert-release-trap
Emit trap for assert(0) in release mode.
2013-09-15 23:46:26 -07:00
David Nadlinger
945f4882c2 Emit trap for assert(0) in release mode. 2013-09-15 23:53:52 +02:00
David Nadlinger
3556f52b95 Fix _d_invariant mangling on MinGW/Win32.
This is getting uglier and uglier, should probably just switch back
to extern(C) irrespective of what upstream DMD does.
2013-09-15 19:57:25 +02:00
David Nadlinger
90127ab87a Fix broken indentation in debug log output. 2013-09-12 10:21:01 +02:00
kai
6875d8a20f Mark frontend generated strings with attribute unnamed_addr.
This is part of a fix for issue #133.
2013-08-18 23:34:41 +02:00
kai
f769406216 Fix for issue #119.
Instead of creating individual stores to the array elements an constant
array is created and assigned to the destination memory. This is much
less IR than before. With -O it is optimized to a memset.
2013-08-18 19:36:58 +02:00
kai
c28c7fb134 Introduce a debug info builder.
Moves all code from todebug into a new class.
Also caches the compilation unit in order to fix a LLVM 3.4 compile error.
2013-07-29 00:04:08 +02:00
Alexey Prokhin
8b783da523 Fixed cases where the destructor is called on an uninitialized temporary 2013-07-10 18:15:05 +04:00
Alexey Prokhin
1999749415 Issue #426 part 2. Generate a try-finally block only if it is required
(i.e. there are actually some destructor calls that are needed to be put into finally)
2013-07-10 13:34:52 +04:00
Alexey Prokhin
71023952d4 Issue #426 part 1. Wrap destructor calls of temporary variables in a try/finally expression. 2013-07-10 13:34:52 +04:00
Kai Nacke
ebadc7fcb3 Merge pull request #412 from AlexeyProkhin/cpp
extern(C++) interfaces
2013-06-30 15:37:10 -07:00
kai
67a9391f79 Replace an old-style cast. 2013-06-30 22:30:13 +02:00
Alexey Prokhin
90bb32d2d8 extern(C++) interfaces 2013-06-22 17:33:00 +04:00
David Nadlinger
235bb94878 Make -release only disable bounds checking in non-@safe code. 2013-06-17 13:31:21 +02:00
David Nadlinger
1215ffacd3 Complete IrStruct->IrAggr rename. 2013-06-17 13:14:15 +02:00
David Nadlinger
897c4382af Do not re-codegen struct literals on taking address of globals.
The AST the frontend generates is arguably invalid, but we
have to deal with that.

Fixes DMD testcase 'interpret'.
2013-06-16 01:02:46 +02:00
David Nadlinger
2e0941c194 Add names for globals to make LDC compile against LLVM 3.1. 2013-06-15 16:16:47 +02:00
David Nadlinger
c813ccdcf7 Small debug diagnostics improvements. 2013-06-15 15:04:48 +02:00
David Nadlinger
bca5dac669 Fixed ClassReferenceExp codegen, handle self-referential literals. 2013-06-15 15:04:48 +02:00
David Nadlinger
041e8e8b54 Remove LDC-specific .classinfo AST rewrite.
Apart from reducing the diff to upstream DMD, this also fixes a
"cannot interpret" CTFE issue.
2013-06-14 21:49:44 +02:00
David Nadlinger
9dc387aa91 Do not invoke postblit twice on struct literal creation.
The frontend seems to explicitly insert __cpctor now.

Fixes DMD testcase 'sdtor'.
2013-06-14 16:43:41 +02:00
David Nadlinger
4901877d24 Handle side-effects in TupleExp::e0.
Fixes DMD testcase 'aliasthis'.
2013-06-14 15:03:24 +02:00
David Nadlinger
83415eeeb8 Minor debug log fixes. 2013-06-14 15:03:24 +02:00
David Nadlinger
c64c4f479a Handle static array typed SliceExps.
Fixes DMD testcase 'testbounds2'.
2013-06-13 18:45:07 +02:00
David Nadlinger
bc910004a4 Adapt codegen to removal of old _d_invariant from druntime.
We should think about using symbolic constants for runtime function
names though, this is not maintainable in the long run.
2013-06-12 20:34:50 +02:00
David Nadlinger
4c788699ae Initial, incomplete ClassReferenceExp::toConstElem implementation.
Allows us to get through a Phobos build without errors.
2013-06-12 20:23:27 +02:00
David Nadlinger
a9e620d428 Work around invalid special ref var initializations in 2.063. 2013-06-12 20:16:37 +02:00
David Nadlinger
292caa1438 Merge the 2.063 frontend. 2013-06-12 20:16:37 +02:00
David Nadlinger
9a016a1002 Refactor struct initializers codegen.
This not only reduces code duplication, but the unification
also enables code a la StructLiteralExp to handle classes
(for CTFE class constant support in 2.063).
2013-06-12 20:16:05 +02:00
David Nadlinger
5dadec2e70 Remove raw address from log output.
Makes comparing logs harder.
2013-06-12 17:16:46 +02:00
David Nadlinger
28f39cbdad Remove superfluous Expression::toConstElem overrides.
The error message can be printed by the non-overridden
Expression::toConstElem just as well.
2013-06-12 17:16:31 +02:00
David Nadlinger
978c2c1b6a Re-enable SymOffExp and remove associated LLVM-only modifications. 2013-06-11 00:40:48 +02:00
David Nadlinger
f5e276d6a6 Revert meaning of AddExp/MinExp for pointers to DMD default.
It might be worth considering to move the stride multiplication
down to the glue layer in the upstream sources. But assigning a
different meaning to AST nodes was a giant maintenance
liability, especially with regard to CTFE.
2013-06-10 22:49:01 +02:00
David Nadlinger
049f784e5f Remove extra semicolons after macro invocation.
Silences some Clang warnings.
2013-06-10 19:54:19 +02:00
David Nadlinger
bf0e03df98 Also avoid i1 in TupleExp::toElem. 2013-06-10 19:49:52 +02:00
David Nadlinger
848dee32d4 Store bools as i8.
I really hope we can refactor this to use a less leaky
abstraction later – it should at least be possible to merge
voidToI8 and i1ToI8.
2013-06-07 03:20:54 +02:00
David Nadlinger
1fed92b9b7 VarExp::toElem refactoring and global size assertion.
Frontend errors shouldn't be used for glue layer consistency
checks – maybe the error was actually hit in ancient versions.
2013-05-19 20:25:16 +02:00
David Nadlinger
7b435c2c87 Unify handling of struct initializers.
GitHub: Fixes #351.
2013-05-18 19:51:37 +02:00