Commit graph

2765 commits

Author SHA1 Message Date
Johan Engelen
cb15d21996 Fix evaluation order of bitwise operators 2016-07-12 23:01:34 +02:00
Johan Engelen
cec61a4432 clang-format [NFC] 2016-07-12 23:01:10 +02:00
Johan Engelen
57b21d10d4 Fix github issue 1611 2016-07-10 00:42:00 +02:00
Johan Engelen
df10fca7fa Clarify code (NFC) 2016-07-07 21:25:42 +02:00
David Nadlinger
75e1573cb2 Merge pull request #1577 from JohanEngelen/inlining
Implement cross-module inlining
2016-07-04 21:32:28 +01:00
Martin
12ff7ef803 Let special __result variable be an alias for sret
So for functions using sret and featuring an out contract, we save an
additional alloca + memcpy by using the sret pointer as storage.
2016-07-04 19:47:55 +02:00
Martin
1760e261db Move special __result variable into return value (no postblit)
This fixes issue #1335.
2016-07-03 21:58:10 +02:00
Martin
ed70c12b06 Enable in-place construction for static array literals 2016-07-03 00:23:08 +02:00
Martin
08fa2f093c Enable in-place construction for struct literals 2016-07-03 00:23:03 +02:00
Johan Engelen
f2c3ed4cce Separate inlining-heuristic code into its own file. Implement a simple statement-counting inlining heuristic. 2016-07-02 17:08:48 +02:00
Johan Engelen
7919805eb4 Disable cross-module inlining for LLVM < 3.7. 2016-07-02 17:08:48 +02:00
Johan Engelen
7ed5a09dc3 Fixes and improvements to cross-module inlining code. 2016-07-02 17:08:48 +02:00
Johan Engelen
a3f0678283 Fix inlining problem: reverse order in which module array is codegenned. 2016-07-02 17:08:48 +02:00
Johan Engelen
2e9b196c09 Force codegen for templated functions with pragma(inline, true) 2016-07-02 17:08:47 +02:00
Johan Engelen
0eb8689006 Implement cross-module inlining (with and without pragma). 2016-07-02 17:08:47 +02:00
Johan Engelen
b8048be6e4 Implement same-module pragma(inline, {true|false}). 2016-07-02 17:08:47 +02:00
Martin
364d1e9acd Be less restrictive in toDirectSretConstruction() 2016-07-02 12:52:29 +02:00
Martin
50b89a47fe Extract helper toDirectSretConstruction() 2016-07-02 12:52:28 +02:00
Martin
cdb817633e Rename IrFunction::retArg to sretArg 2016-07-02 12:52:28 +02:00
Martin
879fb97d56 Rename retvar to sretPointer 2016-07-02 12:52:21 +02:00
Martin
07cad0f20a Fix the actual issue 2016-06-29 22:41:08 +02:00
Martin
26d0c715d2 Resolve virtual base functions (super.foo()) correctly
Don't perform a vtable lookup for those, resolve them directly instead.
Fixes issue #1450, where calling the base method in the overwritten
method resulted in an infinite loop and corresponding stack overflow.
2016-06-29 20:35:11 +02:00
Martin
82005009e7 Refactor and fix intrinsics for variadic functions
I.e., va_start(), va_copy() and va_arg().
2016-06-28 22:40:14 +02:00
Johan Engelen
dfbb6c5b08 Merge pull request #1589 from JohanEngelen/noinlineSEH
Remove explicit `noinline` call attribute inside SEH catch/cleanup pads.
2016-06-27 21:10:14 +02:00
David Nadlinger
f995fc88ab Merge pull request #1585 from kinke/gh1581
Fix issue #1581
2016-06-27 17:10:31 +01:00
David Nadlinger
5858398ae2 optimizer: Skip adding verifier function pass if -disable-verify is given
This makes the flag useful again for dumping invalid IR.
2016-06-27 15:04:40 +01:00
David Nadlinger
a963e7439b optimizer: Mechanical cleanup [nfc] 2016-06-27 14:53:15 +01:00
David Nadlinger
fbce0be4e0 optimizer: clang-format again [nfc] 2016-06-27 14:45:56 +01:00
Johan Engelen
ccea089f07 Remove explicit noinline call attribute inside SEH catch/cleanup pads.
See https://llvm.org/bugs/show_bug.cgi?id=25162
However LLVM inliner now knows not to inline functions inside cleanup pads and so this is no longer needed. I have tested with clang (trunk) and clang also no longer marks function calls explicitly with noinline: the inliner no longer tries to inline `alwaysinline` functions.

