Emit better debugging information for a trait object pointer. In
particular, now:
* The fields are explicitly represented in the DWARF;
* DWARF for the vtable itself is emitted; and
* The DWARF for the vtable's type has a DW_AT_containing_type which
points to the concrete type for which the vtable was emitted. This is
a small DWARF extension, that allows debuggers to determine the real
type of the object to which a trait object points.
I'll submit the gdb patch to take advantage of this new debuginfo once
this lands.
The vtable type is not currently complete -- it doesn't include members
for the pointers it contains. This information was not needed for this
feature.
This addresses part 1 of #1563.
This commit refactors the `collect_crate_translation_items` function to only
require the `TyCtxt` instead of a `SharedCrateContext` in preparation for
query-ifying this portion of trans.
Drop of arrays is now translated in trans::block in an ugly way that I
should clean up in a later PR, and does not handle panics in the middle
of an array drop, but this commit & PR are growing too big.
These changes are in the same commit to avoid needing to adapt
meth::trans_object_shim to the new scheme.
One codegen-units test is broken because we instantiate the shims even
when they are not needed. This will be fixed in the next PR.
Give LLVM much more information about vtable pointers. Without the extra
information, LLVM has to be rather pessimistic about vtables, preventing
a number of obvious optimisations.
* Makes the vtable pointer argument noalias and readonly.
* Marks loads of the vtable pointer as nonnull.
* Marks load from the vtable with `!invariant.load` metadata.
Fixes#39992
According to the LLVM reference:
> A value of 0 or an omitted align argument means that the operation has
the ABI alignment for the target.
So loads/stores of fields of packed structs need to have their align set
to 1. Implement that by tracking the alignment of `LvalueRef`s.
Fixes#39376.
This does not make unreachable and other terminators take self by-value
because it is deemed too difficult. We would need to create by-value
methods on BAB that call into Builder, due to the Deref to builder.
In #34268 (8531d581), we replaced matches of None to the unit value `()`
with `if let`s in places where it was deemed that this made the code
unambiguously clearer and more idiomatic. In #34638 (d37edef9), we did
the same for matches of None to the empty block `{}`.
A casual observer, upon seeing these commits fly by, might suppose that
the matter was then settled, that no further pull requests on this
utterly trivial point of style could or would be made. Unless ...
It turns out that sometimes people write the empty block with a space in
between the braces. Who knew?
Associated type normalization is inhibited by higher-ranked regions.
Therefore, every time we erase them, we must re-normalize.
I was meaning to introduce this change some time ago, but we used
to erase regions in generic context, which broke this terribly (because
you can't always normalize in a generic context). That seems to be gone
now.
Ensure this by having a `erase_late_bound_regions_and_normalize`
function.
Fixes#37109 (the missing call was in mir::block).