Introduce a hidden `-dwarf-version=<uint>` switch to support old gdb versions
used by Travis. Older versions only supporting DWARF-2 and/or not supporting
TLS correctly are detected in dmd-testsuite's CMakefile.
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.
There is a LLVM 3.7 command line option named color. This option is
only available if ldc is linked against shared LLVM libraries.
Because the LDC color option uses a FlagParser simple renaming does
not work. The solution is now:
- Rename LLVM option `color` to `llvm-color` and hide this option
- Dynamically create the LDC option `color`
This finally enables building with shared LLVM libraries.
Adds a new command line option -mabi= and uses the value to compute
the ABI to use. Adds the ABI to linker and assembler invocation, too.
Allows consistent invocation of the whole tool chain.
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.
The new command line option conflicted with a builtin LLVM 3.0
one. The functionality will be added back in after the 0.11.0
release branch has been created.
This reverts commit 6a1bc70bd7 and
subsequent fixes.
Even though this argument design conflates two separate concepts
(ABI and hardware/software implementation), I chose to go
with it since users are liekly know it from GCC and the
combination of softloat operations with hardfloat ABI makes
no sense.
I didn't implement it for old LLVM versions, as ARM EABI
exception handling requires LLVM 3.3+ anyway, without which
LDC would be useless anyway.