Commit graph

595 commits

Author SHA1 Message Date
Kai Nacke
1619b18f73 Small cleanup of attribute mess. 2013-12-31 17:29:25 +01:00
Kai Nacke
c231ae0ad0 Merge remote-tracking branch 'origin/master' into merge-2.064
Conflicts:
	gen/arrays.cpp
2013-12-19 21:27:53 +01:00
Kai Nacke
5f520fccf9 Cache result of DtoFunctionType. 2013-12-19 19:45:16 +01:00
Kai Nacke
248d3f2b66 Merge branch 'master' into merge-2.064 2013-11-05 10:47:43 +01:00
kai
6fe28e1660 Small code modifications to Ir-Classes.
Adds some constructors and moves the code to the header file. Uses some of the new constructors.

A big problem with the source are the different strategies used for otherwise similar classes.
E.g. a IrField registers itself with the VarDeclaration. Same is required for IrParameter, but
in this case it is done by the caller.
2013-11-05 10:31:14 +01:00
David Nadlinger
cb341586e3 First merge of 2.064 beta.
This corresponds to DMD commit a913ce4bc59a94a022a27e390fc841f4aededffb.

Doesn't build Phobos yet.
2013-10-29 19:21:15 +01:00
David Nadlinger
c400d180d2 Immediately exit on function type mismatch to avoid LLVM crash. 2013-10-29 19:21:14 +01:00
David Nadlinger
f67cbcda98 DtoType -> DtoFunctionType. 2013-10-29 19:21:14 +01:00
David Nadlinger
265d3ee069 Do not try to emit nested functions with unanalyzed parents.
GitHub: Fixes #497.
2013-10-13 21:37:53 +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
Alexey Prokhin
8fea7484fe Don't use TypeFunction::funcdecl as it is about to be removed 2013-10-05 19:04:18 +04:00
Alexey Prokhin
b819975c84 Eliminate the need for TypeFunction::funcdecl 2013-10-05 19:03:03 +04: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
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
d402cd382e Always add 'uwtable' attribute on x86_64.
This is what Clang does, and omitting it could lead to problems
w.r.t. the System V ABI. Doesn't seem to have caused any issues
so far, though.
2013-05-19 21:47:15 +02:00
David Nadlinger
a792ecbaf2 Fix function attribute handling on LLVM 3.3+.
The issue was that when merging in the old attributes, attrs
wasn't assigned to, thus silently dropping all of them
(leading e.g. to noinline being omitted on functions containing
inline asm).

The new code hopefully also makes the intent clearer.
2013-05-09 22:57:33 +02:00
kai
2e7884a80d Add support for new parameter attribute returned.
Starting with LLVM 3.3 a new parameter attribute `returned` is supported.
The attribute states that the parameter is the return value, too. This is the
case in constructors. (Destructors and postblits do not return `this`.)
Attribute `returned` is now added to the `this` parameter of constructors.
2013-05-05 16:17:34 +02:00
kai
0b19b81ac9 Add new intrinsic LDC_never_inline.
LDC_never_inline is a complementary intrinsic to LDC_allow_inline.
It tells the LLVM optimizer to never inline a function. This can be
useful if inlining creates incorrect code.
A possible application is core.thread.getStackTop().
2013-03-11 22:32:40 +01:00
kai
37558273c2 Remove SARRAYVALUE 2013-03-06 10:20:24 +01:00
kai
c3801d65f5 Remove STRUCTTHISREF 2013-03-06 10:20:24 +01:00
kai
1e4a8fffc2 Remove DMDV1 and DMDV2. 2013-03-06 10:20:24 +01:00
kai
5a9336bf25 Fix another attribute problem with LLVM 3.3. 2013-03-03 15:10:33 +01:00
David Nadlinger
2d3de4a3d4 Fix ABI on Win32.
We can't simply use the C calling convention, as the D(MD)
ABI is callee-pop, and this is hardcoded in naked functions
with stack parameters.

The \1 "trick" is normally used to avoid prefixes added by
LLVM; on the 3.2 release, a patch is needed to make it work
for the @<n> stdcall suffixes as well.
2013-02-26 13:14:32 +01:00
David Nadlinger
3392f70a4e Move calling convention conversion into TargetABI.
The code is tightly coupled to TargetABI (the transformations
there only make sense knowing that the right CC is selected).
2013-02-26 00:20:45 +01:00
David Nadlinger
0a96aea868 Sort includes according to style guidelines:
1. Main include corresponding to .cpp file, if any.
 2. DMD and LDC includes.
 3. LLVM includes.
 4. System includes.

