Commit graph

47 commits

Author SHA1 Message Date
liushuyu
fc4d884d2d
Multiple changes ...
* Use getVoidPtrType helper
* Replace #define with constexpr
2024-03-26 14:48:36 -06:00
liushuyu
b8a96faf92 tree-wide: port LDC to LLVM 18 2024-03-26 14:45:35 -06:00
Martin Kinkelin
9ce57807c0 Drop support for LLVM 9 and LLVM 10 2023-07-29 01:12:43 +02:00
Nicholas Wilson
12d97f975e
Use typed loads in gen/trycatchfinally.cpp (#4059) 2022-08-28 14:33:28 +08:00
Nicholas Wilson
79d6da7105
Remove getPointeeType from trycatchfinally.cpp (#4031) 2022-08-21 10:35:35 +08:00
Martin Kinkelin
bdef01e7cc Raise min LLVM version to 9.0 2022-04-25 23:11:48 +02:00
Martin Kinkelin
7b6810b01b Fix LLVM 13 deprecation messages during build 2022-02-26 19:15:46 +01:00
Martin Kinkelin
49caa9e8a0 Windows: Dllimport aggregate globals too
Init symbols, TypeInfos (classes only) & vtables - unless defined in a
root module. For explicitly exported aggregates, or, with
`-fvisibility=public`, all aggregates.
2021-04-29 17:22:12 +02: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
b7c6a2f101 Fix colliding WinEH TypeDescriptors for exceptions with the same TypeInfo_Class name
As reported in https://github.com/ldc-developers/ldc/issues/3501#issuecomment-661551187.

Previously, LDC would simply override an existing TypeDescriptor global
with an equivalent definition if assertions were disabled.

Use different equivalent TypeDescriptors in this exotic case now, by
using proper mangling. [The linker can presumably still fold duplicates
via ICF.]

Ideally, these descriptors would be truly unique, but WinEH depends on
string comparisons to check for matching catch clauses, and currently
depends on TypeInfo_Class.name to generate these strings at runtime when
throwing an exception, see
19731a92a9/src/ldc/eh_msvc.d (L192-L211).
So if those names were fully qualified (`cd->toPrettyChars(*true*)`
during ClassInfo generation), we'd be fine, but that'd obviously be a
breaking change and diverge from upstream.
2020-11-13 06:05:28 +01: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
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
834f666ce5
Raise min LLVM version to 6.0 (#3493) 2020-07-13 20:42:50 +02:00
Martin Kinkelin
4ac7f0554b Adapt to frontend refactorings 2019-12-22 16:29:45 +01:00
Martin Kinkelin
1662406231 Upgrade front-end & libs to v2.088.0-beta.1 2019-08-25 00:36:15 +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
5e93ed0dfd Upgrade front-end & libs to v2.085.0-beta.1 2019-03-01 18:19:00 +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
f38a7972a5 Split up getOrCreateGlobal() in {declare,define}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.
2018-04-10 22:13:00 +02:00
Martin
e337cec78a Slightly refactor RTTIBuilder 2018-04-04 19:59:10 +02:00
Martin
9ff736bf0f Lookup runtime function before constructing the call args
To retain the LoC information in case TypeInfo declarations are missing.
2018-04-04 19:59:10 +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
Martin Kinkelin
5e4d04faad
Call _Unwind_Resume() directly (except for ARM EABI) (#2642)
This fixes the 32-bit std.file unittests on Linux with enabled
optimizations. Quoting the SysV ABI docs:

> This is the only routine in the unwind library which is expected to be
> called directly by generated code: it will be called at the end of a
> landing pad in a "landing-pad" model.

The remaining LDC-specific ARM EABI wrapper (_d_eh_resume_unwind()) is
implemented in assembly (ldc/eh_asm.S), preserving registers apparently.
2018-04-04 19:58:06 +02:00
Elie Morisse
bf8cd786e7 Differentiate C++ catch clauses from D ones by wrapping std::type_info pointers inside __cpp_type_info_ptr class instances like DMD does. (#2590)
Previously assuming in the personality routine that encountering a C++ exception meant that catch clauses were raw std::type_info pointers was wrong in cases like:

try {
   throwStdException(); // external C++ function throwing a std::exception
} catch (Throwable t) {
   (...)
}

Generated __cpp_type_info_ptr constants receive the same mangling that they do within DMD.
2018-02-24 13:50:30 +01:00
Martin
c6a9affc8f Support catching C++ exceptions for MSVC targets 2017-11-27 18:59:29 +01:00
Martin
dfe45715ba Enable catching C++ exceptions for non-MSVC targets 2017-11-26 18:41:01 +01:00
kinke
426f8c0593
Fix PGO for MSVC targets (issue #1943) (#2398) 2017-10-31 22:30:47 +01: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
Rainer Schuetze
ae7f1a7f2c fix buildinng against LLVM master (#2111) 2017-05-16 20:43:29 +02:00
Johan Engelen
64df1687a8 Fix LLVM 5.0 compilation. 2017-04-14 12:55:19 +02: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
4b72aad875 Fix issue #1774
Running a cleanup with a dummy target BB and later replacing all uses of
that dummy with the actual BB is buggy, as the cleanup keeps track of its
exit targets (via pointers) which aren't updated.
2016-10-02 12:11:05 +02:00
Martin
f8f9269055 Fix linking error when using LLVM < 3.8 and enabled LDC assertions 2016-09-24 11:33:49 +02:00
David Nadlinger
01ad624be7 gen/trycatchfinally: Remove unused parameter [nfc] 2016-09-03 14:38:10 +01:00
David Nadlinger
11572489d5 clang-format again some files touched in the next commits [nfc] 2016-09-03 00:52:00 +01:00
Martin
cac96fd0e9 Add some more comments for TryCatchFinallyScopes 2016-08-08 23:33:27 +02:00
Martin
963dd722dd Move EH ptr & selector and resume-unwind block to TryCatchFinallyScopes
To properly encapsulate landing pad emission.
2016-08-08 22:43:01 +02:00
Martin
25b186ce2d TryCatchFinallyScopes: Encapsulate unresolved gotos properly 2016-08-08 22:15:23 +02:00
Martin
92e9ad85fc Some minor improvements for gen/trycatchfinally 2016-08-08 22:15:20 +02:00
Martin
7b238f36c8 Move landing pads to the end of the function, in emission order 2016-08-08 01:26:51 +02:00
Martin
7d15ab9ffc Reduce ScopeStack to JumpTargets
Add some comments after this more or less clean separation, and move
callOrInvoke() to FuncGenState.
2016-08-07 21:29:47 +02:00
Martin
73652977e9 Move unresolved gotos from ScopeStack to TryCatchFinallyScopes 2016-08-07 20:32:20 +02:00
Martin
caf5397f6f Extend TryCatchScopes to TryCatchFinallyScopes 2016-08-07 18:45:59 +02:00