The change is necesary because setting `noinline` conflicts with functions that have `alwaysinline` attribute added (due to `pragma(inline, true)`).
2016-06-27 11:38:06 +02:00
Martin
40fdf7819a Support non-trivial initializers for enums
E.g., non-zero-initialized structs encountered in issue #1581.
2016-06-26 23:29:10 +02:00
kinke
13f522a164 Merge pull request #1588 from kinke/assignSret
AssignExp: Refactor direct construction by rhs call via sret
2016-06-26 21:26:14 +02:00
kinke
a2fdffaf0d Merge pull request #1562 from kinke/dvalue
Continue with DValue refactoring and fix issue #1327
2016-06-26 21:24:43 +02:00
Martin
a3adb403de Fix evaluation/load order of binary operators
Fixes issue #1327 by loading immediately from lvalues resulting from
left- and right-hand sides.
2016-06-26 21:19:06 +02:00
Martin
1c14efffde AssignExp: Refactor direct construction by rhs call via sret 2016-06-26 19:51:57 +02:00
Martin
99384dde9b Tighten NRVO detection for VarDeclarations
The D types of the variable and the right-hand-side of the init AssignExp
must match; this fixes issue #1548.
Don't restrict it to memory-only types anymore though; the sret-check
performed by DtoIsReturnInArg() should suffice and makes more sense to me.
2016-06-25 23:40:58 +02:00
Martin
7fec36b51f Continue with DValue refactoring
* Introduce a DRValue base class to be able to discriminate between
  DLValues and DRValues (e.g., function parameters).
* Let DValue::getRVal() return each DValue's value as DRValue.
  This allows to convert a DLValue to a DRValue, a snapshot of the
  lvalue's current state, while retaining the D type, something we've
  previously lost when returning the low-level rvalue directly.
* Let the DtoR/LVal() helpers be the only way to convert a DValue to a
  low-level value.
2016-06-25 15:33:57 +02: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
bab4f96246 clang-format (NFC) 2016-06-23 20:26:37 +02:00
Johan Engelen
aadb45a946 [PGO] Fix LLVM 3.9 error handling code. 2016-06-20 17:28:34 +02:00
Johan Engelen
8bae926fd4 clang format 2016-06-20 17:28:33 +02:00
Johan Engelen
0f22a88238 Remove unused variables. 2016-06-20 17:28:32 +02:00
Johan Engelen
cb4b77d4d0 Fix LLVM3.9 build. 2016-06-20 17:28:29 +02:00
Johan Engelen
c42e543424 [PGO] If a function is in a comdat group, set the linkage of __profn_ symbol to internal.
Attempt to fix PGO on Windows platform.
2016-06-20 17:28:27 +02:00
Johan Engelen
5ac4832e91 [PGO] Emit profile summary for LLVM >= 3.9 2016-06-20 17:28:27 +02:00
Johan Engelen
91c066b8c1 [PGO] Fix bug with multiple defined MaxFunctionCounts when compiling multiple files with -singleobj. 2016-06-20 17:28:26 +02:00
Johan Engelen
7cce21e498 Remove commented-out remnants from Clang source. [NFC] 2016-06-20 17:28:24 +02:00
Johan Engelen
ebbd2a38d0 [PGO] Remove hot/cold function marking from LDC, because LLVM >= 3.8 does this itself: http://reviews.llvm.org/D15245 . 2016-06-20 17:28:23 +02:00
Johan Engelen
e52ce7dba4 [PGO] Implement correct calculation of region execution count for break label; and continue label;. 2016-06-20 17:28:23 +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