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.
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.
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.
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).
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.
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.
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).
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.
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.
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.
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.
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.