Commit graph

240 commits

Author SHA1 Message Date
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
David Nadlinger
24048025c7 gen/statements: Always create new "after return" block for unreachable code
This makes sure we do not emit IR into the return bb after the terminator
instruction, which is invalid.

Also improved variable names and comments for clarity.

GitHub: Fixes #1582.
2016-06-25 00:27:18 +01:00
David Nadlinger
92d6eb57a5 gen/statements: clang-format again [nfc] 2016-06-25 00:27:07 +01: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
Martin
de9149f1b6 Remove getLVal() from DValue and add DtoL/RVal() overloads 2016-06-13 22:30:16 +02:00
Martin
0c0c1ecaf5 Rename DVarValue to DLValue 2016-06-13 22:30:15 +02:00
Martin
963a10b225 Let DValue types handle memory-only types consistently
I.e., disallow memory-only values from being represented as DImValues
and disallow getRVal() for such types instead of returning the address.
2016-06-13 22:30:14 +02:00
David Nadlinger
c9c4b7cc42 Fix string switch table sorting
GitHub: Fixes #1406.
2016-04-03 02:48:43 +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
3adf19c50d _d_enter_catch can throw, so it might have to be invoked 2016-03-13 17:27:55 +01:00
Rainer Schuetze
18b1492733 avoid outlining catch handler 2016-03-13 17:27:55 +01:00
Rainer Schuetze
83368904d1 - add classinfo argument to _d_eh_enter_catch 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
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
956061c3c7 Revise DtoGEP() helpers and mark most GEPs inbounds 2015-12-14 00:18:15 +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
c9c854f664 eh: Do not use GC for _d_exception records 2015-11-03 00:53:34 +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
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
David Nadlinger
431c14615e Remove llvm::Value address in log 2015-09-26 15:24:36 +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
Martin
a721b4f823 Revise DtoRawAlloca() alignments 2015-09-25 15:16:28 +02:00
David Nadlinger
78ddb15690 Fix throwing inside catch (should not target later catches of same try) 2015-09-14 09:01:17 +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
David Nadlinger
16ce842122 OnScopeStatements are not supposed to make it to the glue layer 2015-08-16 22:59:41 +02:00
David Nadlinger
06d07dfefe statements: Remove some commented code 2015-08-16 20:42:40 +02:00
David Nadlinger
d2135d4ade Fix more duplicate static array postblit calls 2015-07-28 02:12:45 +02:00
David Nadlinger
0922254dd1 Directly emit IR into same llvm::Module instead of using Linker
GitHub: Fixes #970.
2015-06-14 21:36:35 +02:00
Kai Nacke
8618c73177 Merge branch 'master' into merge-2.067 2015-06-05 02:56:49 +02:00
Kai Nacke
227f16bcce DebugInfo: Better location for automatically appended return.
If function main() has return type void then a 'return 0;' is
automatically appended to the statements. Set the end of the
function as the location of this statement. This helps with the
debug information in LDC.
Don't do it at a more global level because disturbs the coverage
code.
2015-06-05 02:52:13 +02:00
Kai Nacke
cddb59f7b7 Merge branch 'master' into merge-2.067 2015-06-04 22:02:52 +02:00
Kai Nacke
b301407f9c DebugInfo: Use the IRBuilder to create a ret instruction.
This ensures that a previous set debug location will be set on the
return instruction.
2015-06-04 21:22:38 +02:00
Kai Nacke
80acadc841 Merge branch 'master' into merge-2.067 2015-06-04 20:48:38 +02:00
Kai Nacke
104e7c991f DebugInfo: Remove most calls to EmitFuncEnd()
Debug information is based on static lexical blocks. Most calls to
EmitFuncEnd() are done if control flow reaches the end of the
function which is quite different.
2015-06-04 20:19:54 +02:00
Kai Nacke
45ec6a0512 Merge branch 'master' into merge-2.067 2015-06-04 19:07:28 +02:00
Kai Nacke
0f86de548c DebugInfo: EmitStopPoint() now has a Loc parameter. 2015-06-04 19:04:23 +02:00
Kai Nacke
ac7f8c70f8 Merge branch 'master' into merge-2.067
Conflicts:
	dmd2/mars.h
	driver/ldmd.cpp
	gen/module.cpp
2015-04-08 22:23:50 +02:00
Johan Engelen
505f18ca2a Add coverage analysis ("-cov=...") to ldc2 2015-04-07 22:11:02 +02:00
kai
0551f613e4 Remove last traces of AsmBlockStatement 2015-03-01 17:33:08 +01:00
kai
f61327c149 Replace AsmBlockStatement with CompoundAsmStatement. 2015-03-01 16:40:44 +01:00
Alexey Prokhin
ac2524d129 Remove old unused declarations 2014-10-05 16:55:23 +04:00