Commit graph

107 commits

Author SHA1 Message Date
Martin Kinkelin
4eff49437c Adapt to somewhat simpler global-var-replacement for mismatching initializers
We don't have any constant pointer-bitcasts anymore for these, but can
use the helper global directly.
2024-05-20 18:49:46 +02:00
Martin Kinkelin
d140f2a283 Skip superfluous IR pointer bitcasts, now that they are always opaque 2024-05-20 16:45:09 +02:00
Martin Kinkelin
e7091dd0c7 Drop support for LLVM < 14
LLVM 14 is the first version supporting both new pass manager and
opaque IR pointers.
2024-05-12 03:53:03 +02:00
Martin Kinkelin
0a69a8451a Add support for new ulong[] hex string literals 2024-03-09 02:19:38 +01:00
Martin Kinkelin
5d3ded9eeb Remove legacy LL[Maybe]Align 2023-07-29 02:09:35 +02:00
Martin Kinkelin
f6702cfbf5 Remove legacy llvm::make_unique 2023-07-29 02:09:35 +02:00
Martin Kinkelin
14759a744e ImportC: Account for StringExp typed as static array with length > string length
Fixes dmd-testsuite's compilable/test23066.c.
2022-10-07 00:04:46 +02:00
Nicholas Wilson
011fb4a479
Remove getContainedType from setGlobalVarInitializer (#4145) 2022-09-13 17:27:53 +08:00
Nicholas Wilson
1ddf803241
Remove getPointerElementType from createInlineAsmCall (#4142) 2022-09-13 12:43:44 +08:00
Nicholas Wilson
ae80c639e7
Remove redundant check from createInlineAsmCall (#4127) 2022-09-09 17:48:06 +08:00
Nicholas Wilson
def909e6a7
Revert "Provide indirect types to createInlineAsmCall from naked.cpp (#4120)" (#4125)
This reverts commit 4561cdb9e1.
2022-09-09 10:04:28 +08:00
Nicholas Wilson
4561cdb9e1
Provide indirect types to createInlineAsmCall from naked.cpp (#4120) 2022-09-07 20:50:56 +08:00
Nicholas Wilson
fdf1eba96a
Provide pointee type with gcc-asm to createInlineAsmCall (#4038) 2022-09-07 19:18:35 +08:00
Nicholas Wilson
0829b40abe
Remove deprecated getPointeeType and DtoLoad (#4109) 2022-09-04 11:39:21 +08:00
Martin Kinkelin
2b6177fdc9 Fix LLVM 14 complaints about missing element type attributes for indirect asm operands 2022-03-30 15:00:07 +02:00
Martin Kinkelin
369cfd13ce Adapt to TY enum class 2021-09-07 16:51:19 +02:00
Martin Kinkelin
a765bf8901 Refactoring: Move IR global declaration & definition to IrGlobal 2020-10-24 19:55:38 +02: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
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
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
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
5ab92f418b Keep Loc's for inline asm diagnostics in GC-tracked memory
To prevent dangling refs with `-lowmem`.
2020-03-08 11:52:43 +01:00
Martin Kinkelin
4629f156a7 Extend inline asm diagnostics by D source location 2020-02-25 02:31:58 +01:00
Martin Kinkelin
2d86e49fba
Finalize support for LLVM 10 (#3323) 2020-02-14 17:53:40 +01:00
Martin Kinkelin
82f6d4fb85
Embed linker directives in ELF and Mach-O object files (#3259)
Resolves #3245 by adding `pragma(lib, <name>)` library names to
`llvm.dependent-libraries` for ELF object files.

For Mach-O, embed appropriate linker options for `pragma(lib)` and
support generic `pragma(linkerDirective, <flag>, ...)` as well.
2020-01-14 23:12:55 +01:00
Martin Kinkelin
c431fb02a9 Make ClassReferenceExp → IR global association more robust
Fixes the runnable/interpret.d regression.
2019-10-20 00:43:27 +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
33cadfaca6 Remove ldc.arrayinit & streamline _d_array_slice_copy/_d_arraycast_len with upstream 2019-01-07 15:54:26 +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
cfad799f48 Merge 2.078.0 front-end and stdlibs 2018-01-06 01:39:18 +01:00
Martin
36b5dfa9cb Fix warning 2017-10-29 16:24:10 +01:00
Martin
95915a8ab8 Fix and refactor Objective-C state
Tie the state to an LLVM module/object file instead of having a global
one. And finalize it once per LLVM module instead of once per D module
(previously, as part of ModuleInfo generation).

Fixes issue #2388.
2017-10-26 20:28:53 +02:00
Martin
0c0c8d72d6 Clean up IRState initialization 2017-09-24 14:02:29 +02:00
Martin
ea0167d652 Attempt to fix issue #1829 (dangling pointers after replacing globals)
Postpone the destruction of replaced global variables, register them in
`IRState::globalsToReplace` and perform a second replacement pass when
finalizing the IR module. The globals will be destroyed in that 2nd pass,
so there may still be dangling pointers in `IrGlobal::value`, but now only
after writing the module.

The nicer thing would be replacing IrGlobal::value by IrGlobal::getValue()
which could look it up in IRState, but that's not feasible due to the
field being inherited from IrVar and IrGlobal apparently quite often being
used as IrVar (via pointers union), so the cached field is currently
required.

So the feasible options to me were either registering each IrGlobal with
its mangled name and replacing their values when swapping out the global
variable, or performing this second replacement pass right before
finalizing the IR module to make sure we really replace all occurrences.
I went for the latter as it's both easier and safer (from the LL
perspective as the old global might be cached somewhere else too).
2017-07-15 20:30:47 +02:00
Martin
4db1f05391 Use IRState::setGlobalVarInitializer() for regular global variables 2017-06-17 23:57:21 +02:00
Martin
b07feb296e Refactoring: Introduce IRState::setGlobalVarInitializer() 2017-06-17 20:45:06 +02:00
Nicholas Wilson
6c7f1b616e [NFC] [dcompute] Make LDC somewhat aware of addrspaces. (#2122)
* [NFC] Make LDC somewhat aware of addrspaces.

Required so that we don't generate invalid code when dealing with pointer to addrspaces other than zero.
2017-05-21 08:43:04 +08: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
kinke
bb3e16481c Fix alignment and size of target critical section (#1956)
The missing alignment is a front-end bug; this is a combined backport
of dlang/dmd@b9aa6ed and dlang/dmd@a93fa3c.

For POSIX targets, the critical section size was assumed to be identical
to the host compiler's, which generally isn't true when cross-compiling.

DtoMutexType() wasn't used anywhere, so I removed it.
2017-01-13 21:44:28 +01: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
e711deac1b Refactor basic block construction and revise BB order 2016-08-06 22:04:41 +02:00
David Nadlinger
6cc93bc8ba gen/ir: Move function body codegen state into separate class
Previously, the transitory state only needed and valid during
generation of the LLVM IR for the function body was conflated
with the general codegen metadata for the function declaration
in IrFunction.

There is further potential for cleanup regarding the use of
gIR->func() and so on all over the code base, but this is out
of scope of this commit, which is only concerned with those
IrFunction members moved to FuncGenState.

GitHub: Fixes #1661.
2016-08-03 21:07:18 +01:00
Martin
2dfa5e8569 Some more cosmetic fixes
Found by searching for lines > 80 chars.
2015-11-05 19:12:32 +01:00
David Nadlinger
05d45350aa clang-tidy: Add readability-else-after-return 2015-11-02 11:30:40 +02:00
David Nadlinger
9df487edff gen/ir: clang-tidy the world 2015-11-02 11:30:40 +02:00