Commit graph

535 commits

Author SHA1 Message Date
Martin
24cecc268c Streamline main() with DMD's (ddmd/mars.d) 2016-08-27 20:40:26 +02:00
David Nadlinger
d47bdb234a gen: Use single ldc.register_dso function for both module ctor/dtor
This reduces the size of a statically linked Phobos-based
Hello World by 11 kB on Linux x86_64.

Also creates a header file for gen/module.cpp, which has been
renamed to "modules" such as not to conflict with the frontend
header file.
2016-08-18 16:28:41 +02:00
Johan Engelen
7bc6512c65 Early merge front-end fixes for Module.semantic.
This eliminates the hidden-virtuals warning flood.

See
https://github.com/dlang/dmd/pull/6001
60f622ff1b
and
https://github.com/dlang/dmd/pull/6038
2016-08-08 19:24:04 +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
Matthias Klumpp
d949688216 Default to PIC code on Linux
Modern Linux distributions have their toolchain generate PIC code for
additional security features (like ASLR).
Since there is no (sane) way to detect whether the toolchain defaults to
PIC code, we simply default to PIC code on all Linux
distributions to avoid linking issues on these OSes.

The relocation model can be switched back to non-PIC code manually at
any time.
2016-08-02 20:55:54 +02:00
Johan Engelen
ae5ffa4c0d Fix LLVM 4.0 build. 2016-07-29 16:57:12 +02:00
Johan Engelen
be54d79966 Revert 4fede9467f 2016-07-29 15:33:41 +02:00
Johan Engelen
4fede9467f Fix LLVM 4.0 build. 2016-07-29 15:32:28 +02:00
Johan Engelen
c3fe8f3fdd Refactor the call to llvm::sys::fs::getMainExecutable.
Taking the address of `main` is UB in C++. Reading LLVM's source, any function address can be used (that's what clang does too).
2016-07-28 14:00:53 +02:00
kinke
dbc9733a05 Merge pull request #1649 from JohanEngelen/warningfix1
Fix a few clang warnings [NFC]
2016-07-28 00:46:53 +02:00
Johan Engelen
c6ba2dc29b Fix a few clang warnings. [NFC] 2016-07-27 20:21:02 +02:00
Johan Engelen
0fcd50fb0d Do the check that gExePath is not a directory (before deleting it) also in release builds. 2016-07-27 19:47:51 +02:00
Martin
436aba77af Fix issue #1621
LLVM's ParseCommandLineOptions() expands response files automatically, but
always uses the TokenizeGNUCommandLine tokenizer, which apparently eats
backslashes.

The solution is to pre-expand the response files into the arguments vector
on the LDC side, and using TokenizeWindowsCommandLine if LDC is built for
Windows.
2016-07-23 15:31:27 +02:00
Johan Engelen
a3f0678283 Fix inlining problem: reverse order in which module array is codegenned. 2016-07-02 17:08:48 +02:00
Rainer Schuetze
9f85baee90 use *W-functions if UNICODE #defined on windows 2016-06-28 08:29:49 +02:00
Johan Engelen
c7e0486205 Add IR-to-Objectcode caching with -ir2obj-cache=<cache dir>. 2016-06-23 19:48:59 +02:00
David Nadlinger
6de981af75 codegen, runtime: Go back to old executable .bss range detection
We had switched to a somewhat simplified implementation Martin
came up with for DMD based on our old one. Unfortunately, that
turned out not to work for certain ld.bfd versions on Linux
(e.g. 2.26.0.20160501), where the .bss section from other shared
objects would be picked up instead.

This reverts commit 08ad4fddb5.

