Commit graph

362 commits

Author SHA1 Message Date
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
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
b63a5e3cf8 Merge branch 'master' into merge-2.068 2015-10-22 22:39:46 +02:00
Martin
a39997d326 Use the target pointer size as lower bound for the alignment of LL globals
This is apparently assumed by a std.conv unittest.

Using DtoAlignment() here instead of checking for an explicit
vd->alignment != STRUCTALIGN_DEFAULT is not only nice for consistency,
but also leads to a `struct S { align(16) int a; }` global being correctly
aligned on a 16-bytes boundary. The struct itself has no explicit
alignment, but alignsize() is 16; so the upstream code doesn't set any
explicit alignment for the global.
2015-10-19 23:25:25 +02:00
Martin
310ad102d7 Don't use DtoAlignment() when determining if a struct is packed
We need the type's natural alignment for that.
2015-10-19 21:21:00 +02: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
46421dbd5f Proper (?) fix in getParentFunc() 2015-10-08 19:41:16 +02:00
Martin
b0649397c0 Nested static functions and function literals do not inherit the parent context 2015-10-08 19:40:54 +02:00
Martin
0d7c0aeedc Proper (?) fix in getParentFunc() 2015-10-08 03:23:02 +02:00
Martin
a2fe91d5e3 Nested static functions and function literals do not inherit the parent context 2015-10-08 02:17:58 +02:00
Martin
cda8a12112 Merge branch 'master' into merge-2.068
Conflicts:
	dmd2/root/man.c
	tests/d2/dmd-testsuite
2015-10-05 22:56:36 +02:00
Martin
b13565c17e Refactor common i1ToI8(voidToI8(DtoType(...))) code occurrences 2015-10-03 22:58:00 +02:00
Martin
8ee0e250c7 Merge branch 'master' into merge-2.068 2015-10-02 15:38:02 +02:00
David Nadlinger
c897015f62 Fix misaligned vector variable initializers
GitHub: Closes #1092.
2015-09-26 19:48:54 +02:00
Martin
d45170464e Merge branch 'master' into merge-2.068
Conflicts:
	runtime/druntime
2015-09-26 14:21:43 +02:00
Martin
9e194bfe2c Refactor store-to-new-alloca code occurrences. 2015-09-25 17:12:42 +02:00
David Nadlinger
f9e8f0d09a Merge branch 'master' into merge-2.068
druntime/phobos/dmd-testsuite not yet merged
2015-09-13 18:17:23 +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
cb0cecb9e7 Implement ToElemVisitor::visit(TypeidExp*) 2015-08-29 03:09:17 +02:00
David Nadlinger
9fd1e8d2a6 Merge frontend tag v2.068.0
Kept idgen as C++ program for now. We'll tackle build system integration
once we actually switch to DDMD.
2015-08-29 03:09:17 +02:00
David Nadlinger
47bd4c5f7b Fix ICE caused by type mismatch on casting sret return value
Another one caused by special "context-specific" AST semantics. :/

GitHub: Fixes #982.
2015-08-21 23:34:26 +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
5064909c32 Fix handling of reals where padding is built into the LLVM type
This fixes structs with members of structs with real fields. Did not
fail the test suite unless building with assertions before, but
crashed building real-world applications (and obviously led to wrong
struct layouts).
2015-08-10 20:49:30 +02:00
David Nadlinger
63ca3c7eb4 Always zero struct padding as required by TDPL
We already generated the memsets for zeroing the padding,
but because we relied on the native LLVM type allignment
where possible instead of generating explicit padding
values, LLVM did not always copy those bytes around (e.g.
when spilling/reloading registers).
2015-08-10 20:49:30 +02:00
David Nadlinger
553ce18a5e Fix crash due to invalid iterators in DtoEnclosingHandlers
Unfortunately, I could not manage to isolate a self-contained
test case. The bug is quite specific to the exact memory
allocation decisions made by the standard library, as it will
not occur if the elements appended by the finally block codegen
fit into the current capacity.
2015-08-09 20:25:39 +02:00
Martin
9d5560601a WIP: fix array construction/assignment wrt. RAII 2015-07-22 01:41:17 +02:00
David Nadlinger
21d1bab114 Merge branch 'master' into merge-2.067 2015-07-11 18:10:43 +02:00
David Nadlinger
f7c3fc4ef3 Do not emit globals with void initializer as LLVM constants
Fixes things like `const(Foo) f = void; static shared this() { f = …; }`.
2015-07-08 02:34:48 +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
6f6f6b1987 Use new global string literal cache for module names 2015-06-14 21:27:21 +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
f49d32f5f6 Merge branch 'master' into merge-2.067 2015-05-31 19:01:54 +02:00
Kai Nacke
63ed72cf48 Merge branch 'master' into merge-2.067 2015-05-30 10:42:06 +02:00
David Nadlinger
568bf3723b DtoSymbolAddress: Remove support for unused ClassInfoDeclaration
It will be gone in 2.068.
2015-05-30 06:23:16 +02:00
David Nadlinger
084ae9da5b Remove extra load on assignment generated only for debug info
This leads to serious problems for values we really should
not be loading from, such as 100k element static arrays.

