aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaOpenMP.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-03-20Revert "[clang] improve class type sugar preservation in pointers to ↵Matheus Izvekov1-2/+3
members" (#132215) Reverts llvm/llvm-project#130537 This missed updating lldb, which we didn't notice due to lack of pre-commit CI.
2025-03-20[clang] improve class type sugar preservation in pointers to members (#130537)Matheus Izvekov1-3/+2
This changes the MemberPointerType representation to use a NestedNameSpecifier instead of a Type to represent the class. Since the qualifiers are always parsed as nested names, there was an impedance mismatch when converting these back and forth into types, and this led to issues in preserving sugar. The nested names are indeed a better match for these, as the differences which a QualType can represent cannot be expressed syntactically, and it also represents the use case more exactly, being either dependent or referring to a CXXRecord, unqualified. This patch also makes the MemberPointerType able to represent sugar for a {up/downcast}cast conversion of the base class, although for now the underlying type is canonical, as preserving the sugar up to that point requires further work. As usual, includes a few drive-by fixes in order to make use of the improvements, and removing some duplications, for example CheckBaseClassAccess is deduplicated from across SemaAccess and SemaCast.
2025-03-14[Sema] Avoid repeated hash lookups (NFC) (#131263)Kazu Hirata1-6/+5
2025-03-11[clang] [OpenMP] New OpenMP 6.0 self_maps clause (#129888)Ritanya-B-Bharadwaj1-1/+15
Initial parsing/sema support for self maps in map and requirement clause [Sections 7.9.6 and 10.5.1.6 in OpenMP 6.0 spec]
2025-02-13[Clang] [OpenMP] Add support for '#pragma omp stripe'. (#126927)Zahira Ammarguellat1-26/+290
This patch was reviewed and approved here: https://github.com/llvm/llvm-project/pull/119891 However it has been reverted here: https://github.com/alejandro-alvarez-sonarsource/llvm-project/commit/083df25dc256154cccbc0e127d79fbac4d0583c5 due to a build issue here: https://lab.llvm.org/buildbot/#/builders/51/builds/10694 This patch is reintroducing the support.
2025-02-11Revert "[Clang] [OpenMP] Add support for '#pragma omp stripe'. (#119891)"Kazu Hirata1-290/+26
This reverts commit 070f84ebc89b11df616a83a56df9ac56efbab783. Buildbot failure: https://lab.llvm.org/buildbot/#/builders/51/builds/10694
2025-02-11[Clang] [OpenMP] Add support for '#pragma omp stripe'. (#119891)Zahira Ammarguellat1-26/+290
Implement basic parsing and semantic support for `#pragma omp stripe` constuct introduced in https://www.openmp.org/wp-content/uploads/[OpenMP-API-Specification-6-0.pdf](https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-6-0.pdf), section 11.7.
2025-02-11[Sema] Avoid repeated hash lookups (NFC) (#126674)Kazu Hirata1-6/+6
2025-02-07[OpenMP] Fix infinite loop on recursive initializers (#126269)Joseph Huber1-0/+4
Summary: If the user tried to initialize a gobal declare target variable with itself the compiler will hang forever. Add a visited set to make sure this stops. Fixes: https://github.com/llvm/llvm-project/issues/69194
2025-02-06[clang][OpenMP] New OpenMP 6.0 assumption clause, 'no_openmp_constructs' ↵David Pagan1-0/+2
(#125933) Add initial parsing/sema support for new assumption clause so clause can be specified. For now, it's ignored, just like the others. Added support for 'no_openmp_construct' to release notes. Testing - Updated appropriate LIT tests. - Testing: check-all
2025-02-05[clang][OpenMP] OpenMP 6.0 updates to restrictions with order/concurrent ↵David Pagan1-8/+22
(#125621) From OpenMP 6.0 features list - OpenMP directives in concurrent loop regions - atomics constructs on concurrent loop regions - Lift nesting restriction on concurrent loop Testing - Updated test/OpenMP/for_order_messages.cpp - check-all
2025-02-05[OpenMP]Initial parsing/sema support for target_device selector set (#118471)Ritanya-B-Bharadwaj1-1/+33
This patch adds initial support for target_device selector set - Section 9.2 (Spec 6.0)
2025-01-13[clang][OpenMP] Add 'align' modifier for 'allocate' clause (#121814)David Pagan1-35/+67
The 'align' modifier is now accepted in the 'allocate' clause. Added LIT tests covering codegen, PCH, template handling, and serialization for 'align' modifier. Added support for align-modifier to release notes. Testing - New allocate modifier LIT tests. - OpenMP LIT tests. - check-all
2024-11-27[Sema] Migrate away from PointerUnion::{is,get} (NFC) (#117498)Kazu Hirata1-4/+4
Note that PointerUnion::{is,get} have been soft deprecated in PointerUnion.h: // FIXME: Replace the uses of is(), get() and dyn_cast() with // isa<T>, cast<T> and the llvm::dyn_cast<T> I'm not touching PointerUnion::dyn_cast for now because it's a bit complicated; we could blindly migrate it to dyn_cast_if_present, but we should probably use dyn_cast when the operand is known to be non-null.
2024-11-25seq_cst is allowed in Flush since OpenMP 5.1. (#114072)ShashwathiNavada1-1/+2
This PR adds support seq_cst (sequential consistency) clause for the flush directive in OpenMP. The seq_cst clause enforces a stricter memory ordering, ensuring that all threads observe the memory effects of the flush in the same order, improving consistency in memory operations across threads. --------- Co-authored-by: Shashwathi N <nshashwa@pe28vega.hpc.amslabs.hpecorp.net> Co-authored-by: CHANDRA GHALE <chandra.nitdgp@gmail.com>
2024-11-16[Sema] Remove unused includes (NFC) (#116461)Kazu Hirata1-3/+0
Identified with misc-include-cleaner.
2024-11-15[Clang] Use TargetInfo when deciding if an address space is compatible ↵Joseph Huber1-3/+5
(#115777) Summary: Address spaces are used in several embedded and GPU targets to describe accesses to different types of memory. Currently we use the address space enumerations to control which address spaces are considered supersets of eachother, however this is also a target level property as described by the C standard's passing mentions. This patch allows the address space checks to use the target information to decide if a pointer conversion is legal. For AMDGPU and NVPTX, all supported address spaces can be converted to the default address space. More semantic checks can be added on top of this, for now I'm mainly looking to get more standard semantics working for C/C++. Right now the address space conversions must all be done explicitly in C/C++ unlike the offloading languages which define their own custom address spaces that just map to the same target specific ones anyway. The main question is if this behavior is a function of the target or the language.
2024-11-15[Clang] [NFC] Refactor AST visitors in Sema and the static analyser to use ↵Sirraide1-12/+12
DynamicRecursiveASTVisitor (#115144) This pr refactors all recursive AST visitors in `Sema`, `Analyze`, and `StaticAnalysis` to inherit from DRAV instead. This is over half of the visitors that inherit from RAV directly. See also #115132, #110040, #93462 LLVM Compile-Time Tracker link for this branch: https://llvm-compile-time-tracker.com/compare.php?from=5adb5c05a2e9f31385fbba8b0436cbc07d91a44d&to=b58e589a86c06ba28d4d90613864d10be29aa5ba&stat=instructions%3Au
2024-11-05[clang][OpenMP] Add 'allocator' modifier for 'allocate' clause. (#114883)David Pagan1-4/+17
The 'allocator' modifier is now accepted in the 'allocate' clause. Added LIT tests covering codegen, PCH, template handling, and serialization for 'allocator' modifier. Added support for allocator-modifier to release notes. Testing - New allocate modifier LIT tests. - OpenMP LIT tests. - check-all - relevant sollve_vv test cases tests/5.2/scope/test_scope_allocate_construct.c
2024-10-24[clang] Use {} instead of std::nullopt to initialize empty ArrayRef (#109399)Jay Foad1-4/+4
Follow up to #109133.
2024-10-21[NFC][Sema][OpenMP] Fix free-nonheap-object warning (#112942)Jinsong Ji1-2/+4
This is one of the many PRs to fix errors with LLVM_ENABLE_WERROR=on. Built by GCC 11. Fix warning In destructor ‘llvm::APInt::~APInt()’, inlined from ‘llvm::APInt::~APInt()’ at llvm-project/llvm/include/llvm/ADT/APInt.h:190:3, inlined from ‘llvm::APSInt::~APSInt()’ at llvm-project/llvm/include/llvm/ADT/APSInt.h:23:21, inlined from ‘bool checkOMPArraySectionConstantForReduction(clang::ASTContext&, const clang::ArraySectionExpr*, bool&, llvm::SmallVectorImpl<llvm::APSInt>&)’ at llvm-project/clang/lib/Sema/SemaOpenMP.cpp:18357:45, inlined from ‘bool actOnOMPReductionKindClause(clang::Sema&, {anonymous}::DSAStackTy*, clang::OpenMPClauseKind, llvm::ArrayRef<clang::Expr*>, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation, clang::CXXScopeSpec&, const clang::DeclarationNameInfo&, llvm::ArrayRef<clang::Expr*>, {anonymous}::ReductionData&)’ at llvm-project/clang/lib/Sema/SemaOpenMP.cpp:18715:68: llvm-project/llvm/include/llvm/ADT/APInt.h:192:18: error: ‘void operator delete [](void*)’ called on a pointer to an unallocated object ‘1’ [-Werror=free-nonheap-object] 192 | delete[] U.pVal; | ^~~~
2024-10-17[APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) ↵Nikita Popov1-1/+3
(#80309) This fixes all the places that hit the new assertion added in https://github.com/llvm/llvm-project/pull/106524 in tests. That is, cases where the value passed to the APInt constructor is not an N-bit signed/unsigned integer, where N is the bit width and signedness is determined by the isSigned flag. The fixes either set the correct value for isSigned, set the implicitTrunc flag, or perform more calculations inside APInt. Note that the assertion is currently still disabled by default, so this patch is mostly NFC.
2024-10-09[Clang][OpenMP] Add permutation clause (#92030)Michael Kruse1-2/+85
Add the permutation clause for the interchange directive which will be introduced in the upcoming OpenMP 6.0 specification. A preview has been published in [Technical Report12](https://www.openmp.org/wp-content/uploads/openmp-TR12.pdf).
2024-10-05[Sema] Avoid repeated hash lookups (NFC) (#111227)Kazu Hirata1-12/+6
2024-09-30[clang] Fix static analyzer concerns (#110243)Mariya Podchishchaeva1-1/+1
It seems in checkOpenMPIterationSpace `OrderedLoopCountExpr` can also be null, so check before dereferencing.
2024-09-17[clang][OpenMP] Slightly refactor EndOpenMPDSABlock for readability, NFC ↵Krzysztof Parzyszek1-102/+109
(#109003) Change the loop ``` if (isOpenMPExecutableDirective) for (Clause) if (Clause is kind1) multi line do something1; else if (Clause is kind2) ... ... ``` to ``` auto do1 = ...do something1...; auto do2 = ...do something2...; ... if (isOpenMPExecutableDirective) for (Clause) if (Clause is kind1) do1(); else if (Clause is kind2) do2(); ... ... ```
2024-09-07[clang][OpenMP] Simplify handling of implicit DSA/mapping information (#106786)Krzysztof Parzyszek1-62/+47
Create `VariableImplicitInfo` to hold the data. Most of it is used all at once, so aggregating it seems like a good idea.
2024-08-29[NFC][Sema] Move `Sema::AssignmentAction` into its own scoped enum (#106453)Dan Liew1-35/+41
The primary motivation behind this is to allow the enum type to be referred to earlier in the Sema.h file which is needed for #106321. It was requested in #106321 that a scoped enum be used (rather than moving the enum declaration earlier in the Sema class declaration). Unfortunately doing this creates a lot of churn as all use sites of the enum constants had to be changed. Appologies to all downstream forks in advanced. Note the AA_ prefix has been dropped from the enum value names as they are now redundant.
2024-08-19[Clang] Fix ICE in SemaOpenMP with structured binding (#104822)Yuxuan Chen1-10/+2
Fixes https://github.com/llvm/llvm-project/issues/104810. Clang currently crashes on the following program: ``` struct S { int i; }; auto [a] = S{1}; void foo() { a; } ``` when `-fopenmp` is enabled. Because `a` is neither `VarDecl` nor `FieldDecl`. It's a `BindingDecl` that's not handled in `SemaOpenMP.cpp`'s `getCanonicalDecl`. It appears to me that this pattern matching is merely just for a refined return type of the overrides. It can also be achieved with just using the virtual `Decl::getCanonicalDecl()` instead. Do the final casting should be safe for `ValueDecl`s.
2024-08-19[clang][OpenMP] Diagnose badly-formed collapsed imperfect loop nests ↵Julian Brown1-8/+133
(#60678) (#101305) This patch fixes a couple of cases where Clang aborts with loop nests that are being collapsed (via the relevant OpenMP clause) into a new, combined loop. The problematic cases happen when a variable declared within the loop nest is used in the (init, condition, iter) statement of a more deeply-nested loop. I don't think these cases (generally?) fall under the non-rectangular loop nest rules as defined in OpenMP 5.0+, but I could be wrong (and anyway, emitting an error is better than crashing). In terms of implementation: the crash happens because (to a first approximation) all the loop bounds calculations are pulled out to the start of the new, combined loop, but variables declared in the loop nest "haven't been seen yet". I believe there is special handling for iteration variables declared in "for" init statements, but not for variables declared elsewhere in the "imperfect" parts of a loop nest. So, this patch tries to diagnose the troublesome cases before they can cause a crash. This is slightly awkward because at the point where we want to do the diagnosis (SemaOpenMP.cpp), we don't have scope information readily available. Instead we "manually" scan through the AST of the loop nest looking for var decls (ForVarDeclFinder), then we ensure we're not using any of those in loop control subexprs (ForSubExprChecker). All that is only done when we have a "collapse" clause. Range-for loops can also cause crashes at present without this patch, so are handled too.
2024-08-18[clang][OpenMP] Change /* ParamName */ to /*ParamName=*/, NFCKrzysztof Parzyszek1-44/+43
Change foo(/* Index */ 0); to foo(/*Index=*/0); There was a mix of these two formats in the source. Clang-format treats the latter one a bit better, so use that one consistently.
2024-08-18[clang][OpenMP] Avoid multiple calls to getCurrentDirective in DSAChecker, NFCKrzysztof Parzyszek1-9/+7
2024-08-10[Clang][Sema][OpenMP] Allow `thread_limit` to accept multiple expressions ↵Shilei Tian1-19/+39
(#102715)
2024-08-06[Clang][Sema] Make UnresolvedLookupExprs in class scope explicit ↵Krystian Stasiowski1-2/+4
specializations instantiation dependent (#100392) A class member named by an expression in a member function that may instantiate to a static _or_ non-static member is represented by a `UnresolvedLookupExpr` in order to defer the implicit transformation to a class member access expression until instantiation. Since `ASTContext::getDecltypeType` only creates a `DecltypeType` that has a `DependentDecltypeType` as its canonical type when the operand is instantiation dependent, and since we do not transform types unless they are instantiation dependent, we need to mark the `UnresolvedLookupExpr` as instantiation dependent in order to correctly build a `DecltypeType` using the expression as its operand with a `DependentDecltypeType` canonical type. Fixes #99873.
2024-08-06[Clang][Sema][OpenMP] Allow `num_teams` to accept multiple expressions (#99732)Shilei Tian1-18/+73
By the OpenMP standard, `num_teams` clause can only accept one expression (for now). In this patch, we extend it to allow to accept multiple expressions when it is used with `target teams ompx_bare` construct. This will allow to launch a multi-dim grid, same as CUDA/HIP.
2024-08-05[OpenMP] OpenMP 5.1 "assume" directive parsing support (#92731)Julian Brown1-0/+70
This is a minimal patch to support parsing for "omp assume" directives. These are meant to be hints to a compiler's optimisers: as such, it is legitimate (if not very useful) to ignore them. The patch builds on top of the existing support for "omp assumes" directives (note spelling!). Unlike the "omp [begin/end] assumes" directives, "omp assume" is associated with a compound statement, i.e. it can appear within a function. The "holds" assumption could (theoretically) be mapped onto the existing builtin "__builtin_assume", though the latter applies to a single point in the program, and the former to a range (i.e. the whole of the associated compound statement). This patch fixes sollve's OpenMP 5.1 "omp assume"-based tests.
2024-08-04[clang] Construct SmallVector with ArrayRef (NFC) (#101898)Kazu Hirata1-7/+3
2024-08-02[OpenMP] Generate implicit default mapper for mapping array section. (#101101)jyu2-git1-0/+215
This is only for struct containing nested structs with user defined mappers. Add four functions: 1>buildImplicitMap: build map for default mapper 2>buildImplicitMapper: build default mapper. 3>hasUserDefinedMapper for given mapper name and mapper type, lookup user defined map, if found one return true. 4>isImplicitMapperNeeded check if Mapper is needed During create map, in checkMappableExpressionList, call isImplicitMapperNeeded when it return true, call buildImplicitMapper to generate implicit mapper and added to map clause. https://github.com/llvm/llvm-project/pull/101101
2024-07-30[clang][OpenMP] Rename `varlists` to `varlist`, NFC (#101058)Krzysztof Parzyszek1-9/+9
It returns a range of variables (via Expr*), not a range of lists.
2024-07-30[Clang][Sema][NFC] Remove duplicate check in if-condition (#101070)Jannick Kremer1-2/+1
Resolves #101041
2024-07-25[OpenMP] Defaultmap: fixes scalar issue, adds all variable category (#99315)nicebert1-11/+14
Fixes issue with defaultmap where scalar isn't handled correctly for present modifier. Adds all variable cateogry introduced in OpenMP 5.2 and alters existing tests for error messages to check OpenMP 5.2 defaultmap messages.
2024-07-23[clang][OpenMP] Mark all SIMD regions as non-throwing (#100162)Krzysztof Parzyszek1-15/+24
[4.5:75:19], [5.0:114:3], [5.1:137:21], [5.2:235:30] "No exception can be raised in the **simd** region."
2024-07-23[clang][OpenMP] Move "loop" directive mapping from sema to codegen (#99905)Krzysztof Parzyszek1-174/+48
Given "loop" construct, clang will try to treat it as "for", "distribute" or "simd", depending on either the implied binding, or the bind clause if present. This patch moves the code that performs this construct remapping from sema to codegen. For a "loop" construct without a bind clause, this patch will create an implicit bind clause based on implied binding to simplify further analysis. During codegen the function `EmitOMPGenericLoopDirective` (i.e. "loop") will invoke the "emit" functions for "for", "distribute" or "simd", depending on the bind clause. --------- Co-authored-by: Alexey Bataev <a.bataev@gmx.com>
2024-07-22[clang][OpenMP] Avoid names that hide existing variables, NFCKrzysztof Parzyszek1-6/+6
2024-07-19[Clang][OpenMP] Add interchange directive (#93022)Michael Kruse1-0/+160
Add the interchange directive which will be introduced in the upcoming OpenMP 6.0 specification. A preview has been published in [Technical Report 12](https://www.openmp.org/wp-content/uploads/openmp-TR12.pdf).
2024-07-18[Clang][OpenMP] Add reverse directive (#92916)Michael Kruse1-0/+195
Add the reverse directive which will be introduced in the upcoming OpenMP 6.0 specification. A preview has been published in [Technical Report 12](https://www.openmp.org/wp-content/uploads/openmp-TR12.pdf). --------- Co-authored-by: Alexey Bataev <a.bataev@outlook.com>
2024-07-15[clang[OpenMP] Revert accidentally included changes from previous commitKrzysztof Parzyszek1-16/+8
2024-07-15[clang][OpenMP] Simplify check for taskloop in `ActOnOpenMPLoopInitia… ↵Krzysztof Parzyszek1-12/+21
(#98633) …lization` Replace the explicit list of compound directives ending with taskloop with checking for the last leaf construct.
2024-07-15[clang][OpenMP] Remove compound directives from `checkNestingOfRegions` (#98387)Krzysztof Parzyszek1-54/+42
Express the constraints via constituent directives.
2024-07-12[clang][OpenMP] Add early exit to/unindent `ActOnOpenMPLoopInitialization`Krzysztof Parzyszek1-74/+71
NFC