Commit graph

344 commits

Author SHA1 Message Date
Nicholas Wilson
a448110fd3
Use typed gep in tollvm.cpp (#4085) 2022-09-01 10:26:47 +08:00
Nicholas Wilson
4aba54ed52
Add typed overloads for GEP, mark old ones deprecated (#4051) 2022-08-28 12:32:41 +08:00
Nicholas Wilson
f142ac2e83
Add overloads of DtoLoad to transition from getPointeeType (#4043) 2022-08-22 09:45:11 +08:00
Nicholas Wilson
aea2033c19
Remove getPointeeType from DtoAlignedLoad (#4025) 2022-08-21 08:24:40 +08:00
Nicholas Wilson
764e2fb34e
[NFC] Push getPointeeType up the stack in DtoGEP (#4026) 2022-08-20 06:25:53 +00:00
Nicholas Wilson
f0a3abf1dc
Remove getPointeeType from DtoVolatileLoad (#4024) 2022-08-20 05:23:17 +00:00
Nicholas Wilson
844508d059
Push getPointeeType up the stack from DtoLoadImpl (#4023) 2022-08-20 11:19:40 +08:00
Martin Kinkelin
be20833b22 codegen: Support {Not,Logical,Identity,Cmp}Exp with non-bool type (for importC AST)
Fixing failing LDC assertions.
2022-04-30 23:46:47 +02:00
Martin Kinkelin
bdef01e7cc Raise min LLVM version to 9.0 2022-04-25 23:11:48 +02:00
Martin Kinkelin
f2a6fefb7b
Merge pull request #3923 from kinke/fix3916
Fix #3916 - undefined symbols with `-dllimport=all` on Windows
2022-02-28 22:19:02 +01:00
Martin Kinkelin
7b6810b01b Fix LLVM 13 deprecation messages during build 2022-02-26 19:15:46 +01:00
Martin Kinkelin
4bd8dcd91b Adapt to new TOK and EXP enum classes 2022-02-16 20:52:07 +01:00
Martin Kinkelin
4fcbd692bb
Add @hidden UDA (#3855)
To hide a symbol in the sense of making it DSO-local. An `export`
visibility is stronger and overrides the UDA.

On non-Windows, also newly hide symbols (without `export`) with
linkonce_odr etc. linkage.
2021-10-23 17:50:18 +02:00
Martin Kinkelin
e8997308f9 Always specify a pointee type for llvm::ConstantExpr::getGetElementPtr()
As required by LLVM 13.
2021-10-11 19:21:37 +02:00
Martin Kinkelin
369cfd13ce Adapt to TY enum class 2021-09-07 16:51:19 +02:00
Johan Engelen
70ecbc8b8d Fix issue #3802 - Fix size_t size for 32bit ABI on 64bit architectures. 2021-08-07 23:50:13 +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
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
c5afede4f3 Windows: Try to make implicit dllimport work for data symbols
Functions can and apparently are magically stubbed (something like
`void myFunc() { (*__imp_myFunc)(); }`), but it seems we cannot avoid
dllimport for global variables exported from other DLLs/executables.

In order to try to make druntime etc. work as DLL without explicitly
exporting all required globals, `-fvisibility=public` now also assumes
all `extern(D)` globals *not* defined in some root module are exported
from some binary and dllimports them accordingly.

So e.g. compiling Phobos with `-fvisibility=public` means

* Phobos exports all defined symbols,
* Phobos dllimports extern(D) druntime symbols, and
* extern(C) globals, e.g., from the C runtime, remain external and are
  linked regularly.
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
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
c1a9251c40 Extend linkonce_odr to template lambda instances 2021-02-07 02:26:15 +01:00
Martin Kinkelin
d1b94a6577 Emit lambdas as linkonce_odr, including contained globals
As they are emitted into each referencing object file anyway.
Handling the globals resolves issue #3648.

I think this also solves issue #2968 - in the presumably rare event
that you absolutely don't want to emit a function into its owning
CU and only into each referencing CU, an enum-lambda can be used as
shown in the testcase.
With `pragma(inline, true)`, it'll most likely be actually inlined
and not make it to the object files.
2021-02-07 02:23:29 +01:00
Martin Kinkelin
c155e3c141
Merge pull request #3600 from kinke/linkonce2
Extend -linkonce-templates by matching template emission scheme
2020-11-27 02:45:14 +01:00
Martin Kinkelin
1834e88739 Handle AST quirk wrt. aggregate Types t with stripModifiers(t) != stripModifiers(t.sym.type) 2020-11-13 17:47:56 +01:00
Martin Kinkelin
3f716ff75e Refactoring: Introduce getIrType()
As *the* way to access the IrType associated with a Type via its `ctype`
field. Most importantly, it makes sure all access is redirected to the
*unqualified* type's `ctype`, which allows to get rid of the 'multiple
types' workaround for aggregates in DtoType(). Those were e.g. hit for
`shared struct SpinLock`, where the struct's type includes the `shared`
modifier...
2020-11-13 15:43:18 +01:00
Martin Kinkelin
ab2ae5e0a2 Handle AST quirks wrt. aggregates with Terror type
Reducing some ugliness found while investigating
https://issues.dlang.org/show_bug.cgi?id=19762.

A struct or class can apparently have 'semantic errors', in which case
the associated type is Terror. In DtoType(), we've been associating
Terror with the IrType (via `ctype`) for the first such aggregate, so
the LL type was *some* struct and got reused for other erroneous
aggregates with Terror type.

Use an opaque '_error_' LL struct in these cases now, and don't
associate Terror with any IrType anymore.
2020-11-13 15:33:17 +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
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
looked-at-me
1b5b40556a
Refactor and improve string literal emission (#3492)
Fixes #3490 by avoiding unnecessary extra key allocations for the literals cache etc.
Also gets rid of code duplication and improves IRState encapsulation.
2020-07-11 01:06:10 +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
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
2d86e49fba
Finalize support for LLVM 10 (#3323) 2020-02-14 17:53:40 +01:00
Roberto Rosmaninho
a1e44b2c81 Adapt to current LLVM 10 (#3257) 2019-12-16 22:23:43 +01:00
Johan Engelen
9c47b12895 LLVM 10 fix: add llvm::make_unique and LLMaybeAlign "aliases". (an explicit cast from integer to llvm::MaybeAlign is needed now to setAlignment) 2019-10-16 22:53:46 +02: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
c1725809c2
-fvisibility=hidden: Hide init symbols, TypeInfos and vtables too if the associated aggregate isn't exported (#3129) 2019-08-20 01:41:26 +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
c62b760263
Support templated LLVM intrinsics with vector arguments (#2971)
Fixes #2962.
2019-01-21 22:22:36 +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
Martin Kinkelin
5c24f60cf9
Raise min LLVM version to 3.9 (#2872) 2018-10-15 22:31:59 +02:00
Martin Kinkelin
561fdc276f WebAssembly doesn't support COMDATs 2018-07-09 20:23:27 +02:00
Martin Kinkelin
a133ffad56 MSVC: Port Rainer's upstream extern(C++) method ABI fixes
From https://github.com/dlang/dmd/pull/8330.
2018-06-19 20:13:02 +02:00
Martin
8583c117bc Adapt new Target::isReturnOnStack() to LDC
It's apparently used for std.traits.
2018-04-28 00:42:50 +02:00
Martin
d8f60d2f5c Redirect access to object.d type declarations through gen/runtime
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).
2018-04-04 19:59:10 +02:00
Johan Engelen
b222089136 LLVM7.0: update code to use new API for creating MemCpy intrinsic call. (#2551)
http://lists.llvm.org/pipermail/llvm-dev/2018-January/120542.html
2018-02-01 20:05:39 +01:00
Martin Kinkelin
6367d98d3a
Don't finalize scope objects without dtors and monitor (#2516)
The dtors can be checked at compile-time; insert a runtime check for the
monitor before finalizing the stack-allocated class object via druntime
call.

See issue #2515.
2018-01-26 18:38:16 +01:00