Commit graph

527 commits

Author SHA1 Message Date
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
Martin Kinkelin
7dddf506a7 Cross-module inlining: Enable emission into multiple object files
Previously, the logic gave up early if semantic3 was run for the
function to be inlined, either because the function is going to be
codegen'd in some root module, or because sema3 was already run for an
available_externally 'copy' in a previous compilation unit.
This restricted a function to being defined in at most one compilation
unit per ldc2 invocation.

So e.g. a little `pragma(inline, true)` wrapper in druntime wasn't
inlined into other druntime modules, because the whole lib is built in a
single cmdline by default, and sema3 was obviously run for the actual
emission in the corresponding object file.

When later compiling Phobos in a single cmdline, only the first object
file referencing the wrapper got lucky, running sema3 manually and
getting an available_externally 'copy'.
2020-06-01 02:28:58 +02:00
Martin Kinkelin
75f18b49ba
Merge pull request #3441 from kinke/fix_captured_nonpassed
Fix ICE for *captured* parameters *not* passed on the LLVM level
2020-05-29 18:28:45 +02:00
Hiroki Noda
b8b7615696
Add --fno-plt option to avoid PLT external calls (#3443)
This patch gives new option which avoids the PLT and lazy binding while
making external calls.
Implementation inspired by `-fno-plt` support to Clang.

Clang's patch: https://reviews.llvm.org/D39079
2020-05-24 22:31:07 +02:00
Martin Kinkelin
0c0102a9e4 Fix ICE for *captured* parameters *not* passed on the LLVM level
Their IrParameter isn't created as part of DtoDeclareFunction(). Before
being able to handle that later in defineParameters() (as part of
defining the function), DtoCreateNestedContextType() steps in and
creates an IrLocal if not already created.

1) Create an IrParameter in that case in DtoCreateNestedContextType().
2) Handle these new value-less (no LL param) IrParameters in
   defineParameters().
3) Fix the iOS AArch64 ABI, as apparently not all empty structs are
   ignored for parameter passing, but only POD ones.
   Also don't ignore anything passed by reference.
2020-05-22 14:58:29 +02:00
Martin Kinkelin
967947eb84 Emulate @weak functions on Windows and don't emit COMDATs for ELF anymore
Emulation for @weak global variables is still left out but should be
analogous.

The test adaptations are mostly a revert of 3893840f. The testcase has
shown that @weak hasn't worked properly for ELF (linker apparently
prefers the version in the 1st object file, independent of whether it's
weak or not), because the functions are emitted in COMDATs.
clang emits COMDATs for templates and inline functions only, not for
regular functions.
2020-05-16 20:42:57 +02:00
Martin Kinkelin
f4f80d32d7 Make IR type determination for captured lazy params TargetABI-agnostic
This fixes codegen/nested_lazy_gh2302.d for AArch64, which failed due to
the TargetABI rewriting the delegate (IR struct) to `[2 x i64]`.
2020-05-03 16:31:46 +02:00
Martin Kinkelin
d603010159 Refactoring: Introduce TargetABI::isExternD() 2020-05-03 16:31:46 +02:00
Martin Kinkelin
3786614967 Merge upstream stable (dlang/dmd@2dc6c9d619) 2020-05-03 13:36:07 +02:00
Martin Kinkelin
d8f22699a8 Prevent redundant type semantic for va_list 2020-05-02 01:06:58 +02:00
Martin Kinkelin
684acd6a3f Improve check for multiple entry point definitions
* Extend the error message, closely following DMD. Tested by
  fail_compilation/fail5634.d.
* Check across all compiled modules, not on a per-object-file basis.
  That's what DMD does too.
* Apply the implicit `return 0` / void -> int return type promotion to
  all D/C main functions, not just the first one. This prevents some
  potential follow-up crashes.
2020-04-28 01:37:49 +02:00
Martin Kinkelin
5e7e0d55bc Merge remote-tracking branch 'origin/master' into merge-2090
Conflicts:
	tests/d2/dmd-testsuite
