Commit graph

298 commits

Author SHA1 Message Date
Martin Kinkelin
69269f3bd9 Refactor IRScope handling
Replace the stack of IRScopes, each with its own IRBuilder, by directly
tampering with the state of a single IRBuilder.

This seems like the most feasible way to account for a breaking change
in LLVM 11, disallowing IRBuilder from being copied.
2020-09-26 01:04:50 +02:00
Johan Engelen
e628a0a7d0
Add missing UnrolledLoopStatement to PGO region count instrumentation and calculation. Also add extra precautions to catch this problem earlier in the future. (#3524)
Fixes issue #3375
2020-07-30 20:59:09 +02:00
Johan Engelen
fd9d23139e
Fix PGO instrumentation crash for final switch(enum) statements together with -release. (#3512)
This change includes checking of whether there is a default statement when using `case <variable>:` (LLVM IR switch instruction cannot be used), although that is currently not allowed in the D language. Therefore there is no testcase that covers that.

See GH issue #3375
2020-07-22 11:42:02 +02:00
Martin Kinkelin
f70feb1354
Fix return statements: Don't access memory from destructed temporaries (#3426)
Our version of https://issues.dlang.org/show_bug.cgi?id=20809.
2020-05-09 21:26:26 +02:00
Martin Kinkelin
684acd6a3f Improve check for multiple entry point definitions
* Extend the error message, closely following DMD. Tested by
  fail_compilation/fail5634.d.
* Check across all compiled modules, not on a per-object-file basis.
  That's what DMD does too.
* Apply the implicit `return 0` / void -> int return type promotion to
  all D/C main functions, not just the first one. This prevents some
  potential follow-up crashes.
2020-04-28 01:37:49 +02:00
Martin Kinkelin
ebd359273d druntime: Switch from __asm to GCC-style asm syntax 2020-02-25 01:19:25 +01:00
Martin Kinkelin
298898a0a7 Add support for GCC/GDC-style inline asm syntax 2020-02-15 23:58:13 +01:00
Martin Kinkelin
26673c174f
Refactoring: Replace Expression::op check followed by static cast to Expression::is<ExpressionType> (#3141)
This may negatively impact performance, as the (final, i.e.,
non-virtual) Expression::is... family is implemented in D and not
available inline in the C++ headers.
2020-01-15 12:54:05 +01:00
Martin Kinkelin
4ac7f0554b Adapt to frontend refactorings 2019-12-22 16:29:45 +01:00
Stefanos Baziotis
94743b90fc Disable dead code when an if/else if condition is constant (#3134) 2019-11-05 18:33:25 +01:00
Martin Kinkelin
8fd69da8fb Make all DtoGEP helpers use implicit inbounds
Single functional change: always emit inbounds when computing the base
pointer of a SliceExp.
2019-09-10 22:36:25 +02:00
Martin Kinkelin
8da4e6f9cf
Merge pull request #3093 from kinke/merge-2.087
Upgrade front-end & libs to v2.087.1+
2019-08-06 22:21:18 +02:00
Martin Kinkelin
1608105681
Fix ICE when returning a void expression (#3095)
Fixes #3094, a regression introduced in v1.16 due to AST changes.
2019-07-01 20:35:39 +02:00
Martin Kinkelin
e52199469f Upgrade front-end & libs to v2.087.0-beta.1 2019-06-21 15:39:45 +02:00
Martin Kinkelin
0dbd7ded60 Adapt to switch error lowering to object.__switch_error!()
The _d_switch_error function has been removed from druntime.
2019-04-23 22:41:44 +02:00
Martin Kinkelin
5e93ed0dfd Upgrade front-end & libs to v2.085.0-beta.1 2019-03-01 18:19:00 +01:00
Martin Kinkelin
6c19cfeae0 Port https://github.com/dlang/dmd/pull/8997 2018-12-09 01:19:51 +01:00
Martin Kinkelin
4a23399236 Aim for consistent #includes (order + dir prefix)
I surely missed a few.
2018-10-20 16:19:46 +02:00
Martin Kinkelin
7776c4081b Upgrade frontend & libs to v2.083.0-beta.1 2018-10-20 16:19:46 +02:00
Elie Morisse
841146644b Debug info: emit llvm::DIModule and llvm::DIImportedEntity for modules and imports
Matches GDC's DWARF output and enables access to global and imported symbols from GDB.
2018-10-15 22:48:03 +02:00
Martin Kinkelin
e0611c3114 Adapt to now subtyped class AsmStatement 2018-08-18 00:33:48 +02:00
Martin
d8f60d2f5c Redirect access to object.d type declarations through gen/runtime
Not all type declarations yet (e.g., some TypeInfo subtypes are still
accessed directly), but those already wrapped as LazyType in the
gen/runtime.cpp module (with check and proper error msg in case object.d
doesn't contain a required declaration).
2018-04-04 19:59:10 +02:00
Martin
1b8a3b9d7d Adapt to frontend injecting implicit 'return 0' for betterC main
This fixes lit-test codegen/betterC_typeinfo.d.
2018-02-25 01:25:37 +01:00
Martin
197e65efde Merge branch 'master' into merge-2.078
Conflicts:
	driver/main.cpp
	gen/cl_helpers.h
	gen/declarations.cpp
	runtime/druntime
	tests/d2/dmd-testsuite
2018-01-20 11:20:17 +01:00
Martin
27deb2ff8c Get rid of obsolete gen/llvmcompat.h
Not needed anymore since C++11.
2018-01-12 20:20:47 +01:00
Martin
b83780538f Adapt to new string-switch lowering
Now all done in the front-end, no need for us to handle it manually
anymore. This also fixes tests/semantic/dcompute.d.
2018-01-07 01:43:12 +01:00
Martin
cfad799f48 Merge 2.078.0 front-end and stdlibs 2018-01-06 01:39:18 +01:00
Martin
30b858781b -betterC: Use C assert function
Instead of druntime's _d_assert[_msg], _d_arraybounds and
_d_switch_error.

Tested by dmd-testsuite's runnable/cassert and compilable/betterCarray.
2017-10-25 00:38:05 +02:00
Martin
2616261fd2 Revise all LDC-specific errors/warnings/deprecs and insert backticks
For DMD's new syntax highlighting. I grepped in all .{h,cpp} files only.
2017-08-03 22:53:49 +02:00
Martin
45eacd0f32 Merge branch 'master' into merge-2.074
Conflicts:
	runtime/druntime
	runtime/phobos
2017-06-10 03:15:11 +02:00
Martin
383c2d3a59 Range-ify usages of front-end Arrays 2017-06-04 00:29:44 +02:00
kinke
151e83dc6b Fix C++ warnings (#2140) 2017-05-26 13:45:15 +02:00
Nicholas Wilson
ae6ff33fc1 [dcomptue] codegen (#2126)
* code generation

* simplify logic

* apply clang-format

* Undo completely inane choice by clang-format

* Guard the use of the command line args.
2017-05-24 08:55:32 +08:00
Martin
15e565e4f4 Support cast runtime variables as case expressions
Fixes compilable/b17111.d, see dlang/dmd@84fcc60.
2017-04-22 21:53:35 +02:00
Martin
e45bb9709d Don't declare IfStatement::match separately anymore
It's apparently rewritten to a CommaExp if-condition now:

`if (auto x = ...)` => `if (auto x = ..., x)`
2017-01-29 23:23:03 +01:00
Ivan Butygin
a26bfc1223 Refactor code to hide direct IrFunction->func usage and add convenient functions (#1911) 2017-01-17 22:40:32 +01:00
David Nadlinger
9f4cdb5168 Remove unnecessary semicolon [nfc] 2016-11-27 04:10:03 +00:00
LemonBoy
596fc82254 Implement -finstrument-functions.
Closes #1839.
2016-11-06 23:17:04 +01:00
Johan Engelen
8d84cc7f8c PGO: remove unnecessary instrumentationn BBs for switch statements in instrumentation-disabled functions. 2016-09-27 12:19:24 +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
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
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
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
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