It may likely show up as garbage, as it's not a real local variable
(allocated by caller, address mostly passed in a register); e.g., this
happens on Win64 with the VS debugger ('expression is not an address' or
something along these lines), but at least output *some* DI.
We may be able to fix this and similar issues with LLVM 7 and new
intrinsic llvm.dbg.addr().
There's a new need to access a class' vtable symbol, see dlang/dmd#8362.
Use it as alias to the actual vtable symbol with different type (dummy:
`i8*`, actual: `[N x i8*]`) and mangled name.
I tried matching the special symbol's mangled name and using an
appropriate static array front-end type for it, but then casting the
symbol address for the assignment leads to issues if the ctor is @safe.
So I decided to handle it in DtoSymbolAddress().
Unfortunately, this seems not to solve the extern(C++) issues exposed by
LDC self-compilation yet.
The AST now features special-ref result variables (storage classes:
ref, temp, result) after rewriting out contracts; from dmd/func.d:
/* out(id1) { statements1... }
* out(id2) { statements2... }
* ...
* becomes:
* out(__result) { { ref id1 = __result; { statements1... } }
* { ref id2 = __result; { statements2... } } ... }
*/
We are talking about the `id1` and `id2` variables here.
There's an existing assertion that we don't set a special-ref variable's
lvalue (T**) to the sret pointer (T*) which was already triggered when
compiling Phobos without unittests.
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.
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).
D2.072 apparently doesn't set the STCforeach storage class for each
special reference anymore. So let's consider all references which aren't
parameters, i.e., all locals with STCref, as special references.
By-ref parameters are different as we simply use the LL pointer parameter as
lvalue for the variable, no extra alloca required. Special references are
automatically dereferenced pointers and as such occupy a dedicated alloca for
the address.
The previous check wouldn't check intermediate aggregates for static-ness,
that was one problem. The other was the assertion that the outer function
can be reached as long as there are no static functions inbetween, which
isn't always the case, as issue #1864 clearly shows, which is resolved by
this.
Compatible with DMD, but restricted to Windows and functions only.
`export` functions with bodies get the dllexport attribute and will be
exported if the containing object is pulled in when linking.
Body-less `export` functions get the dllimport attribute and will be
accessed via an import table indirection, set up at runtime by the OS.
This is a temporary solution, the proper fix is a pending DMD PR, after
which LDC will need to be adapted.
There's no <Type>_init type for aggregates (structs and classes) anymore,
effectively eliminating a *lot* of named LLVM types, some bitcasts as well
as replacements of globals etc.
To get there, it was even required to use the regular type for compatible
literals too, otherwise structs embedded as fields in other aggregates had
an anonymous type (well, the LLVM constant for the field initializer had)
and so the container initializer wasn't compatible with the regular type
anymore.
What was also necessary was a fix wrt. static arrays of bools (LLVM
constant of type `[N x i1]` vs. `[N x i8]` for regular type).
I also had to change the initializer for `char[2][3] x = 0xff` from
`[6 x i8]` to `[3 x [2 x i8]]`, i.e., NOT flattening multi-dimensional
inits from a scalar.
So only literals with overlapping (union) fields and an explicit
initializer initializing dominated non-alias union fields should still
have a mismatching anonymous type - i.e., very, very few cases.