Commit graph

132 commits

Author SHA1 Message Date
Martin Kinkelin
98a066ea30
Ignore -enable-cross-module-inlining if inlining is generally disabled (#3664)
People use `dflags "-enable-cross-module-inlining" platform="ldc"`
in their dub.sdl files; default and debug builds without -O thus
incur a superfluous compile-time cost for no benefit.
2021-02-13 00:09:01 +01:00
Martin Kinkelin
cacdc46154 Use LLVM 10+ setFunctionAttributes()
Which supports more cmdline options in the meantime than what we have
been supporting manually, and should be future-proof, similar to
InitTargetOptionsFromCodeGenFlags().
Attributes are only set if explicitly specified in the cmdline (and not
already present in the function's existing attributes).

This started out as a workaround for not being able to determine whether
the user has explicitly set -frame-pointer in the cmdline with LLVM 11,
and ended with having to touch more than I wanted. An *enabled*
-ffast-math flag (from us, not LLVM) overriding LLVM's
-enable-unsafe-fp-math, but e.g. -ffast-math=false NOT overriding was/is
one of the quirks.
2020-09-26 01:04:50 +02:00
Martin Kinkelin
834f666ce5
Raise min LLVM version to 6.0 (#3493) 2020-07-13 20:42:50 +02:00
Johan Engelen
a6b4757b79 Sort includes and fix SanitizerCoverage pass call 2019-10-16 22:53:46 +02:00
Martin Kinkelin
030123410a Add support for LLVM 9.0.0
Including some of Nicholas' fixes in #3144.
2019-09-25 03:42:18 +02:00
Martin Kinkelin
6015278dfa Restore -disable-fp-elim option for LLVM 8+ 2019-03-02 19:54:36 +01:00
Martin Kinkelin
306bda36fd Adapt to latest LLVM 8 changes 2019-03-02 19:54:36 +01:00
Johan Engelen
354e45737b
Support LLVM 9 (trunk) (#2983)
* LLVM 9: fix sanitizer pass renaming

* Add LLVM 9 to intrinsics in druntime

* LLVM 9: fix commandline option change from `-disable-fp-elim` to -frame-pointer=`

Resolves issue 2980
2019-01-25 17:58:26 +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
5c24f60cf9
Raise min LLVM version to 3.9 (#2872) 2018-10-15 22:31:59 +02:00
Johan Engelen
e8e28b33b2 PGO: Add IR-based PGO. 2018-01-16 00:02:49 +01:00
Johan Engelen
3ec79179b4 PGO: refactor such that there can be IR-based and frontend-based PGO. 2018-01-15 23:59:14 +01:00
Martin Kinkelin
ca6472c3b0
Don't eliminate frame pointer by default at -O0 (#2483)
Fixes issue #2480.
2018-01-13 13:49:10 +01:00
Johan Engelen
f86e33f1d0
Remove LDC_WITH_PGO. (#2476)
It's no longer needed, all our builds have it set to true.
2017-12-29 23:54:32 +01:00
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