Commit graph

744 commits

Author SHA1 Message Date
Martin Kinkelin
9a87d45f61
Fix DMD issue 20401 (#3233)
See https://issues.dlang.org/show_bug.cgi?id=20401; a testcase will be
added with https://github.com/dlang/dmd/pull/10577.

It's a pretty serious issue (the previously returned reference in the
testcase was a dangling reference to a local memcopy of the original
value in memory), hence this early fix.
2019-11-23 02:53:11 +01:00
Martin Kinkelin
ce3de8be0b Make sure a replaced temporary's lvalue is an alloca
As the replacement most likely wouldn't work if the temporary lvalue was
a bitcast alloca, for example. We want to replace all usages of the
alloca to make sure all writes are redirected to the final lvalue.
2019-10-27 00:53:52 +02:00
Martin Kinkelin
a984145dde Try to in-place-construct temporary structs and static arrays
Inspired by https://issues.dlang.org/show_bug.cgi?id=20321.
2019-10-26 16:43:20 +02:00
Martin Kinkelin
3840a03af4
Don't emit init symbol for zero-initialized structs (#3131)
And optimize previous usages of it to direct memset-zero.
2019-09-12 00:30:09 +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
Stefanos Baziotis
122ecd127e Add inbounds to static arrays and dynamic arrays 2019-09-10 22:27:36 +02:00
Stefanos Baziotis
eedde0ab16 Add inbounds where possible 2019-09-10 22:27:36 +02:00
Martin Kinkelin
a9b9097918
Improve emission of vector literals (#3139) 2019-08-27 00:08:39 +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
45460a1e5c Fix this in functions nested in in/out contracts
Contracts are special nested functions, previously receiving the
aggregate `this` pointer as context ptr, as nothing except for `this`
can actually be captured from the original function (parameters are
passed explicitly).

If a contract features a nested function and that function accesses
`this`, it is captured from the original function, and the nested
function expects a regular context of depth 2.

By passing a pointer to the `this` pointer as context for contracts, it
can naturally be used directly as parent context in the contract.

This fixes newly extended runnable/testcontracts.d.
2019-05-27 21:14:45 +02:00
Martin Kinkelin
a44c78fb88 Disallow some vector ops and fix integral vector identity comparisons
Bail out on unsupported vector ops (not checking the rhs type for binops
though) in the frontend instead of causing LLVM errors.

Also precompute the target's critical section size once at startup, like
DMD.
2019-05-26 05:11:16 +02:00
Martin Kinkelin
b3b06d0cc7 Replace LDC-specific VarDeclaration.scopeClassType by .onstackWithDtor
This doesn't increase the VarDeclaration size.
2019-04-13 20:34:16 +02:00
Martin Kinkelin
68fa7b0167 Enforce slice IR rvalues to be represented by DSliceValue, disallow DImValue 2019-01-10 00:53:24 +01:00
Martin Kinkelin
32ecbdd266 Upgrade front-end & libs to v2.084.0-beta.1 2018-12-18 02:31:57 +01:00
Johan Engelen
7966987178 Assigning T.init should only create a temporary when needed. (#2927) 2018-12-03 20:57:40 +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
dbf263aa1f Fix issue #2865 (#2867)
Functions, labels etc. aren't sized; respect that when coming across a SymOffExp (and checking whether we can elide a pointer cast to i8* for the GEP).
2018-10-08 21:04:53 +02:00
Martin Kinkelin
5557278ba2 Adapt to refactored defaultInit() (method => free-standing) 2018-08-17 21:34:46 +02:00
Martin Kinkelin
14c74efb7a Support new explicitly direct calls of struct methods
dlang/dmd#8359 introduces direct call expressions for struct methods
(which cannot be virtual anyway and are so always called directly).

Our previous code relied on the instance being a class. There are
multiple ways to fix this; I went with this one.
2018-06-23 17:19:28 +02:00
Martin Kinkelin
c01dfc3db8 Fix: Don't emit struct literals aliasing T.init
This fixes the std.conv unittests on Win64 with the more efficient
IndirectByvalRewrite. This code would segfault:

```
import std.typecons;

alias T = Tuple!(string, string, int);

void main()
{
    T local;
    local = T.init;
}
```

`T.init` represents a struct literal here (a D rvalue in memory) and is
newly forwarded directly by ref to the Tuple's `opAssign(auto ref
Tuple)` for high-level-by-value semantics.

The problem was that `emitStructLiteral()` would actually return a
DLValue to the global init symbol directly in some cases, i.e., a D
lvalue, instead of allocating a dedicated temporary and filling it with
a bitcopy.
2018-05-30 21:46:39 +02:00
Martin
05839a784f Adapt LDC to dropped floating-point comparison operators 2018-04-25 01:00:46 +02:00
Martin
bd623f028a Redirect access to remaining TypeInfo subtypes through gen/runtime 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
2ffd6ba3c4 Error out when trying to concatenate arrays in -betterC mode
This fixes the error message for fail_compilation/test18312.d, which
used to be:

Error: `TypeInfo` cannot be used with -betterC
2018-03-31 01:22:03 +02:00
Martin
6eceb9141e Merge branch 'master' into merge-2.079
Conflicts:
	.circleci/config.yml
	runtime/druntime
	runtime/phobos
	tests/d2/dmd-testsuite
2018-02-25 15:32:50 +01:00
Martin Kinkelin
f0aba4559f
Fix cat-assign-element issue if rhs affects the lhs length (#2589)
I.e., this fixes #2588.

To fix the index of the new array element to be assigned to, I went for
decrementing the new length instead of saving the old length directly
before the druntime call (i.e., after evaluating the rhs expression due
to its potential side effects). The IR seems more intuitive to me this
way - load both new length+ptr directly after the druntime call and then
decrement the length by 1.
2018-02-23 18:51:36 +01:00
Martin
df4f854dd5 Upgrade to D v2.079.0-beta.1 2018-02-20 02:04:41 +01:00
Martin
c6132508b1 Don't waste an alloca for the nested context argument
And so get rid of all loads too; just use the untouched pointer argument
directly.
2018-02-11 18:43:02 +00:00
Martin
1b860e70d7 Merge branch 'master' into merge-2.078 2018-01-26 18:52:49 +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
1941ea0b7b Refactoring: Make DtoAllocaDump(DValue*) overloads handle DLValues 2018-01-14 22:42:27 +01:00
Martin
f9575686e1 Get rid of obsolete runtime functions
For array comparisons (new) and the _adReverse family.
2018-01-07 05:03:37 +01:00
Martin
cfad799f48 Merge 2.078.0 front-end and stdlibs 2018-01-06 01:39:18 +01:00
Martin Kinkelin
4b0653bcd3 Fix #2415 and #2471 (#2479)
Reverts previous fix for #2415 that introduced regression #2471 , and implements alternative fix for #2415 .
2018-01-03 20:05:41 +01:00
Martin
ad89009d6e Merge 2.077.0 front-end and stdlibs 2017-11-05 18:41:55 +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
kinke
d4e9f26f2b Fix issue #1728 (nested this in constructors) (#2375) 2017-10-25 00:19:16 +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
c251170912 Rename DtoMangled... to getIRMangled... 2017-10-07 14:06:17 +02:00
Martin
c9a3be1295 Let TargetABI fix up LLVM mangles for more special symbols
For ModuleInfos, ModuleRefs, InterfaceInfos, interface vtables & thunks.
2017-10-07 14:06:17 +02:00
Martin
befd05eb56 Optimize lhs = structliteral.ctor(args)
Fixes runnable/sdtor:2842 which tests this for return expressions (in a
function using sret).
2017-08-11 22:29:11 +02:00
Martin
db8797e1ce Allow vectors to be compared for (not-)equality
I don't know how much sense that makes, as the front-end expects a result
expression of a single bool.
LLVM returns a vector of i1 values, the pair-wise results.
From my experience with SIMD on x86_64, what's mostly needed is a vector
bit mask, as that's what the CPU returns and which is later used to mask
accesses/writes.

Anyway, due to new `Target.isVectorOpSupported()` simply allowing all ops,
(not-)equality comparisons of vectors now land here, and I reduce the
pair-wise results via integer bitcast and an additional integer
comparison.
2017-08-04 21:32:25 +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
kinke
57cbe0901e Merge pull request #2211 from kinke/llvm_min37
Drop support for LLVM < 3.7
2017-07-18 17:27:57 +00:00
Nicholas Wilson
6e43377d6b Remove prelude assert from ctors & dtors (Cherrypick dmd/6982) (#2202)
To trigger this you had to construct or destruct an aggregate at the
null memory location, which would crash if you were to access any
members, which is required for a constructor or destructor to do
anything useful.
2017-07-16 19:02:20 +08:00
Martin
1fb269f940 Drop support for LLVM < 3.7 2017-07-16 02:18:00 +02:00
Martin
3b8d6628ba Postpone the evaluation of a SliceExp's base pointer
Load the base's pointer after the bounds expressions have been evaluated,
since they may affect the pointer if the base is an lvalue, see issue #1433.
2017-07-09 14:18:43 +02:00
Martin
383c2d3a59 Range-ify usages of front-end Arrays 2017-06-04 00:29:44 +02:00