Commit graph

89 commits

Author SHA1 Message Date
Martin Kinkelin
406e469e99
Merge pull request #3832 from kinke/fix_compilability
Fix little compilability regression
2021-09-18 02:39:40 +02:00
Nicholas Wilson
1568d0cdca
Fix compilation with LLVM 14 (#3822) 2021-09-17 16:41:49 +02:00
Martin Kinkelin
369cfd13ce Adapt to TY enum class 2021-09-07 16:51:19 +02:00
Martin Kinkelin
49affcffb2
Fix issue #3496 - missing IR declarations for some fwd-declared functions (#3503)
Whenever we need an IR function, we'd better make sure it exists. Handle
that in DtoCallee(), by invoking DtoDeclareFunction() by default,
instead of the previous DtoResolveFunction() + DtoCallee() combo.
DtoResolveFunction() usually declares the function, but somehow doesn't
for abstract and body-less functions.
2020-07-13 21:49:41 +02:00
Martin Kinkelin
834f666ce5
Raise min LLVM version to 6.0 (#3493) 2020-07-13 20:42:50 +02:00
Ivan Butygin
cbeb2b45d6
@dynamicCompileEmit attribute (#2747) 2018-06-26 21:59:02 +03:00
Martin Kinkelin
d681ce2825 Fix warning wrt. initialization order 2018-06-01 21:06:44 +02:00
Martin Kinkelin
92913d4c08 Store front-end D function type in IrFuncTy
As we do for IrFuncTyArg. We'll need access to the front-end linkage for
the Posix ABIs too in order to implement indirect-by-value passing of
non-PODs for `extern(C++)`.
2018-05-30 22:41:48 +02:00
Ivan
42f283c221 D dynamic compilation support 2017-08-27 17:42:55 +03:00
Martin
1fb269f940 Drop support for LLVM < 3.7 2017-07-16 02:18:00 +02:00
Johan Engelen
9e394e4f99 Fix LLVM 5.0 build. (#2050)
llvm::AttributeSet was renamed to llvm::AttributeList
2017-03-29 22:26:17 +02: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
Johan Engelen
cd3ae57d14 Implement -ffast-math.
Resolves #1874.
2016-12-14 12:27:45 +01: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
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
Elie Morisse
302d71a9de MSVC: Attach !dbg info to _d_eh_enter_catch, _d_enter_cleanup and _d_leave_cleanup calls. 2016-07-03 16:46:51 -03:00
Johan Engelen
4a7a5de382 Fix initialization order warning. 2016-06-20 17:28:34 +02:00
Johan Engelen
e0d9c58443 [PGO] Add PGO to LDC. Supported for LLVM >= 3.7
Add the commandline options -fprofile-instr-generate[=filename] and -profile-instr-use=filename
-fprofile-instr-generate
-- Add instrumentation on branches, switches, and function entry; uses LLVM's InstrProf pass.
-- Link to profile runtime that writes instrumentation counters to a file.
-fprofile-instr-use
-- Read profile data from a file and apply branch weights to branches and switches, and annotate functions with entrycount in LLVM IR.
-- Functions with low or high entrycount are marked with 'cold' or 'inlinehint'.

The only statement type without PGO yet is "try-finally".

A new pragma, `pragma(LDC_profile_instr, [ true | false ])`, is added to selectively disable/enable instrumentation of functions (granularity = whole functions).

The runtime library ldc-profile-rt is a copy of LLVM compiler-rt lib/profile. It has to be exactly in-sync with the LLVM version, and thus we need a copy for each PGO-supported LLVM (>=3.7).
import ldc.profile for a D interface to ldc-profile-rt (for example to reset execution counts after a program startup phase).

The instrumentation data is mainly passed on to LLVM: function-entry counts and branch counts/probabilities. LDC marks functions as hot when "execution count is 30% of the maximum function execution count", and marks functions as cold if their count is 1% of maximum function execution count.

The source of LLVM's llvm-profdata tool is hereby included in LDCs repository (different source for each LLVM version), and the binary is included in the install bin folder.
The executable is named "ldc-profdata" to avoid clashing with llvm-profdata on the same machine. This is needed because profdata executable has to be in-sync with the LLVM version used to build LDC.

Maintenance burden: for trunk LLVM, we have to keep ldc-profile-rt and llvm-profdata in sync. There is no diff with upstream; but because of active development there are the occasional API changes.
2016-06-20 17:28:22 +02:00
Johan Engelen
53a14b325b Add per-function FastMathFlags and apply them upon function codegen. 2016-05-22 19:56:56 +02:00
Martin
9109075b5f Enable MSVC EH for Win64 2016-03-16 19:45:35 +01:00
Rainer Schuetze
03e7834a49 cleanup obsolete changes 2016-03-13 17:27:56 +01:00
Rainer Schuetze
1f41496326 fix compilation after merge 2016-03-13 17:27:56 +01:00
Rainer Schuetze
d8bbc0491d eh unwinding: don't alloc data in parent frame, just use nullptr for now 2016-03-13 17:27:55 +01:00
Rainer Schuetze
2a86b7250a replace _d_skipCleanup var with callbacks _d_enter_cleanup, _d_leave_cleanup 2016-03-13 17:27:54 +01:00
Rainer Schuetze
858128a540 - add a global condition to cleanup pads to avoid them being inferred as "noreturn" by the optimizer
- do not inline functions into the cleanup funclets, it can break exception handling
- even if no var given, retrieve the caught exception to pass it to _d_eh_enter_catch
2016-03-13 17:27:53 +01:00
Rainer Schuetze
5b22904ff9 use catch-all and rethrow instead of cleanup pads, they don't work completely the same as C++ 2016-03-13 17:27:53 +01:00
Rainer Schuetze
73ab5f4fee inside a cleanup block, convert "unreachable" to a branch to "cleanupret" 2016-03-13 17:27:51 +01:00
Rainer Schuetze
5dabf78c7b fix MSVC-EH again, disable inlining and tail call optimization for functions with EH 2016-03-13 17:27:51 +01:00
Rainer Schuetze
aad27069ca MSVC/x86 EH support using __CxxFrameHandler3 personality 2016-03-13 17:27:51 +01: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
Martin
b9f7d2b499 Normalize signatures of EH runtime functions 2015-12-04 15:07:47 +01:00
Johan Engelen
70a6e73188 Cleanup runtime fwd decls and use ABI functiontype rewriting 2015-11-22 01:27:26 +01:00
David Nadlinger
2401554bec Small landing pad code refactoring
Now the resume unwind block isn't literally created in between
two other, unrelated lines – I must have made a mistake when
resolving a merge conflict or something like that before.
2015-11-03 00:48:12 +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
52532985a9 IR source directory: use C++11 inline-initialization in headers 2015-11-01 19:30:04 +01:00
Martin
2d959ea540 Make use of C++11 range-based for
Should be available now that support for LLVM < 3.5 has been dropped.
2015-11-01 14:49:04 +01: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
93158caca8 Respect alignments of captured variables when building nested context LL struct 2015-10-18 23:25:37 +02:00
David Nadlinger
ed406f3501 IrFunction: Remove some unused variables 2015-08-31 17:59:36 +03:00
David Nadlinger
2b77da4e2e Do not execute nested finally block twice
GitHub: Fixes #1054.
2015-08-31 17:57:42 +03:00
David Nadlinger
d25dee7f89 irfunction/ScopeStack: Unify style, add comments (NFC) 2015-08-21 20:42:51 +02:00
David Nadlinger
db8f0fd8e2 Coalesce last catch mismatch block with unwind resume block if possible
Makes IR a bit more compact.
2015-08-19 19:56:39 +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
f54e70ede9 Fix memory leak. 2015-07-22 02:00:09 +02:00
Martin
6fefec5a07 Don't destruct a temporary if its constructor throws. 2015-07-19 01:01:04 +02:00
Martin
b9c77c266a Restore toElemDtor() functionality. 2015-07-18 17:17:26 +02:00
Martin
cf52b53888 Move temporaries-related state from ToElemVisitor to FuncGen. 2015-07-18 13:34:26 +02:00