GitHub: Fixes #1534.
2016-06-21 11:25:36 +01:00
Johan Engelen
33a54a9900 [PGO] Fix ldc-profile-rt.lib linking on Windows. 2016-06-20 17:28:35 +02:00
Johan Engelen
20c9f3fbec [PGO] Fix profile-rt linking: put it before Phobos. 2016-06-20 17:28:32 +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
Rainer Schuetze
f9995b1883 fix build against LLVM trunk svn rev 273030 2016-06-18 10:54:23 +02:00
Johan Engelen
ef91385223 Making bitcode file argument errors fatal. 2016-06-10 12:47:46 +02:00
Johan Engelen
404d483c2a Bitcode cmd arguments: fix compilation for LLVM < 3.8, and disable for LLVM 3.5. 2016-06-10 12:43:31 +02:00
Johan Engelen
0aea0df3a7 Add predefined version identifier D_Coverage.
(test upstreamed)
2016-06-09 15:16:36 +02:00
Johan Engelen
d9b267a4be Accept LLVM bitcode files (*.bc) on the commandline and add the code to the first source file on the cmdline (the first emitted module). 2016-06-05 16:07:14 +02:00
Martin
f4ccde3c24 Fix detection of -mtriple/-march in tryGetExplicitTriple() 2016-05-27 21:39:26 +02:00
Martin
9404a1ab43 Use i686 instead of i386 for -march=x86 2016-05-27 16:06:31 +02:00
Martin
789c0935d8 [x86_64] -m32: Use i686 architecture instead of i386
`get32BitArchVariant()` for x86_64 seems to return i386 which is
inconsistent with i686 (Pentium Pro+) for a native 32-bit build.
2016-05-26 15:41:52 +02:00
Johan Engelen
776e32d801 Add experimental -hash-threshold option to hash very long symbol names. 2016-05-24 11:39:08 +02:00
David Nadlinger
f68ebbf1ec Merge pull request #1469 from rainers/multi_config
Allow different configurations in the ldc2.conf
2016-05-23 00:02:34 +01:00
Kai Nacke
de296b90ec LLVM 3.9: llvm::Reloc::Default was removed.
The value is now optional as there is nothing like a default relocation.
2016-05-20 21:17:20 +02:00
Kai Nacke
ffc07566b1 LLVM 3.9: DataLayout.getLargestLegalIntTypeSize() was renamed.
Fixes a compile error with LLVM 3.9. Original by Rainer.
2016-05-19 22:56:33 +02:00
Kai Nacke
cb0f2e7e6a Fix space handling for different paths.
E.g. on my machine LLVM is installed in folder C:\My Program Files\LLVM.

Fixes part of issue #1465. (PR 1466 is required for complete fix.)
2016-05-16 00:12:27 +02:00
Joakim
bf2cb831f3 Add back Android TLS support that was supposedly merged in ee8a832c4 but isn't there for some reason. 2016-05-15 16:44:11 +05:30
Johan Engelen
4515033381 Merge pull request #1470 from JohanEngelen/random_file
Use random output filenames for `-run`.
2016-05-10 13:08:18 +02:00
Johan Engelen
ac23473525 Use random output filenames for -run.
The temporary files created should be unique for parallel processes (e.g. in a test suite where LDC is called in parallel with perhaps same input).
These files will be deleted after execution so their name is not relevant. For better linking errors, the new filenames are created by appending random characters to their name.
2016-05-09 20:14:00 +02:00
David Nadlinger
219758756c Merge branch 'merge-2.071' 2016-05-06 19:24:48 +01:00
Rainer Schuetze
8a563e9d20 update tryGetExplicitTriple to better mimmick command line behaviour 2016-05-01 09:51:55 +02:00
Kai Nacke
0b2d7e7969 Merge remote-tracking branch 'origin/ltsmaster' 2016-04-30 16:35:00 -04:00
Kai Nacke
1cfb6d46ee Do not use -Xlinker for linker options starting with -shared or -static.
This is part of fixing the CMAKE_EXE_LINKER_FLAGS problem of the 1.0 build.
2016-04-30 16:11:02 +02:00
Rainer Schuetze
e92bb482a2 select configuration group by target triple extracted from the command line 2016-04-30 12:28:02 +02:00
Rainer Schuetze
bc1a1b1f9e fix runnable/cppa.d for Windows: C++ interface functions are implemented without thunks, the this pointer is adjusted in the function itself 2016-04-28 23:43:50 +02:00
Kai Nacke
ee8c6b106b Fix merge errors 2016-04-23 14:58:39 +02:00
Kai Nacke
e55823fd09 Merge remote-tracking branch 'origin/ltsmaster' 2016-04-23 11:19:20 +02:00
Rainer Schuetze
eaa9e8130c create our own global context, it's been removed from LLVM
(cherry picked from commit 26a4e2bd13)
2016-04-21 22:34:08 +02:00
Rainer Schuetze
a2c5f15955 implement -transition=* 2016-04-20 23:03:20 +02:00
Joakim
ee8a832c49 Add a handful of fixes for Android 2016-04-19 22:09:14 +05:30
Rainer Schuetze
c74d4c2231 Merge remote-tracking branch 'remotes/origin/master' into merge-2.071
# Conflicts:
#	runtime/druntime
#	tests/d2/dmd-testsuite
2016-04-17 21:24:56 +02:00
Rainer Schuetze
26a4e2bd13 create our own global context, it's been removed from LLVM 2016-04-16 10:02:13 +02:00
Dan Olson
cd216538f9 Merge branch 'master' into objc-wip 2016-04-08 22:38:39 -07:00