Commit graph

73 commits

Author SHA1 Message Date
Martin Kinkelin
b3e7fc89fe Handle importC SymOffExp quirk
Fixes dmd-testsuite's compilable/test22929.c.
2022-04-30 21:06:05 +02:00
Martin Kinkelin
4b1f5516fd Pass isCfile parameter for all defaultInit() calls, for some extra importC zero-init
Fixes dmd-testsuite's runnable/test22994.c.
2022-04-30 19:54:20 +02:00
Martin Kinkelin
8527b3f9c8 Work around llvm::PointerType::getElementType() being deprecated in LLVM 14 2022-03-30 19:53:47 +02:00
Martin Kinkelin
4bd8dcd91b Adapt to new TOK and EXP enum classes 2022-02-16 20:52:07 +01:00
Martin Kinkelin
4e74ee272f Ignore void initializers for literal fields
This fixes an LDC ICE, complaining about `void is not a constant`.
2022-02-12 02:40:50 +01:00
Martin Kinkelin
fe146c41e8 Enable toConstElem for some SliceExp
Porting dlang/dmd#13358 to fix dmd-testsuite's compilable/test21414.d.
2021-12-21 04:07:06 +01: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
6b3929597e
Fix regression in recent toConstElem refactoring (#3837)
Fixes #3836 by fixing an oversight in 598b615e77.
2021-09-25 14:26:16 +02:00
Martin Kinkelin
50fb6c8638 Add support for StringExp typed as pointer to static array
E.g., "456" typed as `char[4]*` encountered in dmd-testsuite's
runnable/test22070_2.c, and a similar constant case in
compilable/testcstuff1.c.
2021-09-10 21:56:45 +02:00
Martin Kinkelin
598b615e77 Fix switch case with const runtime variable assuming a *constant* initializer
As the initializer might just as well not be computable at compile-time.
Fixes such a case in `bug6985()` in dmd-testsuite's
`compilable/interpret3.d`.
2021-09-08 17:56:23 +02:00
Martin Kinkelin
369cfd13ce Adapt to TY enum class 2021-09-07 16:51:19 +02:00
Martin Kinkelin
c6096a7d27
Add __traits(initSymbol, <aggregate type>) (#3774)
A clean way of directly accessing struct and class init symbols. It
yields a `const(void[])` slice; the length reflecting the struct/class
instance size, and the pointer either pointing to the init symbol or
being null for zero-initialized structs.

Paves the way for resolving #3773 in druntime as well as accessing class
init symbols without `TypeInfo_Class.initializer()` indirection, and so
with -betterC as well.
2021-06-28 18:40:28 +02:00
Martin Kinkelin
d8bc064cfb Add support for LLVM 12 2021-02-12 07:54:41 +01:00
Martin Kinkelin
d3574b9835 DtoTypeInfoOf(): Make Loc param mandatory and move to 1st position 2020-12-13 15:15:37 +01:00
DaveP1776
3f9d05ac16 Fix missing location information for error reporting of TypeInfo in betterC
This fixes an issue where any instantiation of TypeInfo in the final
output would lead to a cryptic error with no file or line information.
This change brings ldc in line with dmd's reporting of the same error,
which at least gives file and line information to discover the problem.
2020-12-12 22:41:21 -05: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
a765bf8901 Refactoring: Move IR global declaration & definition to IrGlobal 2020-10-24 19:55:38 +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
49affcffb2
Fix issue #3496 - missing IR declarations for some fwd-declared functions (#3503)
Whenever we need an IR function, we'd better make sure it exists. Handle
that in DtoCallee(), by invoking DtoDeclareFunction() by default,
instead of the previous DtoResolveFunction() + DtoCallee() combo.
DtoResolveFunction() usually declares the function, but somehow doesn't
for abstract and body-less functions.
2020-07-13 21:49:41 +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
26673c174f
Refactoring: Replace Expression::op check followed by static cast to Expression::is<ExpressionType> (#3141)
This may negatively impact performance, as the (final, i.e.,
non-virtual) Expression::is... family is implemented in D and not
available inline in the C++ headers.
2020-01-15 12:54:05 +01:00
Martin Kinkelin
4ac7f0554b Adapt to frontend refactorings 2019-12-22 16:29:45 +01:00
Johan Engelen
a72c318cb3 Add explicit casts to llvm::MaybeAlign for setAlignment to use the new LLVM trunk API (silences deprecation messages of old API) 2019-10-18 00:16:24 +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
e52199469f Upgrade front-end & libs to v2.087.0-beta.1 2019-06-21 15:39:45 +02:00
Martin Kinkelin
79a22f734b
Cache struct literal constants per compilation unit, not globally (#2992)
Fixes #2990.
2019-02-15 18:16:59 +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
5c24f60cf9
Raise min LLVM version to 3.9 (#2872) 2018-10-15 22:31:59 +02:00
Martin Kinkelin
7e9db717ce
Fix issue #2859 (#2860)
I assume a DotVar expression making it here implies its address is not constant.
2018-09-29 17:29:00 +02:00
Martin
73036990ac Re-implement module-scope initialized delegates (#2508) 2018-02-14 20:01:31 +01:00
Martin
33dcdb98de Revert "DMD issue 17899 (#2508)"
This reverts commit b22d8cccf3.
2018-02-14 19:56:53 +01:00
Nicholas Wilson
b22d8cccf3
DMD issue 17899 (#2508)
Enable module scope initialised delegates
2018-02-12 09:11:33 +00:00
Martin
ef78d63bf5 Small refactoring wrt. CTFE typeid() expressions
There's a functional change here: previously, the direct calls to
`TypeInfo...Declaration_codegen()` bypassed the check whether the
TypeInfo can be omitted due to the described type being speculative,
which is performed for normal `Declaration_codegen()` calls only.
The latter is used by `DtoTypeInfoOf()`.
2017-10-25 00:38:05 +02:00
kinke
d1b30d627c Backport fix for issue #2357 (#2366)
Improve robustness for TypeInfos of speculative types by only eliding
their TypeInfo definition, not the declaration of the LL global
altogether.

`DtoTypeInfoOf()` expects the LL global to be created and otherwise
fails with an assertion or segfault (e.g., issue #2357). So now only
linker errors should result in case the TypeInfo definition is missing.

Also normalize the calls to `DtoTypeInfoOf()` and revise the following
pointer bitcasts, as the LL type of forward-declared TypeInfo globals
may be opaque.
2017-10-18 20:47:09 +02:00
Martin
2616261fd2 Revise all LDC-specific errors/warnings/deprecs and insert backticks
For DMD's new syntax highlighting. I grepped in all .{h,cpp} files only.
2017-08-03 22:53:49 +02:00
Martin
1fb269f940 Drop support for LLVM < 3.7 2017-07-16 02:18:00 +02:00
Martin
b07feb296e Refactoring: Introduce IRState::setGlobalVarInitializer() 2017-06-17 20:45:06 +02:00
Martin
7790376096 Make sure LL globals for struct/class literals match their type's LL type
I.e., a global may be a cast pointer to a helper global's payload in case
the initializer doesn't match the struct/class LL type (unions).
2017-06-17 20:01:32 +02:00
Martin
383c2d3a59 Range-ify usages of front-end Arrays 2017-06-04 00:29:44 +02:00
kinke
151e83dc6b Fix C++ warnings (#2140) 2017-05-26 13:45:15 +02:00
David Nadlinger
c26bfcbdaa toconstelem: Implement array literal VectorExps
Previously, we would always try to splat the given expression across the
whole vector. This hasn't been noticed earlier as DMD mostly generates
ArrayInitializers when initializing vectors to array literals (but
notably not when explicitly assigning VectorType.init).

GitHub: Fixes #2101.
2017-05-09 23:13:07 +01:00
David Nadlinger
f58fa7576d toconstelem: clang-format again [nfc] 2017-05-07 01:59:57 +01:00
Ivan Butygin
a26bfc1223 Refactor code to hide direct IrFunction->func usage and add convenient functions (#1911) 2017-01-17 22:40:32 +01:00
Martin
10b0261200 Zext i1 constants for scalar Boolean struct fields to i8 2016-10-23 17:31:02 +02:00
David Nadlinger
52445d617b gen: Prefer nullptr [nfc] 2016-09-03 14:38:10 +01:00
Martin
a843bbf2e8 Fix issue #1723
Errors are gagged while trying to create a constant initializer for an
associative array literal. So don't die with an assertion if the cast
source is a NewExp (or something else than a supported ClassReferenceExp),
emit a gaggable error instead.
2016-08-28 20:11:05 +02:00
Martin
df34beb59b Refactor binops and binassigns 2016-07-16 16:42:23 +02:00
Rainer Schuetze
f9995b1883 fix build against LLVM trunk svn rev 273030 2016-06-18 10:54:23 +02:00
Johan Engelen
1b4b9a07c9 Fix typo: typeinf.h --> typinf.h [NFC] 2016-06-08 10:40:00 +02:00
Johan Engelen
d7ed918766 Fix codegen for static initialization with typeid(A). Resolves issue 1540. 2016-06-08 10:40:00 +02:00