Commit graph

316 commits

Author SHA1 Message Date
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
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
Martin
30b858781b -betterC: Use C assert function
Instead of druntime's _d_assert[_msg], _d_arraybounds and
_d_switch_error.

Tested by dmd-testsuite's runnable/cassert and compilable/betterCarray.
2017-10-25 00:38:05 +02:00
Martin
f63166cf35 Try to fix signalling-ness of {float,double}.init
By letting LLVM narrow compile-time real_t values to float/double IR
constants. We previously relied on the host, which turns signalling
real_t NaNs to quiet float/double NaNs.

Signalling NaNs are characterized by their most-significant mantissa bit
being 0 (and at least for D the 2nd-most-significant mantissa bit being
set to distinguish them from infinity). The host truncation led to the MSB
getting set while keeping the rest of the mantissa (i.e., both MSBs set).

Here's the resulting bitpattern table in hex:

            float:     double:            x87 real:
init old:   7fe00000   7ffc000000000000   7fffa000000000000000
init new:   7fa00000   7ff4000000000000   7fffa000000000000000
qnan:       7fc00000   7ff8000000000000   7fffc000000000000000

DMD 2.074.0 produces wrongly quiet float/double init values.

A Win32 LDC build (with double-precision real_t) still loses the
signalling-ness for {float,double,64-bit real}.init, probably due to the
FPU being used instead of SSE.
2017-07-28 00:58:59 +02:00
Martin
1fb269f940 Drop support for LLVM < 3.7 2017-07-16 02:18:00 +02:00
Luís Marques
7c9874a209 Add support for MSP430 / 16-bit targets (#2194)
Relevant version identifiers PRs:
https://github.com/dlang/dmd/pull/6994
https://github.com/dlang/dlang.org/pull/1822
2017-07-14 16:55:09 +02:00
David Nadlinger
e659db6a11 Merge pull request #2135 from kinke/gh2131
Add range metadata when loading bools
2017-06-03 18:35:01 +01:00
kinke
151e83dc6b Fix C++ warnings (#2140) 2017-05-26 13:45:15 +02:00
Martin
c9b2571a44 Zero-extend Boolean parameters and return values 2017-05-25 04:10:00 +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
Martin
0e71a760ae Limited support for arbitrary target reals
While parsing of floating-point literals and CTFE still operate with the
host LDC's real type, compile-time reals can in principle be emitted in
arbitrary precision via LLVM software conversion, therefore paving the way
for cross-compilation to all targets.

The representable constants are still limited by the compile-time real_t
precision. E.g., LDC on Windows with its 64-bit reals can't hold and emit
an 80-bit `real.max` when cross-compiling to a non-Windows x86(_64)
target; the compile-time value will silently overflow to infinity and
later be emitted as 80-bit infinity.

LDC on AArch64 with its 128-bit quad-precision reals on the other hand can
hold and emit reals for all targets, making it a universal cross-compiler
with quad-precision compile-time reals in hardware.

We don't use the strange 2x64-bit PPC double-double format (see
`getRealType()` in `ir/irtype.cpp`), but would more or less support it
(the type properties (max, min_normal...) still need to be determined;
LLVM isn't sure about those either...).
2017-02-11 14:24:46 +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
Johan Engelen
5e9914ad29 Fix LLVM trunk build. (#1936) 2016-12-22 17:59:03 +01: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
29152f5b94 Refactor DIBuilder
Incl. some subtle changes/fixes.
2016-07-22 22:34:31 +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
David Nadlinger
209b6fc2b0 Merge pull request #1393 from kinke/nullArray
Optimize array comparisons against null
2016-04-09 23:22:53 +01:00
Johan Engelen
823a9efe26 Merge branch 'ltsmaster'
Solved merge conflicts in:
	gen/abi.cpp
	gen/toir.cpp
	runtime/druntime
	tests/d2/dmd-testsuite
	tests/lit.site.cfg.in
2016-03-29 11:40:20 +02:00
Martin
0440bd20db Optimize array comparisons against null
This fixes issue #894 and includes some refactorings.
2016-03-28 15:30:55 +02:00
Johan Engelen
69825a6fb9 Add the @ldc.attributes.weak linkage attributes for global symbols. 2016-03-27 22:08:23 +02:00
Kai Nacke
fc7edf2b90 Fix merge error 2016-03-22 19:20:40 +01:00
Kai Nacke
88f3de8bea Merge branch 'ltsmaster' 2016-03-22 19:05:07 +01:00
Martin
608ce9852e Emit symbols by default as COMDATs
That's apparently what DMD does and what currently happens for all
non-MSVC targets anyway.

For MSVC, we need this to enforce the `any` selection instead of
`no duplicates`, otherwise the linker complains about multiply defined
symbols and refuses to link without an extra command line option
(which in turn outputs a non-suppressable warning).
2016-03-20 18:04:42 +01:00
Martin
88dcb4349a Refactor setting linkage type and COMDAT 2016-03-20 16:37:44 +01:00
Kai Nacke
24adf155ff Revert "Revert "Merge branch 'ltsmaster'""
This reverts commit 1653911600.
2016-03-03 21:12:53 +01:00
Kai Nacke
1653911600 Revert "Merge branch 'ltsmaster'"
This reverts commit dcb781004b, reversing
changes made to 3c6f09faf0.
2016-03-03 13:14:39 +01:00
Kai Nacke
dcb781004b Merge branch 'ltsmaster' 2016-03-03 07:50:17 +01:00
Kai Nacke
2b2438b5b2 Fix IEEE 128-bit reals.
The previous implementation sets all reals to 0.0.
2016-03-02 11:42:09 +00:00
Kai Nacke
4d40ea8fcf AArch64: This platform uses IEEE 128-bit floats.
This adds the missing code paths.
2016-03-01 22:02:29 +01:00