It was hard to figure out exactly why we need to emit DWARF
info here, so the easiest solution is to just have a look
at assignments during the next big debug info push.
2015-05-29 00:53:58 +02:00
Martin
c76ac3496d Enable default-initialized static arrays of voids.
With a single byte (implicit and 0) as initializer, as each void
element occupies 1 byte.

This is required when building T.init for a struct T containing
a void[N] with N > 0 and building literals of T.
2015-04-26 14:15:51 +02:00
Martin
2f9b58e261 Don't copy any data when assigning to empty structs. 2015-04-26 02:36:52 +02:00
Kai Nacke
7159aa5392 Merge branch 'master' into merge-2.067 2015-04-16 07:27:09 +02:00
Johan Engelen
8396fc941b Modify stripModifiers to optionally work transitively.
Strip modifiers transitively when testing whether to repaint return type.
2015-04-14 22:06:44 +02:00
Martin
6c333f5761 Allocate structs on the heap via runtime function _d_newitem.
This is required for the GC to be able to call their dtors, if need
be (by appending a TypeInfo pointer after the actual struct in case
the struct has a dtor).

_d_newitemT() / _d_newitemiT() also perform the initialization, so
we don't need to take care of that in toir.cpp anymore.
2015-04-04 21:00:05 +02:00
Martin
f8c9c72795 Don't try to invoke non-existent dtors when deleting dynamic arrays.
Runtime function _d_delarray_t() expects the TypeInfo_Struct argument
to be null if the struct has no dtor.

This fixes runnable/hospital.d, which deletes a dynamic array of class
handles. But in this case, we only delete the memory allocated for the
handles and don't destruct the actual class instances!
For hospital.d, it doesn't matter as the class has no dtor.
But I doubt that's intended behavior...
2015-03-29 17:55:47 +02:00
Martin
7d0d2a1d26 Call _d_delstruct() runtime function when deleting struct pointers.
As long as the struct has a dtor, otherwise continue forwarding
to _d_delmemory().
2015-03-29 04:54:31 +02:00
kai
350c01a97d Updates to runtime functions.
Adds new functions and corrects signatures.
2015-03-21 21:50:49 +01:00
kai
9ef4c8f421 Implement _d_arraycatnTX and remove _d_arraycatnT.
With this commit, the first simple applications can be linked and run!
2015-03-21 17:37:51 +01:00
kai
c39c7e9c35 Update to DMD v2.067.0-b2
Includes all tagged with v2.067.0-b2. Does not includes latest druntime changes from ldc (head) branch.

This is known to be broken. I only merged the frontend stuff but did not try to compile something...
2015-02-24 22:16:17 +01:00
kai
a2748cd2fd Merge current development state of 2.067
First merge of current development stream. Asm blocks are known to be broken.

DMD:      0c9f437bc24015707130ba42dc434d9cd58282fb
druntime: 86d49cfb3670904603df0cfdfe44c6fff565c0fc
Phobos:   a8ca4f7964becac680af0eadbde05aa7d10fc338
2014-11-15 18:53:23 +01:00
David Nadlinger
ced9f884df Do not emit variables for enum declarations.
GitHub: Fixes #762.
2014-10-25 14:36:49 +02:00