Commit graph

484 commits

Author SHA1 Message Date
Johan Engelen
53a14b325b Add per-function FastMathFlags and apply them upon function codegen. 2016-05-22 19:56:56 +02:00
Johan Engelen
b25b7966cc Pass IrFunction* to applyFuncDeclUDAs instead of irfunc->func (llvm::Function*) such that LDC's UDAs can set function properties that are not part of llvm::Function. 2016-05-22 19:56:56 +02:00
David Nadlinger
219758756c Merge branch 'merge-2.071' 2016-05-06 19:24:48 +01:00
Rainer Schuetze
bc1a1b1f9e fix runnable/cppa.d for Windows: C++ interface functions are implemented without thunks, the this pointer is adjusted in the function itself 2016-04-28 23:43:50 +02:00
Rainer Schuetze
8672cf409f implement check for scoped destruction in closure, fixes fail_compilation/fail10666.d 2016-04-21 23:30:26 +02:00
Johan Engelen
9955d8e4e4 For LDC_inline_ir functions: instantiate a new "alwaysinline" function for each call, which is the current behavior for inline ASM too.
When certain attributes are applied to the calling function, like "unsafe-fp-math", the inlined inlineIR function has to have the same attributes otherwise the calling function attribute will be reset to the safe merge of the two: "false". Because the same inlineIR function can be called in different functions using an alias definition, a new function (with possibly different attributes) has to be instantiated upon every call.

Related GH issue #1438
2016-04-21 10:16:33 +02:00
Dan Olson
cd216538f9 Merge branch 'master' into objc-wip 2016-04-08 22:38:39 -07:00
Kai Nacke
88f3de8bea Merge branch 'ltsmaster' 2016-03-22 19:05:07 +01:00
Martin
88dcb4349a Refactor setting linkage type and COMDAT 2016-03-20 16:37:44 +01:00
David Nadlinger
123727ee99 DtoDefineFunction: Avoid assertion after unanalyzed function ICE
The first check is what DMD also does; the second one is to replace
the assertion by an ICE, since the bug can apparently be triggered
rather reliably.

See GitHub #1360.
2016-03-20 01:14:22 +00:00
Martin
4ecfadbc1c MSVC: Re-enable alignment attribute for sret params
Seems to be working with recent LLVM - at least for x64.
2016-03-16 19:45:37 +01:00
Dan Olson
87bbd57ffa Emit error if Objective-C method missing selector
Otherwise method is called as a virtual function and program crashes.
2016-03-08 00:17:42 -08:00
Kai Nacke
d4dc52d4aa Fix compile errors caused by D frontend
- scope is now _scope
- targetTriple requires -> instead of .
- factory method createTypeIdentifier() instead of new TypeIdentifier()
2016-03-03 21:41:46 +01:00
Kai Nacke
24adf155ff Revert "Revert "Merge branch 'ltsmaster'""
This reverts commit 1653911600.
2016-03-03 21:12:53 +01:00
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