2020-01-06 17:01:57 +01:00
Martin Kinkelin
1f5c442519 Revise recent adaptations to frontend refactorings 2020-01-06 17:01:31 +01:00
Fangrui Song
77775a40de Use function attribute "frame-pointer" instead of "no-frame-pointer-elim"/"no-frame-pointer-elim-non-leaf"
LLVM 8 (D56351) introduced "frame-pointer" which was intended to replace
"no-frame-pointer-elim"/"no-frame-pointer-elim-non-leaf".
2019-12-28 09:26:26 -08:00
Martin Kinkelin
4ac7f0554b Adapt to frontend refactorings 2019-12-22 16:29:45 +01:00
Martin Kinkelin
8fd69da8fb Make all DtoGEP helpers use implicit inbounds
Single functional change: always emit inbounds when computing the base
pointer of a SliceExp.
2019-09-10 22:36:25 +02:00
Martin Kinkelin
d4fa4710e0 Don't emit DMD-style tracing with pragma(LDC_profile_instr, false)
E.g., this disables it for __entrypoint.d (the C main function(s) in
there), which is required.

A wmain on Windows is not detected as FuncDeclaration.isCMain() yet,
that should be fixed too.
2019-08-08 22:38:38 +02:00
Martin Kinkelin
d93087ad90 Emit fatal codegen error for unsupported dual-context for now
As long as dlang/dmd#9282 isn't ported to LDC.
2019-07-29 20:13:59 +02:00
Martin Kinkelin
e52199469f Upgrade front-end & libs to v2.087.0-beta.1 2019-06-21 15:39:45 +02:00
Martin Kinkelin
cc336d6df1 Support generic ldc.attributes.llvmAttr UDAs for function parameters 2019-03-31 20:59:54 +02:00
Martin Kinkelin
1fdf330346 Refactoring: Remove obsolete AttrBuilder wrapper
It was useful when we still supported older LLVM versions, but it's
obsolete now.
2019-03-31 19:18:56 +02:00
Martin Kinkelin
306bda36fd Adapt to latest LLVM 8 changes 2019-03-02 19:54:36 +01:00
Martin Kinkelin
5e93ed0dfd Upgrade front-end & libs to v2.085.0-beta.1 2019-03-01 18:19:00 +01:00
Johan Engelen
0a84988d65
Enable pragma(LDC_extern_weak) on function declarations. (#2984)
Enable pragma(LDC_extern_weak) on function declarations.
2019-01-27 14:44:31 +01:00
Johan Engelen
d2ff275678
Fix glaring mistake in #2983 (#2985) 2019-01-27 14:43:13 +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
f5a5324773
Merge pull request #2946 from kinke/merge-2.084
Upgrade front-end & libs to v2.084.0
2019-01-18 19:48:47 +01:00
Nicholas Wilson
f5ae8311cd
Adapt to using SPIR-V support as an external library (#2935)
Adapt to using SPIR-V support as an external library.
2019-01-18 14:51:48 +08:00
Martin Kinkelin
c57e597323 Support both CRT ctor and dtor pragmas for a single function 2019-01-06 21:14:40 +01:00
Martin Kinkelin
32ecbdd266 Upgrade front-end & libs to v2.084.0-beta.1 2018-12-18 02:31:57 +01:00
Martin Kinkelin
deaaab8cf3
-fvisibility=hidden: Only hide function *definitions*, don't touch declarations (#2923) 2018-12-03 20:59:59 +01:00
Andrey Penechko
7bcd6d34dd Add option '-fvisibility=<hidden|default>' able to hide symbols not marked as 'export' on non-Windows targets. Resolves #2431 (#2894) 2018-11-09 20:55:57 +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
7776c4081b Upgrade frontend & libs to v2.083.0-beta.1 2018-10-20 16:19:46 +02:00
Elie Morisse
02eb4058fa Debug info: create temporary forward subprograms before creating the subprogram type
This is for the special case of auto functions returning a nested type, e.g:

  auto foo() {
    struct S {};
    S s;
    return s;
  }
2018-10-15 23:10:18 +02:00
Martin Kinkelin
5c24f60cf9
Raise min LLVM version to 3.9 (#2872) 2018-10-15 22:31:59 +02:00
Martin Kinkelin
9fe95daeea Improve diagnostics for multiple function decls with IR type mismatch 2018-08-18 20:41:41 +02:00
Martin Kinkelin
7461269af4
Merge pull request #2773 from kinke/uda
Add @naked UDA
2018-07-28 17:46:59 +02:00
Martin Kinkelin
c10cf86403 Add @naked UDA
Adding the LLVM `naked` function attribute and disabling LDC's
prologue/epilogue too.
2018-07-27 22:53:55 +02:00
Martin Kinkelin
4d5871a027
Fix overzealous check for multiple main() functions (#2778) 2018-07-19 21:18:50 +02:00