Age | Commit message (Collapse) | Author | Files | Lines |
|
In the important places. They are all fully covered switch statements so
we know where to add code when adding a new pointer type.
|
|
Try harder to avoid creating a new `Pointer` for the element.
|
|
6a60f18997d62b0e2842a921fcb6beb3e52ed823 fixed the primary issue of
dereferences, but there are some expressions that depend on the identity
of the pointed-to object without actually accessing it. Handle those
cases.
Also, while I'm here, fix a crash in interpreter mode comparing typeid
to nullptr.
|
|
For large primitive arrays, avoid creating a new `Pointer` for every
element (via `Pointer::isElementInitialized()`) or avoid iterating over
the array altogether (via `Pointer::allElementsInitialized()`).
|
|
|
|
(#155152)
When we get to this point, the pointer might _not_ be backed by a
primitive array, so the later code will fail.
Fixes #155144
|
|
|
|
Fixes #154312
|
|
So we can save ourselves writing PointeeStorage all the time.
|
|
If one of them is a one-past-end pointer.
|
|
This fixes an old todo item about wrong allocation counting and some
diagnostic differences.
|
|
This is a major change on how we represent nested name qualifications in
the AST.
* The nested name specifier itself and how it's stored is changed. The
prefixes for types are handled within the type hierarchy, which makes
canonicalization for them super cheap, no memory allocation required.
Also translating a type into nested name specifier form becomes a no-op.
An identifier is stored as a DependentNameType. The nested name
specifier gains a lightweight handle class, to be used instead of
passing around pointers, which is similar to what is implemented for
TemplateName. There is still one free bit available, and this handle can
be used within a PointerUnion and PointerIntPair, which should keep
bit-packing aficionados happy.
* The ElaboratedType node is removed, all type nodes in which it could
previously apply to can now store the elaborated keyword and name
qualifier, tail allocating when present.
* TagTypes can now point to the exact declaration found when producing
these, as opposed to the previous situation of there only existing one
TagType per entity. This increases the amount of type sugar retained,
and can have several applications, for example in tracking module
ownership, and other tools which care about source file origins, such as
IWYU. These TagTypes are lazily allocated, in order to limit the
increase in AST size.
This patch offers a great performance benefit.
It greatly improves compilation time for
[stdexec](https://github.com/NVIDIA/stdexec). For one datapoint, for
`test_on2.cpp` in that project, which is the slowest compiling test,
this patch improves `-c` compilation time by about 7.2%, with the
`-fsyntax-only` improvement being at ~12%.
This has great results on compile-time-tracker as well:

This patch also further enables other optimziations in the future, and
will reduce the performance impact of template specialization resugaring
when that lands.
It has some other miscelaneous drive-by fixes.
About the review: Yes the patch is huge, sorry about that. Part of the
reason is that I started by the nested name specifier part, before the
ElaboratedType part, but that had a huge performance downside, as
ElaboratedType is a big performance hog. I didn't have the steam to go
back and change the patch after the fact.
There is also a lot of internal API changes, and it made sense to remove
ElaboratedType in one go, versus removing it from one type at a time, as
that would present much more churn to the users. Also, the nested name
specifier having a different API avoids missing changes related to how
prefixes work now, which could make existing code compile but not work.
How to review: The important changes are all in
`clang/include/clang/AST` and `clang/lib/AST`, with also important
changes in `clang/lib/Sema/TreeTransform.h`.
The rest and bulk of the changes are mostly consequences of the changes
in API.
PS: TagType::getDecl is renamed to `getOriginalDecl` in this patch, just
for easier to rebasing. I plan to rename it back after this lands.
Fixes #136624
Fixes https://github.com/llvm/llvm-project/issues/43179
Fixes https://github.com/llvm/llvm-project/issues/68670
Fixes https://github.com/llvm/llvm-project/issues/92757
|
|
They are only relevant for block pointers.
|
|
To initialize all elements of a primitive array at once. This saves us
from creating the InitMap just to destroy it again after all elements
have been initialized.
|
|
|
|
We use this construct a lot. Use something similar to clang's
UnsignedOrNone.
This results in some slighy compile time improvements:
https://llvm-compile-time-tracker.com/compare.php?from=17a4b0399d161a3b89d8f0ce82add1638f23f5d4&to=a251d81ecd0ed45dd190462663155fdb303ef04d&stat=instructions:u
|
|
As a way of writing atIndex(I).deref<T>(), which creates an intermediate
Pointer, which in turn adds (and removes) that pointer from the pointer
list of the Block. This way we can avoid that.
|
|
Only activate things if the syntactical structure suggests so. This adds
a bunch of new opcodes to control whether to activate in stores, etc.
Fixes #134789
|
|
This is easier to read in debuggers and more common.
|
|
When activating the new pointer, we need to de-activate pointers of all
parent unions, not just the topmost one.
|
|
We need to ignore the lvalue path, just like we do for lvalue reference
types.
|
|
First, don't forget to also activate fields which are bitfields on
assignment.
Second, when deactivating fields, recurse into records.
|
|
In the attached test case, one pointer points to the `Derived` class and
one to `Base`, but they should compare equal. They didn't because those
two bases are saved at different offsets in the block. Use
`computeOffsetForComparison` not just for unions and fix it to work in
the more general cases.
|
|
Even if we only allocate one element, we still need to allocate it as a
single-element array. This matches what the current interpreter does.
|
|
P.block() will assert that P is a block pointer, which it doesn't have
to be here.
|
|
This still leaves the case of the
constexpr auto b3 = name1() == name1();
test from cxx20.cpp broken.
|
|
... with different access specifiers.
|
|
If we refer to arr[N], don't set the OnePastEnd bit of the APValue,
since that is already encoded in the array index.
|
|
That's what the current interpreter does as well.
|
|
We don't need this anymore since we don't return it from classify()
anymore.
|
|
Fix comparing type id pointers, add mor info when print()ing them, use
the most derived type in GetTypeidPtr() and the canonically unqualified
type when we know the type statically.
|
|
The Pointer class already has the capability to be a function pointer,
but we still classifed function pointers as PT_FnPtr/FunctionPointer.
This means when converting from a Pointer to a FunctionPointer, we lost
the information of what the original Pointer pointed to.
|
|
Union members get the same address, so we can't just use
`Pointer::getByteOffset()`.
|
|
The missing descriptor should only happen if the pointer is null
pointer.
|
|
The APValue we generated for a pointer with a LValueReferenceType base
had an incorrect lvalue path attached.
The attached test case is extracted from libc++'s regex.cpp.
|
|
Later operations on these are invalid, but the declaration is fine, if
extern.
|
|
Pull local variables in to the closest scope, remove some unnecessary
calls to getLocation() and remove an outdated comment.
|
|
This fixes the expected output to match the one of the current
interpreter.
|
|
This makes some other problems show up like the fact that we didn't
suppress diagnostics during __builtin_constant_p evaluation.
|
|
|
|
Add it as another kind of pointer, saving both a `Type*` for the result
of the typeid() expression as well as one for the type of the typeid
expression.
|
|
We don't need `E` before.
|
|
When we see an array root, that pointer might yet again be an array
element, so check for that.
|
|
Otherwise we treat this like an array element even though we should
treat it as a single object.
|
|
Not doing this is wrong in general and we need to reject expressions
where it would matter differently.
|
|
(#111110)
Make isArrayElement() return true here, so we can know that such a
pointer is in fact an array element and handle it properly in
toAPValue().
|
|
We're otherwise still pointing to the old type, but with the new offset.
|
|
Get the right offset to apply from the RecordLayout.
|
|
This requires adding a new opcode for PointerToBoolean casts, since we
otherwise emit too many diagnostics. But that fixes an older problem
when casting weak pointers to bool.
|
|
... to current offset. This breaks other tests which this commit also
fixes. Namely, getIndex() should return the integer representation for
non-block pointers.
|