Commit graph

566 commits

Author SHA1 Message Date
Nicholas Wilson
906037988f
Move abi*.* to abi/ (#4192) 2022-09-21 13:16:04 +00:00
jamesragray
7d8e0f787b
Add UWTableKind for LLVM15+ (#4169)
uwtable attribute needs an argument. This was set using setUWTableKind

Co-authored-by: james <jamesragray@bitbucket.org>
2022-09-15 21:24:53 +08:00
Nicholas Wilson
78e68b5149
Make DComputeTarget::ID an enum class (#4172) 2022-09-15 20:00:52 +08:00
Nicholas Wilson
2dd2f7fc15
Use typed GEP in functions.cpp (#4072) 2022-08-28 21:19:15 +08:00
Martin Kinkelin
be9d5817a1 Adapt glue layer to renamed/changed Declaration::linkage 2022-05-06 19:42:18 +02:00
Martin Kinkelin
b7b8e59043 Upgrade frontend & libs to v2.100.0-beta.1+ (dlang/dmd@c0cff59c79) 2022-04-26 23:01:13 +02:00
Martin Kinkelin
bdef01e7cc Raise min LLVM version to 9.0 2022-04-25 23:11:48 +02:00
Martin Kinkelin
143d7b3171 Fix compile & link errors against LLVM 14 2022-03-30 13:51:18 +02:00
Nicholas Wilson
4349388563
Prepare for LLVM15: Headers, attributes (#3936)
`llvm::AttrBuilder` was changed to require an LLVMContext in its constructor, and can no longer be copied.

declare `DEBIG_TYPE` after includes for the GC2Stack pass as `llvm/Support/GenericDomTreeConstruction.h `(included from `llvm/IR/Dominators.h` `#define`s and `#undef`s it.

`llvm::DIBuilder::createExpression` now takes an `ArrayRef<uint64_t>` instead of `int64_t`. EmitLocalVariable has similarly changed
2022-03-11 16:38:49 +01:00
Martin Kinkelin
0fd5c6ec16
Merge pull request #3873 from kinke/no_reverse
Don't reverse parameters order for extern(D)
2022-03-08 17:03:17 +01:00
Martin Kinkelin
dc25da9557 ABI: Handle extern(C++) delegates for 32-bit MSVC with __thiscall convention 2022-02-22 14:48:38 +01:00
Martin Kinkelin
84da9adf7d Handle ImportC special case wrt. non-variadic declaration vs. variadic definition 2022-02-19 23:55:20 +01:00
Martin Kinkelin
34f2628480 Handle newly unparsed unittests from non-root modules 2022-02-17 00:19:02 +01:00
Martin Kinkelin
9d2d891f95 Adapt to new PASS enum class 2022-02-16 20:52:07 +01:00
Johan Engelen
6a56267699
Add @ldc.attributes.noSanitize UDA to selectively disable sanitizer instrumentation of functions. (#3889) 2022-01-01 14:27:36 +01:00
Martin Kinkelin
25abb0bb48
Try a blunter, clone-less approach for MSVC weak-any emulation (#3869)
As cloning a function with debuginfos has always been problematic,
and I haven't found a suitable workaround for new assertions with
LLVM 13, without resorting to even blunter instruments like
suppressing debuginfos for weak-any functions and MSVC targets.
2021-11-12 17:02:05 +01:00
Martin Kinkelin
9858cfb01c Simplify dmd/ldcbindings.{d,h} 2021-09-17 03:49:28 +02:00
Martin Kinkelin
5e8490d69e
Merge pull request #3821 from kinke/merge-2.098
Upgrade frontend & libs to early v2.098.0
2021-09-11 20:12:55 +02:00
Martin Kinkelin
86f430c039 Slightly revise frontend diff
E.g., preferring local imports for less merge conflict potential.
2021-09-11 17:34:51 +02:00
Martin Kinkelin
16b9eab374
-dllimport=defaultLibsOnly: Avoid -linkonce-templates requirement (#3816)
Via a sorts-of '-linkonce-templates light', only defining all *data*
symbols instantiated from druntime/Phobos templates in each
referencing CU.
2021-09-11 04:53:21 +02:00
Martin Kinkelin
369cfd13ce Adapt to TY enum class 2021-09-07 16:51:19 +02:00
Johan Engelen
c517ce9d12
Improve ftime-trace implementation. (#3797)
* 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.
2021-08-14 14:11:22 +02:00
Martin Kinkelin
6e15e1ab04
Make sure special struct TypeInfo members are semantically analyzed before emitting the TypeInfo (#3783)
As there are apparently cases where the struct hasn't had semantic3
yet, at least with -linkonce-templates. This prevents erroneous xopCmp
etc. (failing to compile) from being referenced in the TypeInfo (=>
linker errors) / being analyzed for -linkonce-templates codegen.
`semanticTypeInfoMembers()` replaces them by `object._xopCmp()` etc.
if compilation fails.
2021-07-14 15:41:06 +02:00
Martin Kinkelin
92617aba94 Refactoring: Push/pop FuncGenState for naked asm functions in DtoDefineFunction() too 2021-06-18 16:35:15 +02:00
Martin Kinkelin
1e00f63045 Adapt to upstream global.params.* -> target.* shuffling 2021-05-29 00:19:22 +02:00
Martin Kinkelin
64a5b53566 Windows: Disable @weak emulation for dllexported functions
Otherwise the functions aren't exported. We have some @weak functions in
druntime.
2021-04-29 17:20:32 +02:00
Martin Kinkelin
fb709e9b5f Windows: Only export all external and weak_odr symbols with -fvisibility=public
Mainly, don't export any linkonce_odr symbols.
2021-04-29 17:20:32 +02:00
Martin Kinkelin
eaeb65a9d8 Windows: Make -fvisibility=public export all defined symbols
To pave the way for simple DLL generation (end goal:
druntime-ldc-shared.dll).

The dllexport storage class for functions definitions is enough; the
automatically generated import .lib seems to resolve the regular symbol
name to the actual symbol (__imp_*), so dllimport for declarations seems
superfluous.

For global variables, things are apparently different unfortunately.
2021-04-29 17:20:32 +02:00
Martin Kinkelin
3cdd5b58cb LLVM 12: Add type information to sret and byval parameter attributes
This fixes the failing bitcode writer assertions.
2021-04-27 23:48:26 +02:00
Martin Kinkelin
f39371a32d Merge remote-tracking branch 'origin/master' into merge-2.096
Conflicts:
	gen/dibuilder.cpp
2021-04-10 15:57:21 +02:00
Martin Kinkelin
a268b23469
Don't enforce the frame pointer for functions with GCC-style inline asm (#3685)
As GDC doesn't either.
2021-04-04 19:25:55 +02:00
Martin Kinkelin
52bcbcc566 Fix ICE for ref/out params of opaque structs
Fixes dmd-testsuite's new compilable/test21668.d.
2021-03-01 13:10:16 +01:00
Martin Kinkelin
44daef934a Add support for 'noreturn' type
It's apparently already in the AST, e.g., for core.internal.abort.
2021-02-28 18:57:45 +01:00
Martin Kinkelin
0c079fbdf9 Silence 2 C++ compiler warnings for builds with disabled assertions 2021-02-10 03:27:43 +01:00
Martin Kinkelin
fe5a1776ac Merge remote-tracking branch 'origin/master' into merge-2.095 2021-01-06 23:58:20 +01:00
Martin Kinkelin
0ae530f966 Merge upstream stable (dlang/dmd@ebd5e81dc9) 2021-01-06 23:34:36 +01:00
Johan Engelen
29245c8255
Add --ftime-trace functionality. (#3624)
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.
2020-12-28 17:05:04 +01:00
Martin Kinkelin
3eab44153a Merge branch 'master' into merge-2.095
Conflicts:
	runtime/phobos
2020-12-03 21:34:29 +01:00
Johan Engelen
b7b676e8da
Remove unused function.cpp:binary (#3626) 2020-12-01 09:52:36 +01:00
Martin Kinkelin
079858f3b2 Upgrade frontend & libs to early v2.095.0 (dlang/dmd@a4274b3c39) 2020-11-27 17:45:13 +01:00
Martin Kinkelin
ec9caae7fc Replace DtoIsTemplateInstance() by Dsymbol::isInstantiated()
The semantics were almost identical, except for DtoIsTemplateInstance()
checking the specified Dsymbol and its parents, while isInstantiated()
starts from its parent and ignores the symbol itself.

After a quick glance, we seem to have fed it with {Aggregate,Func,Var}
Declarations only, so should be fine with the default front-end variant.
2020-11-13 02:41:11 +01:00
Martin Kinkelin
145ce40b11 Extend -linkonce-templates by matching template emission scheme
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.
2020-11-13 02:41:11 +01:00
Martin Kinkelin
6f5730049b Merge remote-tracking branch 'origin/master' into merge-2.094
Conflicts:
	gen/tocall.cpp
	runtime/phobos
2020-09-30 19:46:43 +02:00
Martin Kinkelin
1d969cfcca Revise IRScope refactoring
LLVM already provides suited RAII helper types to restore the IRBuilder
state. [They sadly aren't movable, so I've had to wrap them in a
unique_ptr.]

While at it, also minimally revise debuginfo generation for functions.
2020-09-26 01:04:50 +02: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
96b9cde428 Add support for LLVM 11
One major change is the removal of llvm::CallSite, which I've replaced
by llvm::CallBase*.
2020-09-26 01:04:50 +02:00
Martin Kinkelin
69269f3bd9 Refactor IRScope handling
Replace the stack of IRScopes, each with its own IRBuilder, by directly
tampering with the state of a single IRBuilder.

This seems like the most feasible way to account for a breaking change
in LLVM 11, disallowing IRBuilder from being copied.
2020-09-26 01:04:50 +02:00
Martin Kinkelin
f202c851ae Upgrade frontend & libs to v2.094.0-beta.1 2020-09-22 00:06:19 +02:00
Martin Kinkelin
834f666ce5
Raise min LLVM version to 6.0 (#3493) 2020-07-13 20:42:50 +02:00
Martin Kinkelin
bc8dfe3f9f Fix: Prevent regular definitions from being weakened to available_externally
This is exactly what happened for the 4 problematic delegate literals
for the Phobos unittests - DtoDefineFunction(fd) could result in that
definition ending up as available_externally - all done as part of
DtoResolveFunction(), which declared it, and DtoDeclareFunction()
defined it as available_externally, and the outer DtoDefineFunction()
returned early in that case without fixing up the linkage.
2020-06-01 02:28:58 +02:00