
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
160 lines
7.9 KiB
C++
160 lines
7.9 KiB
C++
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=52 %s
|
|
|
|
typedef enum omp_allocator_handle_t {
|
|
omp_null_allocator = 0,
|
|
omp_default_mem_alloc = 1,
|
|
omp_large_cap_mem_alloc = 2,
|
|
omp_const_mem_alloc = 3,
|
|
omp_high_bw_mem_alloc = 4,
|
|
omp_low_lat_mem_alloc = 5,
|
|
omp_cgroup_mem_alloc = 6,
|
|
omp_pteam_mem_alloc = 7,
|
|
omp_thread_mem_alloc = 8,
|
|
} omp_allocator_handle_t;
|
|
|
|
int myAlloc() {
|
|
return 100;
|
|
}
|
|
|
|
int main() {
|
|
int a, b, c;
|
|
// expected-error@+4 {{expected '('}}
|
|
// expected-error@+3 {{expected expression}}
|
|
// expected-error@+2 {{expected ')'}}
|
|
// expected-note@+1 {{to match this '('}}
|
|
#pragma omp scope private(c) allocate(allocator
|
|
// expected-error@+6 {{expected expression}}
|
|
// expected-error@+5 {{expected ')'}}
|
|
// expected-note@+4 {{to match this '('}}
|
|
// expected-error@+3 {{expected expression}}
|
|
// expected-error@+2 {{expected ')'}}
|
|
// expected-note@+1 {{to match this '('}}
|
|
#pragma omp scope private(c) allocate(allocator(
|
|
// expected-error@+4 {{expected expression}}
|
|
// expected-error@+3 {{expected expression}}
|
|
// expected-error@+2 {{expected ')'}}
|
|
// expected-note@+1 {{to match this '('}}
|
|
#pragma omp scope private(c) allocate(allocator()
|
|
// expected-error@+2 {{expected expression}}
|
|
// expected-error@+1 {{expected expression}}
|
|
#pragma omp scope private(c) allocate(allocator())
|
|
// expected-error@+6 {{expected ')'}}
|
|
// expected-note@+5 {{to match this '('}}
|
|
// expected-error@+4 {{missing ':' after allocate clause modifier}}
|
|
// expected-error@+3 {{expected expression}}
|
|
// expected-error@+2 {{expected ')'}}
|
|
// expected-note@+1 {{to match this '('}}
|
|
#pragma omp scope private(c) allocate(allocator(omp_default_mem_alloc
|
|
// expected-error@+6 {{missing ':' after allocate clause modifier}}
|
|
// expected-error@+5 {{expected expression}}
|
|
// expected-error@+4 {{expected ')'}}
|
|
// expected-note@+3 {{to match this '('}}
|
|
// expected-error@+2 {{expected ')'}}
|
|
// expected-note@+1 {{to match this '('}}
|
|
#pragma omp scope private(c) allocate(allocator(omp_large_cap_mem_alloc:
|
|
// expected-error@+4 {{missing ':' after allocate clause modifier}}
|
|
// expected-error@+3 {{expected expression}}
|
|
// expected-error@+2 {{expected ')'}}
|
|
// expected-note@+1 {{to match this '('}}
|
|
#pragma omp scope private(c) allocate(allocator(omp_const_mem_alloc)
|
|
// expected-error@+2 {{missing ':' after allocate clause modifier}}
|
|
// expected-error@+1 {{expected expression}}
|
|
#pragma omp scope private(c) allocate(allocator(omp_high_bw_mem_alloc))
|
|
// expected-error@+1 {{expected expression}}
|
|
#pragma omp scope private(c) allocate(allocator(omp_low_lat_mem_alloc):)
|
|
// expected-error@+6 {{expected ')'}}
|
|
// expected-note@+5 {{to match this '('}}
|
|
// expected-error@+4 {{missing ':' after allocate clause modifier}}
|
|
// expected-error@+3 {{expected expression}}
|
|
// expected-error@+2 {{expected ')'}}
|
|
// expected-note@+1 {{to match this '('}}
|
|
#pragma omp scope private(c) allocate(allocator(omp_cgroup_mem_alloc:)
|
|
// expected-error@+4 {{expected ')'}}
|
|
// expected-note@+3 {{to match this '('}}
|
|
// expected-error@+2 {{missing ':' after allocate clause modifier}}
|
|
// expected-error@+1 {{expected expression}}
|
|
#pragma omp scope private(c) allocate(allocator(omp_pteam_mem_alloc:))
|
|
// expected-error@+4 {{expected ')'}}
|
|
// expected-note@+3 {{to match this '('}}
|
|
// expected-error@+2 {{missing ':' after allocate clause modifier}}
|
|
// expected-error@+1 {{expected expression}}
|
|
#pragma omp scope private(c) allocate(allocator(omp_thread_mem_alloc:c))
|
|
// expected-error@+1 {{expected variable name}}
|
|
#pragma omp scope private(c) allocate(allocator(omp_const_mem_alloc):1)
|
|
// expected-error@+1 {{expected variable name}}
|
|
#pragma omp scope private(c) allocate(allocator(omp_const_mem_alloc):-10)
|
|
// expected-error@+4 {{expected ',' or ')' in 'allocate' clause}}
|
|
// expected-error@+3 {{expected ')'}}
|
|
// expected-warning@+2 {{extra tokens at the end of '#pragma omp scope' are ignored}}
|
|
// expected-note@+1 {{to match this '('}}
|
|
#pragma omp scope private(a,b,c) allocate(allocator(omp_const_mem_alloc):c:b;a)
|
|
// expected-error@+1 {{initializing 'const omp_allocator_handle_t' (aka 'const enum omp_allocator_handle_t') with an expression of incompatible type 'int'}}
|
|
#pragma omp scope private(c,a,b) allocate(allocator(myAlloc()):a,b,c)
|
|
// expected-error@+2 {{missing ':' after allocate clause modifier}}
|
|
// expected-error@+1 {{expected expression}}
|
|
#pragma omp scope private(c) allocate(allocator(omp_default_mem_alloc);c)
|
|
// expected-error@+2 {{duplicate modifier 'allocator' in 'allocate' clause}}
|
|
// expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
|
|
#pragma omp scope private(a) allocate(allocator(omp_default_mem_alloc), allocator(omp_default_mem_alloc), align(3) : a)
|
|
// expected-error@+4 {{expected '('}}
|
|
// expected-error@+3 {{expected expression}}
|
|
// expected-error@+2 {{expected ')'}}
|
|
// expected-note@+1 {{to match this '('}}
|
|
#pragma omp scope private(a) allocate(allocator
|
|
// expected-error@+4 {{expected '('}}
|
|
// expected-error@+3 {{expected expression}}
|
|
// expected-error@+2 {{expected ')'}}
|
|
// expected-note@+1 {{to match this '('}}
|
|
#pragma omp scope private(b) allocate(align
|
|
// expected-error@+1 {{duplicate modifier 'align' in 'allocate' clause}}
|
|
#pragma omp scope private(a) allocate(align(8), align(4) : a)
|
|
// expected-error@+5 {{use of undeclared identifier 'align'}}
|
|
// expected-error@+4 {{expected ',' or ')' in 'allocate' clause}}
|
|
// expected-error@+3 {{expected ')'}}
|
|
// expected-note@+2 {{to match this '('}}
|
|
// expected-error@+1 {{expected variable name}}
|
|
#pragma omp scope private(a) allocate(omp_default_mem_alloc, align(8) : a)
|
|
// expected-error@+3 {{expected modifier in 'allocate' clause}}
|
|
// expected-error@+2 {{missing ':' after allocate clause modifier}}
|
|
// expected-error@+1 {{expected expression}}
|
|
#pragma omp scope private(a) allocate(align(8), omp_default_mem_alloc : a)
|
|
// expected-error@+5 {{expected ',' or ')' in 'allocate' clause}}
|
|
// expected-error@+4 {{expected ')'}}
|
|
// expected-note@+3 {{to match this '('}}
|
|
// expected-error@+2 {{expected variable name}}
|
|
// expected-error@+1 {{expected variable name}}
|
|
#pragma omp scope private(a) allocate(omp_default_mem_alloc, omp_default_mem_alloc : a)
|
|
// expected-error@+2 {{use of undeclared identifier 'undefinedVar'}}
|
|
// expected-error@+1 {{expected expression}}
|
|
#pragma omp scope private(a) allocate(undefinedVar : a)
|
|
// expected-error@+1 {{expected expression}}
|
|
#pragma omp scope private(a) allocate(align(8), allocator(omp_default_mem_alloc) : )
|
|
// expected-error@+2 {{missing ':' after allocate clause modifier}}
|
|
// expected-error@+1 {{expected expression}}
|
|
#pragma omp scope private(a) allocate(align(8), allocator(omp_default_mem_alloc) )
|
|
// expected-error@+3 {{expected expression}}
|
|
// expected-error@+2 {{expected ')'}}
|
|
// expected-note@+1 {{to match this '('}}
|
|
#pragma omp scope private(a) allocate(align(8), allocator(omp_default_mem_alloc) :
|
|
|
|
// expected-error@+4 {{missing ':' after allocate clause modifier}}
|
|
// expected-error@+3 {{expected expression}}
|
|
// expected-error@+2 {{expected ')'}}
|
|
// expected-note@+1 {{to match this '('}}
|
|
#pragma omp scope private(a) allocate(align(8), allocator(omp_default_mem_alloc)
|
|
// expected-error@+4 {{expected '('}}
|
|
// expected-error@+3 {{expected '('}}
|
|
// expected-error@+2 {{expected expression}}
|
|
// expected-error@+1 {{use of undeclared identifier 'allocator'}}
|
|
#pragma omp scope private(a) allocate(align, allocator : )
|
|
// expected-error@+7 {{expected expression}}
|
|
// expected-error@+6 {{expected expression}}
|
|
// expected-error@+5 {{expected expression}}
|
|
// expected-error@+4 {{use of undeclared identifier 'allocator'}}
|
|
// expected-error@+3 {{expected ',' or ')' in 'allocate' clause}}
|
|
// expected-error@+2 {{expected ')'}}
|
|
// expected-note@+1 {{to match this '('}}
|
|
#pragma omp scope private(a) allocate(align(), allocator() : )
|
|
++a;
|
|
}
|