Commit graph

2846 commits

Author SHA1 Message Date
Martin
e9ac0a7d2b Set DataLayout for inline-IR modules
This gets rid of LLVM warnings when linking the IR module into the main
one.
2016-08-21 14:26:54 +02:00
Martin
fc2523aa46 Fix issue #1711 2016-08-21 14:26:23 +02:00
David Nadlinger
c379d790b1 Merge pull request #1709 from kinke/fix1698
Fix issue #1698 (missing semantic3() for special member functions)
2016-08-20 23:29:51 +02:00
Martin
eab29ba173 Only define special member functions if semantic3 was run 2016-08-19 23:22:03 +02:00
Martin
642ca606c3 Run semantic3() before defining special member functions (xopEquals etc.)
This fixes issue #1698.
2016-08-19 22:58:20 +02:00
David Nadlinger
d47bdb234a gen: Use single ldc.register_dso function for both module ctor/dtor
This reduces the size of a statically linked Phobos-based
Hello World by 11 kB on Linux x86_64.

Also creates a header file for gen/module.cpp, which has been
renamed to "modules" such as not to conflict with the frontend
header file.
2016-08-18 16:28:41 +02:00
David Nadlinger
e7c95dbd53 gen: Separate ModuleInfo struct emission code [nfc]
gen/module{.h, .cpp} currently is a big kitchen sink for various things
related to emitting modules. This hopefully makes the distinction between
generating the ModuleInfo data and the code to register it with druntime
clearer.
2016-08-18 16:27:34 +02:00
David Nadlinger
53cdc9a68e gen: Const-ify a loc parameter [nfc] 2016-08-18 16:27:34 +02:00
David Nadlinger
537579841c Merge pull request #1695 from kinke/binassignFix
Fix too restrictive assertion for binassigns
2016-08-16 02:54:33 +02:00
Johan Engelen
ee0881c353 Fix unused field warning. 2016-08-15 18:24:58 +02:00
Johan Engelen
5448b5f0ff Fix unused private field warning (SwitchCaseTargets::llFunc) and remove use of global gIR. 2016-08-15 18:24:58 +02:00
Martin
ed87df79b1 Fix too restrictive assertion for binassigns
This was hit when compiling ddmd/lexer.d:1189, where a const(T)* is
implicitly cast to a const(T*).
The DLValue ctor makes sure the LL pointer and the D type are compatible.
2016-08-15 17:39:01 +02:00
David Nadlinger
2de6538241 Revert "Check existing runtime function declarations for matching type" 2016-08-15 15:47:19 +02:00
David Nadlinger
94b111c971 Merge pull request #1570 from kinke/runtime_check
Check existing runtime function declarations for matching type
2016-08-15 14:55:18 +02:00
David Nadlinger
5600d0ae00 Merge pull request #1681 from JohanEngelen/invariantinlining
Disable cross-module inlining of functions that call __invariant*.
2016-08-15 14:51:55 +02:00
Martin
a5e5bd1716 Keep _d_newclass() semantics, re-introduce _d_allocclass() instead
And use that one in DtoNewClass(), keeping 3rd party code from breaking.
2016-08-15 13:19:11 +02:00
Johan Engelen
e6a18b2657 Disable cross-module inlining of __invariant.
Resolves #1678.
2016-08-14 00:31:09 +02:00
David Nadlinger
de5680b867 Merge pull request #1656 from kinke/nothrow
Revive #1202 (propagate "nothrow" to LLVM IR)
2016-08-13 23:38:18 +02:00
Joakim
5eef53e994 Differentiate between the soft and hard floating-point ABIs for ARM, to decide
whether to return the address of structs with floating-point numbers in
general-purpose registers.
2016-08-12 13:40:18 +05:30
Martin
cac96fd0e9 Add some more comments for TryCatchFinallyScopes 2016-08-08 23:33:27 +02:00
Martin
963dd722dd Move EH ptr & selector and resume-unwind block to TryCatchFinallyScopes
To properly encapsulate landing pad emission.
2016-08-08 22:43:01 +02:00
Martin
25b186ce2d TryCatchFinallyScopes: Encapsulate unresolved gotos properly 2016-08-08 22:15:23 +02:00
Martin
92e9ad85fc Some minor improvements for gen/trycatchfinally 2016-08-08 22:15:20 +02:00
Martin
7b238f36c8 Move landing pads to the end of the function, in emission order 2016-08-08 01:26:51 +02:00
Martin
7d15ab9ffc Reduce ScopeStack to JumpTargets
Add some comments after this more or less clean separation, and move
callOrInvoke() to FuncGenState.
2016-08-07 21:29:47 +02:00
Martin
73652977e9 Move unresolved gotos from ScopeStack to TryCatchFinallyScopes 2016-08-07 20:32:20 +02:00
Martin
caf5397f6f Extend TryCatchScopes to TryCatchFinallyScopes 2016-08-07 18:45:59 +02:00
Martin
e711deac1b Refactor basic block construction and revise BB order 2016-08-06 22:04:41 +02:00
Martin
583aab933b Remove some more obsolete MSVC EH functions 2016-08-06 04:05:08 +02:00
Martin
fffe86cd2e Introduce try-catch scopes abstraction
Single intended functional change/fix: check ALL active catch blocks in
`isCatchingNonExceptions()`, not just the ones from the innermost
try-catch scope.

