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>
The StandardInstrumentations type now takes an LLVMContext parameter
so pass it along from the current module.
Signed-off-by: Ikey Doherty <ikey@serpentos.com>
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).
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.
* Start to implement optimization pipeline with new pass manager for LLVM15
* Set default to use legacy passmanager.
Co-authored-by: james <jamesragray@bitbucket.org>
* 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.
* Add MSan compiler-rt library to LDC install and add it to linkerline for --fsanitize=memory
* MSan: Add support for `-fsanitize-memory-track-origins=`
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).
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.
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.