Commit graph

168 commits

Author SHA1 Message Date
Johan Engelen
c421e4ccaf
Implement -fsanitize-recover for ASan and MSan. (#4783)
Resolves #4770
2024-11-29 19:35:56 +01:00
liushuyu
fcd887821f
gen/optimizer.cpp: gate LLVM 19.1 functions behind ...
... LDC_LLVM_VER >= 1900 instead of 1901
2024-11-26 08:46:19 -07:00
Nicholas Wilson
fbc88d1155 Fix some compilation errors for LLVM19/20 2024-11-26 08:46:15 -07:00
Martin Kinkelin
94af2f8126 Drop support for legacy pass manager, and -passmanager CLI option 2024-05-12 06:19:19 +02:00
Martin Kinkelin
e7091dd0c7 Drop support for LLVM < 14
LLVM 14 is the first version supporting both new pass manager and
opaque IR pointers.
2024-05-12 03:53:03 +02:00
liushuyu
b8a96faf92 tree-wide: port LDC to LLVM 18 2024-03-26 14:45:35 -06:00
Johan Engelen
e0f9fa6e20
Add support for -ffat-lto-objects. (#4549) 2024-03-01 21:19:00 +01:00
Johan Engelen
91d306894e
Add support for LLVM 17. (#4533) 2023-12-03 19:07:31 +01:00
Johan Engelen
de948bd664
Add -fprofile-sample-use (#4531)
Resolves issue #4527
2023-11-23 19:11:23 +01:00
Martin Kinkelin
8c9400e7f1 [whitespace nits] 2023-08-12 16:44:30 +02:00
Martin Kinkelin
81ea49db13 Merge remote-tracking branch 'origin/master' into llvm16-2 2023-08-12 14:37:01 +02:00
Martin Kinkelin
9ce57807c0 Drop support for LLVM 9 and LLVM 10 2023-07-29 01:12:43 +02:00
Ikey Doherty
ad71070369
For LLVM >= 16, use std::optional APIs
Unfortunately when building with LLVM < 15, we're using C++-11,
so the std::optional bits are only available in C++-17.

Even more unfortunately we can't really override this, rather
inherit the fact of using C++-17 when using LLVM > 16.

Thus, we add a slightly messy conditional compilation situation
to allow usage of LDC on older LLVM versions, and with newer
LLVM/libcxx.

Signed-off-by: Ikey Doherty <ikey@serpentos.com>
2023-06-03 22:07:24 +01:00
Ikey Doherty
173a4cbda0
gen/optimizer: Port to LLVM 16 Context usage
The StandardInstrumentations type now takes an LLVMContext parameter
so pass it along from the current module.

Signed-off-by: Ikey Doherty <ikey@serpentos.com>
2023-06-03 22:06:33 +01:00
Johan Engelen
ef0719f36b
Implement -femit-local-var-lifetime which adds local (stack) variable… (#4395)
Implement -femit-local-var-lifetime which adds local (stack) variable lifetime annotation to LLVM IR, which enables sharing stack space for variables whose lifetimes do not overlap.
Resolves issue #2227

This is not enabled by default yet, to prevent miscompilation due to bugs (should be enabled in future for optimization levels > 0, and when sanitizers are enabled).
2023-06-01 22:45:56 +00:00
Martin Kinkelin
f41369127a [small refactoring - get rid of superfluous lambdas] 2023-05-12 23:58:32 +02:00
Martin Kinkelin
e30ed5037e Revise -verify-each
Only verify after each dlang-specific pass as per the usage text.

With the new pass manager, the compile-time is now on par with the
legacy one, for `-O -verify-each`. Previously, it was at least 3x
slower (I've aborted the test, long running...), probably much worse.
2023-05-09 23:12:37 +02:00
Martin Kinkelin
3197a523cd Run LLVM codegen passes once in toobj.cpp 2023-05-09 20:58:13 +02:00
Martin Kinkelin
fea7ea372a Slightly revise new LLVM pass manager setup
After comparing with clang/lib/CodeGen/BackendUtil.cpp (v15).
2023-05-09 20:57:12 +02:00
Martin Kinkelin
0b40412c29
Fix #4354 - Huge compile slowdown with -g and the new LLVM pass manager (#4393)
Tested manually with the Symmetry project, and LLVM 14. The `-g`
compile times with both legacy and new pass managers are on par
again.
2023-05-09 12:30:10 +00:00
Johan Engelen
981c58e498
Add -fsanitize-address-use-after-return (#4334) 2023-02-27 11:40:08 +01:00
Johan Engelen
da3e45f330
Fix loading pass plugins while using the new passmanager. (LLVM >= 14) (#4254) 2022-11-12 11:58:51 +01:00
Johan Engelen
fed90e8993
Give error when selecting unsupported passmanager. (#4250) 2022-11-10 23:10:01 +00:00
jamesragray
b2b4969950
Enable Simplify druntime calls for new pass manager. (Setting passman… (#4229)
* Enable Simplify druntime calls for new pass manager. 

Co-authored-by: james <jamesragray@bitbucket.org>
2022-09-28 21:30:05 +08:00
jamesragray
c864d3141c
Wrap strip externals pass for new pass manger. (#4200) 2022-09-24 06:07:47 +08:00
jamesragray
0f2d842d5e
Gc2stack (#4188)
Implement gc2stack for new pass manager.

Co-authored-by: james <jamesragray@bitbucket.org>
2022-09-23 08:01:14 +08:00
Nicholas Wilson
6b38ad0eff
Move gen/cl_helpers.* to driver/ (#4191) 2022-09-21 19:36:24 +08:00
jamesragray
4145c0b86a
Fix for optnone not being respected with new passmanager (#4182)
Co-authored-by: james <jamesragray@bitbucket.org>
2022-09-18 17:11:52 +08:00
Nicholas Wilson
a3eae7a815
Fix compilation with LLVM16 (#4176) 2022-09-16 11:09:41 +08:00
jamesragray
2f06fd7416
New passmanager clean (#4175)
* Start to implement optimization pipeline with new pass manager for LLVM15

* Set default to use legacy passmanager.

Co-authored-by: james <jamesragray@bitbucket.org>
2022-09-16 07:08:59 +08:00
jamesragray
0bf5d96284
Renamed pass functions in gen/optimizer.cpp by prepending legacy. This is allow the corresponding functions for the new pass manager to be use the old names. (#4115)
Co-authored-by: james <jamesragray@bitbucket.org>
2022-09-07 07:43:36 +08:00
Martin Kinkelin
bdef01e7cc Raise min LLVM version to 9.0 2022-04-25 23:11:48 +02:00
Martin Kinkelin
9865e459d1 Windows: Make implicit dllimport more selective
* Newly require `-link-defaultlib-shared` for implicit dllimport.
  E.g., this enables to compile druntime DLL with `-fvisibility=public`
  for pure exports and no (local) imports (such as builtin TypeInfos).
* `-link-defaultlib-shared` alone now only implicitly imports symbols
  from druntime/Phobos.
  This simplifies building complex DLLs linked against a bunch of
  static libs (dub only supports static lib dependencies!); the static
  libs don't need to be compiled with `-fvisibility=public` anymore
  (if the DLL itself isn't either), `-link-defaultlib-shared` is
  sufficient.
  This is mainly useful for existing DLLs with explicit exports, to make
  them link against *shared* druntime/Phobos and so end up with a single
  druntime/Phobos for the whole process.
2021-06-14 17:47:32 +02:00
Johan Engelen
a5025bf83e
Add MSan compiler-rt library to LDC install and add it to linkerline for --fsanitize=memory (#3751)
* Add MSan compiler-rt library to LDC install and add it to linkerline for --fsanitize=memory

* MSan: Add support for `-fsanitize-memory-track-origins=`
2021-06-07 00:29:18 +02:00
Martin Kinkelin
ee0d5fbe3c Windows: Default to dllexport with -shared, and enforce dllimport with -link-defaultlib-shared 2021-05-03 20:54:57 +02:00
Martin Kinkelin
8acdcb43eb Add manual dllimport 'relocation' pass for static data initializers
References to dllimported globals in static data initializers lead to
undefined-symbol linker errors. We need to resolve the indirection
manually at runtime.

I went with an extra LLVM pass for Windows targets when using
`-fvisibility=public`, and scanning the initializers of all global
variables (well, only thread-global ones). The problematic pointers in
the initializers are nullified and initialized at runtime early via a
CRT constructor (working with -betterC as well).
2021-04-30 17:11:55 +02:00
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