Commit graph

570 commits

Author SHA1 Message Date
Kai Nacke
1653911600 Revert "Merge branch 'ltsmaster'"
This reverts commit dcb781004b, reversing
changes made to 3c6f09faf0.
2016-03-03 13:14:39 +01:00
Kai Nacke
dcb781004b Merge branch 'ltsmaster' 2016-03-03 07:50:17 +01:00
Dan Olson
98a608e925 First proof -of-concept for objc support
This at least shows a path forward.  Pretty much a kludge to at this
point, but passes the tests.
2016-03-02 00:30:58 -08:00
Kai Nacke
815b13be38 Run semantic on Type::tvalist.
This is required to resolve the type for AAPCS/AAPCS64.
Up to now it was not necessary because only char* was used.
AAPCS/AAPCS64 use a special extern(C++) struct __va_list.
2016-02-29 08:38:08 +00:00
Johan Engelen
29ce4012af dmd2 --> ddmd. Merge (almost all of) our changes to dmd source into the new D source of dmd 2.069.2.
Also adds the CMake infrastructure to compile and link the D source files.

The build is partially broken:
- A few files in Phobos and druntime do not build
- MSVC build is broken because of unresolved symbols involving reals
2016-01-28 19:03:58 +01:00
Johan Engelen
8d078f3bd8 Implement @ldc.attributes.section("...") for functions. 2015-12-31 12:15:40 +01:00
Martin
7fc28d8143 Use nonnull and dereferenceable attributes for function params 2015-12-14 00:58:25 +01:00
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