* Improve ftime-trace implementation.
- Rewrite ftime-trace to our own implementatation instead of using LLVM's time trace code. The disadvantage is that this removes LLVM's work from the trace (optimization), but has the large benefit of being able to tailor the tracing output to our needs.
- Add memory tracing to ftime-trace (not possible with LLVM's implementation)
- Do not output the sum for each "category"/named string. This causes the LLVM output to be _very_ long, because we put more information in each time segment name. Tooling that processes the time trace output can do this summing itself (i.e. Tracy), and makes the time trace much more pleasant to view in trace viewers.
- Use MonoTime, move timescale calculation to output stage, 'measurement' stage uses ticks as unit
- Fix crash on `ldc2 -ftime-trace` without files passed.
* 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.
Init symbols, TypeInfos (classes only) & vtables - unless defined in a
root module. For explicitly exported aggregates, or, with
`-fvisibility=public`, all aggregates.
To prevent conflicts for concurrent LDC processes in the same
working dir, resolving #3643.
Re-use this for the temporary object files of -run by enforcing
-cleanup-obj in that case. Additionally enforcing -oq prevents
conflicting filenames in that dir and allows to get rid of previous
Module.makeObjectFilenameUnique().
This uses LLVM's TimeProfiler functionality, such that LLVM's work is traced in the same profile (optimization and machine code gen).
Functionality is meant to be identical to Clang and LLD's --ftime-trace.
I.e., *define* templated symbols in each referencing compilation unit
when using discardable linkonce_odr linkage, analogous to C++.
This makes each compilation unit self-sufficient wrt. templated symbols,
which also means increased opportunity for inlining and less need for
LTO. There should be no more undefined symbol issues caused by buggy
template culling.
The biggest advantage is that the optimizer can discard unused
linkonce_odr symbols early instead of optimizing and forwarding to the
assembler. So this is especially useful with -O to decrease compilation
times and can at least in some scenarios greatly outweigh the
(potentially very much) higher number of symbols defined by the glue
layer.
Libraries compiled with -linkonce-templates can generally not be linked
against dependent code compiled without -linkonce-templates; the other
way around works.
* The explicit reference to the ModuleInfo should be obsolete, it's
added to the llvm.used array.
* Only keep a single pair of ldc.dso_{c,d}tor per DSO (pointing to a
common ldc.register_dso() function) instead of a pair per linked-in D
object file. This simplifies ldc.register_dso() and allows to get rid
of the explicit ctor/dtor functions and the ldc.dso_initialized global.
Making it obvious which of the two operations is performed, reducing
call args and making sure a global isn't defined multiple times via
`defineGlobal()`.
The only [intended] functional change is in gen/trycatchfinally.cpp,
where I inserted a check for an existing __cpp_type_info_ptr global when
emitting a catch for C++ exceptions.
Not all type declarations yet (e.g., some TypeInfo subtypes are still
accessed directly), but those already wrapped as LazyType in the
gen/runtime.cpp module (with check and proper error msg in case object.d
doesn't contain a required declaration).