Also updated a few include guards to match the default format.
2013-02-07 21:20:55 +01:00
David Nadlinger
5616753768 Consistently use quotes for LLVM includes. 2013-02-07 21:20:54 +01:00
David Nadlinger
8ff3a8060a Use llvm_unreachable instead of assert(0).
Also removed some unused functions.
2013-02-07 03:38:15 +01:00
kai
104cd77e9c Merge branch 'master' into merge-2.061-2 2013-02-03 15:50:39 +01:00
kai
f806ec0ed5 Attribute holds no longer multiple values in LLVM 3.3.
The solution is to replace Attribute with AttrBuilder in IrFuncTyArg.
Then the argument attributes can be easily manipulated and transformed
into the final AttributeSet.
2013-02-03 15:09:36 +01:00
kai
23f3fd18f1 Merge branch 'master' into merge-2.061-2 2013-02-03 10:54:57 +01:00
kai
fffb23f7ce Replace AttributeWithIndex for LLVM 3.3.
The helper class AttribteWithIndex is gone in LLVM 3.3. Instead a
combination of AttrBuilder and AttributeSet must be used.
2013-02-02 22:04:19 +01:00
kai
bfc23acf30 Merge branch 'master' into merge-2.061-2 2013-02-02 15:27:51 +01:00
kai
9081102f24 Use AttrBuilder for LLVM >= 3.2.
Due to a misunderstanding of the new semantics of the Attribute(s) class,
this class was used in places where class AttrBuilder should be used.
2013-02-02 15:01:13 +01:00
kai
9390374f4d AttributeSet::get(... AttributeWithIndex ...) is now private.
AttributeWithIndex is really going away in LLVM 3.3. This is a
horrible hack to keep everything compiling. Attribute handling
needs some rework.
2013-01-28 22:08:25 +01:00
kai
145e1b5b24 AttributeSet::get(... AttributeWithIndex ...) is now private.
AttributeWithIndex is really going away in LLVM 3.3. This is a
horrible hack to keep everything compiling. Attribute handling
needs some rework.
2013-01-28 19:20:57 +01:00
kai
e68a0fa2a6 Merge branch 'master' into merge-2.061-2 2013-01-26 17:40:24 +01:00
kai
c0284bac2b 2nd attempt on the latest LLVM 3.3 changes.
The previous commit only worked on Windows.
2013-01-26 17:34:08 +01:00
kai
26385c55fe More LLVM 3.3 changes to the AttributeSet class. 2013-01-26 16:27:20 +01:00
David Nadlinger
30caa4bfe6 Merge branch 'master' into merge-2.061-2 2013-01-12 01:27:02 +01:00
kai
6ddb524b91 More LLVM 3.3 changes 2013-01-11 22:46:36 +01:00
kai
a11459bc31 "The Great Renaming" continues.
More changes to match the renamed files of LLVM 3.3.
2013-01-06 17:17:30 +01:00
David Nadlinger
5c518a16ec Merged 2.061 frontend. 2013-01-04 06:22:53 +01:00
kai
4ea7e8dbf8 Add pragma to install function as global C runtime ctor or dtor.
DMD has the obscure functionality to install functions starting with
_STI_ as global ctors and funtions starting with _STD_ as global
dtors. IMHO a pragma is a better way to specify the behaviour.

This commit adds pragma(LDC_global_crt_ctor) and
pragma(LDC_global_crt_dtor). If the pragma is specified on a function
or static method then an entry is made in the corresponding list. E.g.
in monitor_.d:

    extern (C) {
        #pragma(LDC_global_crt_ctor)
        void _STI_monitor_staticctor()
        {
            // ...
        }
    }

This works on Linux without problems. On Windows with MS C Runtime
ctors work always but dtors are invoked only if linked against the
static C runtime. Dtors on Windows require at least LLVM 3.2.
2012-12-22 21:18:37 +01:00
kai
5f37ae30cf LLVM 3.3: class Attributes is renamed to Attribute.
Some other renamings took place in "llvm/Attributes.h" but only this causes
compile errors in LDC.
Also uses new location of "llvm/IRBuilder.h".
2012-12-21 17:32:17 +01:00
David Nadlinger
59a4a02e49 Cleanup: Avoid signed/unsigned comparisons.
The ones ones left are for DMD-defined constants.
2012-12-20 01:21:09 +01:00
David Nadlinger
9cbfc604c7 Fix ICE with closures in member functions.
I chose to fix the problem this way because it increases uniformity
between 'this' and normal explicit parameters. Another possibility
would be to just change the type determinatin code in
DtoCreateNestedContextType to not expect the value to be already
present, because it doesn't need it when isVthisPtr is true anyway.

GitHub: Fixes #217.
2012-12-19 20:27:19 +01:00
David Nadlinger
1bb14c45d2 Removed trailing whitespace. 2012-12-16 17:19:15 +01:00
David Nadlinger
9458911839 Added LLVM-style license headers to all our files. 2012-12-16 17:19:14 +01:00
kai
1a06130cfa AttrListPtr is renamed to AttributeSet in LLVM 3.3. 2012-12-09 19:48:39 +01:00