The catch bodies of a try-catch scope are now emitted in lexical order
(used to be reversed, last catch block first).
2016-08-06 04:05:08 +02:00
Martin
a4eb01e4e4 Remove obsolete method ScopeStack::currentCatchScope()
It was only used by MSVC EH code which doesn't make use of the catchScopes
stack at all.
2016-08-06 00:10:23 +02:00
Martin
163ba88db9 Restrict nothrow invokes to try blocks catching non-Exceptions
A further optimization for try blocks only catching Exceptions.
2016-08-06 00:10:22 +02:00
Martin
f4a22f232b Propagate "nothrow" to LLVM IR (#1202)
Invoke nothrow callees only in try-blocks with at least 1 catch-block,
otherwise call them directly.

Errors thrown by nothrow callees can thus still be caught inside a
try-catch-statement (and this is apparently required for release builds
too).

Most calls will be direct calls though, and this small change will lead
to substantially less IR as we then skip the clean-ups after an Error.
Proper clean-up when unwinding after an Error seems not to be guaranteed
anyway. There are apparent RAII front-end optimizations for structs with
nothrow dtor - see PR #1656.
2016-08-06 00:10:19 +02:00
Johan Engelen
e95a8472d0 [PGO] For LLVM >= 3.9, let profile-rt set the default filename. This prevents extra stderr messages when overriding the filename using the "LLVM_PROFILE_FILE" environment variable. 2016-08-04 16:35:44 +02:00
David Nadlinger
b0b76d865b gen: Make it obvious IRState is non-copy/movable [nfc]
`this` is passed out e.g. to IRBuilderHelper.
2016-08-03 21:08:29 +01:00
David Nadlinger
9d5bf5a707 gen: Keep case/default body IR blocks in lexical order [nfc]
This makes the IR slightly easier to read, in particular the
PGO lit tests.
2016-08-03 21:07:18 +01:00
David Nadlinger
8fbb0ddbfa gen: Do not store body bb for {Case, Default}Statements in AST
Instead, put the mapping into the function-local codegen state,
where it belongs. As a side-effect of the refactoring, avoids
generating trivial "forwarding" BBs (see `nbb` in old code).

Avoids the issue from GitHub #1638 and similar altogether.
2016-08-03 21:07:18 +01:00
David Nadlinger
6cc93bc8ba gen/ir: Move function body codegen state into separate class
Previously, the transitory state only needed and valid during
generation of the LLVM IR for the function body was conflated
with the general codegen metadata for the function declaration
in IrFunction.

There is further potential for cleanup regarding the use of
gIR->func() and so on all over the code base, but this is out
of scope of this commit, which is only concerned with those
IrFunction members moved to FuncGenState.

GitHub: Fixes #1661.
2016-08-03 21:07:18 +01:00
David Nadlinger
5cf48c2135 gen: Do not store CaseStatement index values in AST nodes
They were only ever used in ToIRVisitor[SwitchStatement] anyway,
so just use a local vector.

The code for emitting the string switch tables was moved and slightly
refactored, but should functionally still be the same.

Really looking forward to easily being able to zip together
two containers for iteration in C++.
2016-08-02 17:32:21 +01:00
Kai Nacke
be63398346 Merge pull request #1653 from JohanEngelen/pgo-icp
[PGO] Add Indirect Call instrumentation and promotion.
2016-07-31 01:53:32 +02:00
kinke
54511869d7 Merge pull request #1647 from JohanEngelen/switchstatebug
Fix ICE upon second codegen pass of the same SwitchStatement.
2016-07-30 21:19:44 +02:00
Johan Engelen
de86a0a358 [PGO] Generalize value profiling code. 2016-07-29 21:10:43 +02:00
David Nadlinger
566923b407 Merge pull request #1609 from kinke/sliceAssign
Fix issue #1608
2016-07-29 17:07:50 +01:00
Johan Engelen
12431ac5f4 [PGO] Add Indirect Call instrumentation and promotion. 2016-07-29 14:59:21 +02:00
kinke
b65e289e06 Merge pull request #1646 from JohanEngelen/bestdebugfix
Fix debuginfo generation for the local variable frame for a function with nested functions
2016-07-28 22:29:45 +02:00
Martin
54cab47890 Revise DtoAssign() 2016-07-28 01:03:53 +02:00
Martin
a14e31bd94 Attempt to fix issue #1608 2016-07-28 01:03:42 +02:00
Johan Engelen
c6ba2dc29b Fix a few clang warnings. [NFC] 2016-07-27 20:21:02 +02:00
Johan Engelen
51af7bf596 Fix ICE upon second codegen pass of the same SwitchStatement.
We should not store codegen state into the AST and the variables touched in this commit should be moved out of the AST. Added a TODO item for it.

Resolves #1638
2016-07-27 17:50:28 +02:00
Johan Engelen
197b63a04f Fix debuginfo generation for the local variable frame for a function with nested functions.
Declare debuginfo directly on the GEP instead of on the frame alloca+offset, . An explicit DW_OP_deref is necessary (tested in LLDB).

Resolves an ICE introduced by PR #1598.
2016-07-27 16:57:47 +02:00