Commit graph

168 commits

Author SHA1 Message Date
Martin
1fb269f940 Drop support for LLVM < 3.7 2017-07-16 02:18:00 +02:00
Martin
da469fdc26 Make inlining threshold customizable via (existing) -inline-threshold
By letting LLVM set up the inlining params (taking into account
`-inline-threshold`) instead of hardcoding them.

The old hardcoded thresholds were identical to the LLVM 3.9 defaults, but
they changed in LLVM 4.0:

* optLevel > 2: 275 => 250
* -Os: 75 => 50
* -Oz: 25 => 5

Apparently also fixes issue #2161.
2017-06-25 13:57:21 +02:00
Johan Engelen
22b1accb59 Replace -sanitize with -fsanitize and add -fsanitize-coverage. (#2149)
This reworks the sanitizer interface to be identical with Clang's.
What's left to do is pass the correct runtime libraries to the linker.
2017-06-15 17:19:21 +02:00
Johan Engelen
2f48a468ca Set PassManagerBuilder::PrepareFor(Thin)LTO. (#2157)
Fixes issue #2155
2017-06-10 13:26:23 +02:00
Johan Engelen
058d574f6b Add indirect call promotion pass when PGO info is available. (#2156)
This pass was apparently implicit in LLVM < 5.0. Fixes test PGO/indirect_calls.d with LLVM 5.0.
2017-06-06 16:28:23 +08:00
David Nadlinger
747f7a3dfa clang-format files touched in d01a91f7 [nfc]
Some housekeeping on files that recently saw large changes anyway.
2017-05-24 21:35:40 +01: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
d01a91f755 Allow multiple occurrences for almost all command-line flags
Except for `-sanitize` and `-cache-prune*`.
2017-05-23 20:53:57 +02:00
Martin
84e74e3932 Rework LDMD command-line translation and add -verrors-spec
Simplify LDMD quite a bit by translating the few different command-line
options directly in-place. This puts some more stress onto LDC's
command-line parsing, especially due to multiple occurrences of a single
Boolean option (e.g., '-o-') or mixtures of `-m64` and `-m32` etc. for
dmd-testsuite.

Also add new command-line option `-verrors-spec` showing gagged errors
(DMD's equivalent is `-verrors=<spec|limit>`) and sync the usage text with
DMD. LDMD now also recognizes `-h` (and `/?` on Windows).
2017-02-06 01:17:09 +01:00
Johan Engelen
bb24fb2816 Add LTO support (full and thin), with -flto=thin|full.
LTO needs linker support: I am only aware of support on OS X and Linux (through the LLVMgold plugin).

Resolves #693
2016-11-09 14:30:13 +01:00
Rainer Schuetze
0b55bd21d2 fix build against LLVM master: clEnumValEnd removed 2016-10-12 23:55:59 +02:00
Johan Engelen
f6919e3fb6 ir2obj cache: Add all cmdline args to the hash, unless we are certain they can safely be ignored for ir2obj hashing. 2016-10-06 12:03:44 +02:00
David Nadlinger
d8249bb2e1 Merge pull request #1737 from JohanEngelen/disablecross
Only enable cross-module inlining when explicitly set on the commandline.
2016-09-08 22:18:42 +01:00
Johan Engelen
4991bc0743 Fix LLVM 4.0 compile. 2016-09-04 14:40:39 +02:00
Johan Engelen
55a8097736 Only enable cross-module inlining when explicitly set on the commandline.
In particular, this disables cross-module inlining of `pragma(inline, true)` functions.
2016-09-04 11:38:12 +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
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
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
cb4b77d4d0 Fix LLVM3.9 build. 2016-06-20 17:28:29 +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
David Nadlinger
ab96e1d166 Document what -O4/-O5 are actually doing (-O3) 2016-05-22 19:21:55 +01:00
Kai Nacke
8391626ddd Remove PassNameParser (may be breaking some command lines!)
This PR removes the command line option which adds the pass names as additional
command line options. This code prevents compiling for AArch64 (since LLVM 3.7)
and ARM (since LLVM 3.8). Recommendation on LLVM list was to use the PassNameParser
only in test tools but not in a production compiler.
2016-03-12 16:58:21 +01:00
Martin
2dfa5e8569 Some more cosmetic fixes
Found by searching for lines > 80 chars.
2015-11-05 19:12:32 +01:00
David Nadlinger
75b3270a19 optimizer: Do not disable codegen opt if -g is given
It has been a long time since this actually caused problems. If some
start to show up again, we should preferrably come up with a local fix
instead of globally disable everything (which is horrible for -O3 -g
builds).
2015-11-03 11:35:06 +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
kai
9d3dd1f609 Add true value of "isOptimized" to Dwarf debug info. 2015-05-31 21:32:12 +02:00
kai
4db0123bb7 Implement FlagParser using llvm:🆑:generic_parser_base.
This approach is easier and requires less code. With some template foo
the BoolOrDefaultAdapter is not required.

This solutions applies to previous LLVM versions, too.
2015-04-25 21:47:30 +02:00
kai
66bf03b96b LLVM 3.7: DataLayoutPass is gone.
DataLayout is now non-optional at the module. Therefore
there is no need for a separate DataLayoutPass.
2015-03-06 17:13:00 +01:00
Kevin Brogan
d8f4a2758a Trigger a travis rebuild 2015-02-17 02:09:14 -08:00
unknown
e56ef8b86e copy paste error fix 2015-02-16 15:27:19 -08:00
unknown
674b614807 Update of PassManager interface to match the corresponding deprecation in LLVM's trunk for 3.7 2015-02-16 15:11:42 -08:00
kai
197c32e118 LLVM 3.7: Use new TargetMachine.getTargetIRAnalysis() analysis pass.
This replaces the TargetMachine.addAnalysisPasses() method.
2015-02-04 07:46:14 +01:00
kai
e3e10a0a86 LLVM 3.7: Add changes for TargetLibraryInfo and DataLayout.
The TargetLibraryInfo class is now a wrapper. The real implementation
is TargetLibraryInfoImpl.

The TargetMachine can be asked for the DataLayout (like in all other
supported versions except 3.6)
2015-01-30 08:08:14 +01:00
Kai Nacke
18118d724a Add support for LLVM 3.7
The branch for LLVM 3.7 was created this week.
LLVM trunk is now 3.7.
2015-01-18 21:45:13 +01:00
kai
bef163f559 Fix latest LLVM 3.6 changes 2014-09-19 06:49:34 +02:00
kai
f8a53ab3dc Merge branch 'merge-2.064' into merge-2.065
Conflicts:
	runtime/druntime
2014-03-12 18:27:43 +01:00
kai
6442d79b8b Finally enable the vectorizer (at least in LLVM 3.5).
It still requires verification if this works with LLVM 3.4. Problem was the changed
initialisation of passes in LLVM 3.4/3.5.
2014-03-12 17:12:25 +01:00
kai
9156601d76 Add code for the changed DataLayoutPass in LLVM 3.5 2014-03-10 06:54:59 +01:00
kai
2f2fa92df3 Fix includes for LLVM 3.5 2014-03-07 06:40:39 +01:00
Kai Nacke
fe39da53e3 Merge of 2.065.0-b3.
The new visitor class is used for IR generation. This removes some modifications from DMD source.
2014-02-10 08:47:25 +01:00
kai
cd9e468201 Enable command line option -disable-simplify-libcalls for LLVM 3.4+. 2014-02-04 18:07:46 +01:00
kai
aaaca39a4e Enable vectorizer with LLVM 3.4+.
The missing initialization code disables the vectorizer.
2014-02-04 07:18:32 +01:00
Kai Nacke
ea9c996dcd Fix new signature of verifyModule() in LLVM 3.5. 2014-01-19 12:36:42 +01:00
Kai Nacke
c14e065138 Fix the LLVM 3.5 build.
Some classes were moved into IR folder.
2014-01-13 17:08:43 +01:00