aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaOpenMP.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-07-11[clang][OpenMP] Fix region nesting check for `scan` directive (#98386)Krzysztof Parzyszek1-8/+13
The previous check was inconsistent. For example, it would allow ``` #pragma omp target #pragma omp parallel for for (...) { #pragma omp scan } ``` but not ``` #pragma omp target parallel for for (...) { #pragma omp scan } ``` Make the check conform to the wording on the specification.
2024-07-09[clang][OpenMP] Make `getOpenMPCaptureRegionForClause` more generic (#98180)Krzysztof Parzyszek1-915/+83
Rewrite `getOpenMPCaptureRegionForClause` with more generic code, relying on directive composition instead of listing individual directives.
2024-07-03[clang][OpenMP] Change `ActOnOpenMPRegionStart` to use captured regions (#97445)Krzysztof Parzyszek1-434/+166
Instead of checking specific directives, this function now gets the list of captured regions, and processes them individually. This makes this function directive-agnostic (except a few cases of leaf constructs).
2024-07-03[clang][OpenMP] Use leaf constructs in `mapLoopConstruct` (#97446)Krzysztof Parzyszek1-4/+9
This removes mentions of specific combined directives. Also, add a quote from the OpenMP spec to explain the code dealing with the `bind` clause.
2024-07-01[clang][OpenMP] Implement `isOpenMPCapturingDirective` (#97090)Krzysztof Parzyszek1-12/+2
Check if the given directive can capture variables, and thus needs a captured statement. Simplify some code using this function.
2024-07-01[clang][OpenMP] Unindent `checkNestingOfRegions`, NFCKrzysztof Parzyszek1-283/+279
The entire body of the function is inside of an if-statement, followed by a "return false". Invert the condition and return early, unindent and clang-format the function.
2024-06-29[clang][OpenMP] Implement `isOpenMPExecutableDirective` (#97089)Krzysztof Parzyszek1-0/+2
What is considered "executable" in clang differs slightly from the OpenMP's "executable" category. In addition to the executable category, subsidiary directives, and OMPD_error are considered executable. Implement a function that performs that check.
2024-06-28[OpenMP] [NFC] SemaOpenMP.cpp and StmtOpenMP.cpp spelling fixes (#96814)Julian Brown1-22/+22
This patch just fixes a few spelling mistakes in the above two files. (I changed one British spelling to American -- analyse to analyze -- because the latter spelling is used elsewhere in file, and it's probably best to be consistent.)
2024-06-28[clang][OpenMP] Simplify handling of `if` clause (#96936)Krzysztof Parzyszek1-83/+5
Get the allowed name modifiers from the list of constituent leaf directives.
2024-06-27[clang][OpenMP] clang-format SemaOpenMP.cpp, NFCKrzysztof Parzyszek1-7/+6
There are only a handful of changes, and now the entire file can be kept clang-formatted.
2024-06-27[clang][OpenMP] Place some common code in functions (#96811)Krzysztof Parzyszek1-899/+165
There are chunks of code repeated in a number of functions. This patch moves some of that code into individual functions.
2024-06-24[clang][OpenMP] Fix teams nesting of region check (#94806)Mike Rice1-3/+7
The static verifier flagged dead code in the check since the loop will only execute once and never reach the iterator increment. The loop needs to iterate twice to correctly diagnose when a statement is after the teams. Since there are two iterations again, reset the iterator to the first teams directive when the double teams case is seen so the diagnostic can report both locations.
2024-06-10[OpenMP][NFC] Fix argument order of SourceLocations for allocate clause (#94777)Mike Rice1-1/+1
Static verifier caught passing ColonLoc/LParenLoc in wrong order. Marked as NFC since these don't seem to be used for anything currently that I can think to test for.
2024-06-10[clang][OpenMP][NFC] Remove unnecessary nullptr check (#94680)Mike Rice1-12/+11
Static verifier reports unchecked use of pointer after explicitly checking earlier in the function. It appears the pointer won't be a nullptr, so remove the unneeded check for consistency.
2024-06-05[clang] Split up `SemaDeclAttr.cpp` (#93966)Vlad Serebrennikov1-0/+38
This patch moves language- and target-specific functions out of `SemaDeclAttr.cpp`. As a consequence, `SemaAVR`, `SemaM68k`, `SemaMSP430`, `SemaOpenCL`, `SemaSwift` were created (but they are not the only languages and targets affected). Notable things are that `Sema.h` actually grew a bit, because of templated helpers that rely on `Sema` that I had to make available from outside of `SemaDeclAttr.cpp`. I also had to left CUDA-related in `SemaDeclAttr.cpp`, because it looks like HIP is building up on top of CUDA attributes. This is a follow-up to #93179 and continuation of efforts to split `Sema` up. Additional context can be found in #84184 and #92682.
2024-05-30[clang][NFC] Move `PDiag` into `SemaBase` (#93849)Vlad Serebrennikov1-8/+8
This patch moves `PDiag` into `SemaBase`, making it readily available everywhere across `Sema` without `SemaRef`, like the regular `Diag`.
2024-05-30[clang] fix(93002): clang/lib/Sema/SemaOpenMP.cpp:7405: Possible & / && ↵Oleksandr T1-1/+1
mixup ? (#93093) Fixes #93002
2024-05-22[Clang][OpenMP] Enable tile/unroll on iterator- and foreach-loops (#91459)Michael Kruse1-57/+140
OpenMP loop transformation did not work on a for-loop using an iterator or range-based for-loops. The first reason is that it combined the iterator's type for generated loops with the type of `NumIterations` as generated for any `OMPLoopBasedDirective` which is an integer. Fixed by basing all generated loop variables on `NumIterations`. Second, C++11 range-based for-loops include syntactic sugar that needs to be executed before the loop. This additional code is now added to the construct's Pre-Init lists. Third, C++20 added an initializer statement to range-based for-loops which is also added to the pre-init statement. PreInits used to be a `DeclStmt` which made it difficult to add arbitrary statements from `CXXRangeForStmt`'s syntactic sugar, especially the for-loops init statement which does not need to be a declaration. Change it to be a general `Stmt` that can be a `CompoundStmt` to hold arbitrary Stmts, including DeclStmts. This also avoids the `PointerUnion` workaround used by `checkTransformableLoopNest`. End-to-end tests are added to verify the expected number and order of loop execution and evaluations of expressions (such as iterator dereference). The order and number of evaluations of expressions in canonical loops is explicitly undefined by OpenMP but checked here for clarification and for changes to be noticed.
2024-05-16Avoid unevaluated implicit private (#92055)SunilKuravinakop1-1/+2
For every variable used under `#pragma omp task` directive (`DeclRefExpr`) an ImplicitPrivateVariable is created in the AST, if `private` or `shared` clauses are not present. If the variable has the property of `non_odr_use_unevaluated` e.g. for statements which use `sizeof( i )` `i` will have `non_odr_use_unevaluated` . In such cases CodeGen was asserting by avoiding emitting of LLVM IR for such variables. To prevent this assertion this checkin avoids adding the ImplicitPrivateVariable for variables with `non_odr_use_unevaluated`. --------- Authored-by: Sunil Kuravinakop <kuravina@pe28vega.us.cray.com>
2024-05-13[Clang][OpenMP][Tile] Allow non-constant tile sizes. (#91345)Michael Kruse1-23/+95
Allow non-constants in the `sizes` clause such as ``` #pragma omp tile sizes(a) for (int i = 0; i < n; ++i) ``` This is permitted since tile was introduced in [OpenMP 5.1](https://www.openmp.org/spec-html/5.1/openmpsu53.html#x78-860002.11.9). It is possible to sneak-in negative numbers at runtime as in ``` int a = -1; #pragma omp tile sizes(a) ``` Even though it is not well-formed, it should still result in every loop iteration to be executed exactly once, an invariant of the tile construct that we should ensure. `ParseOpenMPExprListClause` is extracted-out to be reused by the `permutation` clause of the `interchange` construct. Some care was put into ensuring correct behavior in template contexts.
2024-05-13[Clang][OpenMP] Fix unused lambda capture warning.Michael Kruse1-4/+2
2024-05-13[Clang][OpenMP][Tile] Ensure AST node uniqueness. (#91325)Michael Kruse1-25/+50
One of the constraints of an AST is that every node object must appear at most once, hence we define lamdas that create a new AST node at every use.
2024-04-30Reapply "[Clang][Sema] Diagnose class member access expressions naming ↵Krystian Stasiowski1-5/+12
non-existent members of the current instantiation prior to instantiation in the absence of dependent base classes (#84050)" (#90152) Reapplies #84050, addressing a bug which cases a crash when an expression with the type of the current instantiation is used as the _postfix-expression_ in a class member access expression (arrow form).
2024-04-26Revert "[Clang][Sema] Diagnose class member access expressions naming ↵Pranav Kant1-12/+5
non-existent members of the current instantiation prior to instantiation in the absence of dependent base classes (#84050)" This reverts commit a8fd0d029dca7d17eee72d0445223c2fe1ee7758.
2024-04-25[Clang][Sema] Diagnose class member access expressions naming non-existent ↵Krystian Stasiowski1-5/+12
members of the current instantiation prior to instantiation in the absence of dependent base classes (#84050) Consider the following: ```cpp template<typename T> struct A { auto f() { return this->x; } }; ``` Although `A` has no dependent base classes and the lookup context for `x` is the current instantiation, we currently do not diagnose the absence of a member `x` until `A<T>::f` is instantiated. This patch moves the point of diagnosis for such expressions to occur at the point of definition (i.e. prior to instantiation).
2024-04-25[NFC] Generalize ArraySections to work for OpenACC in the future (#89639)Erich Keane1-36/+35
OpenACC is going to need an array sections implementation that is a simpler version/more restrictive version of the OpenMP version. This patch moves `OMPArraySectionExpr` to `Expr.h` and renames it `ArraySectionExpr`, then adds an enum to choose between the two. This also fixes a couple of 'drive-by' issues that I discovered on the way, but leaves the OpenACC Sema parts reasonably unimplemented (no semantic analysis implementation), as that will be a followup patch.
2024-04-22Reapply "[Clang][Sema] Fix crash when 'this' is used in a dependent class ↵Krystian Stasiowski1-2/+2
scope function template specialization that instantiates to a static member function (#87541, #88311)" (#88731) Reapplies #87541 and #88311 (again) addressing the bug which caused expressions naming overload sets to be incorrectly rebuilt, as well as the bug which caused base class members to always be treated as overload sets. The primary change since #88311 is `UnresolvedLookupExpr::Create` is called directly in `BuildPossibleImplicitMemberExpr` with `KnownDependent` as `true` (which causes the expression type to be set to `ASTContext::DependentTy`). This ensures that any further semantic analysis involving the type of the potentially implicit class member access expression is deferred until instantiation.
2024-04-17[clang][NFC] Refactor `Sema::RedeclarationKind`Vlad Serebrennikov1-1/+1
This patch converts the enum into scoped enum, and moves it into its own header for the time being. It's definition is needed in `Sema.h`, and is going to be needed in upcoming `SemaObjC.h`. `Lookup.h` can't hold it, because it includes `Sema.h`.
2024-04-16[clang] Introduce `SemaOpenMP` (#88642)Vlad Serebrennikov1-1827/+2506
This patch moves OpenMP-related entities out of `Sema` to a newly created `SemaOpenMP` class. This is a part of the effort to split `Sema` up, and follows the recent example of CUDA, OpenACC, SYCL, HLSL. Additional context can be found in https://github.com/llvm/llvm-project/pull/82217, https://github.com/llvm/llvm-project/pull/84184, https://github.com/llvm/llvm-project/pull/87634.
2024-04-11[NFC][Clang] Improve const correctness for IdentifierInfo (#79365)Bill Wendling1-1/+1
The IdentifierInfo isn't typically modified. Use 'const' wherever possible.
2024-04-10[OpenMP][CodeGen] Improved codegen for combined loop directives (#87278)David Pagan1-3/+83
IR for 'target teams loop' is now dependent on suitability of associated loop-nest. If a loop-nest: - does not contain a function call, or - the -fopenmp-assume-no-nested-parallelism has been specified, - or the call is to an OpenMP API AND - does not contain nested loop bind(parallel) directives then it can be emitted as 'target teams distribute parallel for', which is the current default. Otherwise, it is emitted as 'target teams distribute'. Added debug output indicating how 'target teams loop' was emitted. Flag is -mllvm -debug-only=target-teams-loop-codegen Added LIT tests explicitly verifying 'target teams loop' emitted as a parallel loop and a distribute loop. Updated other 'loop' related tests as needed to reflect change in IR. - These updates account for most of the changed files and additions/deletions.
2024-03-26[NFC] Refactor ConstantArrayType size storage (#85716)Chris B1-3/+3
In PR #79382, I need to add a new type that derives from ConstantArrayType. This means that ConstantArrayType can no longer use `llvm::TrailingObjects` to store the trailing optional Expr*. This change refactors ConstantArrayType to store a 60-bit integer and 4-bits for the integer size in bytes. This replaces the APInt field previously in the type but preserves enough information to recreate it where needed. To reduce the number of places where the APInt is re-constructed I've also added some helper methods to the ConstantArrayType to allow some common use cases that operate on either the stored small integer or the APInt as appropriate. Resolves #85124.
2024-03-14[clang][OpenMP] Fix directive in ActOnOpenMPTargetParallelForSimdDire… ↵Krzysztof Parzyszek1-1/+2
(#85217) …ctive The function `ActOnOpenMPTargetParallelForSimdDirective` gets the number of capture levels for OMPD_target_parallel_for, whereas the intended directive is OMPD_target_parallel_for_simd.
2024-03-09[Clang][C++23] Implement P1774R8: Portable assumptions (#81014)Sirraide1-3/+3
This implements the C++23 `[[assume]]` attribute. Assumption information is lowered to a call to `@llvm.assume`, unless the expression has side-effects, in which case it is discarded and a warning is issued to tell the user that the assumption doesn’t do anything. A failed assumption at compile time is an error (unless we are in `MSVCCompat` mode, in which case we don’t check assumptions at compile time). Due to performance regressions in LLVM, assumptions can be disabled with the `-fno-assumptions` flag. With it, assumptions will still be parsed and checked, but no calls to `@llvm.assume` will be emitted and assumptions will not be checked at compile time.
2024-03-06[OpenMP] Parse and Sema support for declare target in local scope (#83223)Sandeep Kosuri1-0/+9
- adds Parse and Sema support for the `declare target` directive inside a function scope.
2024-02-29[OpenMP][Clang] Enable inscan modifier for generic datatypes (#82220)Animesh Kumar1-1/+2
This patch fixes the #67002 ([OpenMP][Clang] Scan Directive not supported for Generic types). It disables the Sema checks/analysis that are run on the helper arrays which go into the implementation of the `omp scan` directive until the template instantiation happens. Grateful to @alexey-bataev for suggesting these changes.
2024-02-07[Clang][OpenMP] Fix `!isNull() && "Cannot retrieve a NULL type pointer"' ↵Shourya Goel1-0/+2
fail. (#81015) Fixes : #69085 , #69200 **PR SUMMARY**: "Added Null check for negative sized array and a test for the same"
2024-01-31[OpenMP] atomic compare weak : Parser & AST support (#79475)SunilKuravinakop1-1/+32
This is a support for " #pragma omp atomic compare weak". It has Parser & AST support for now. --------- Authored-by: Sunil Kuravinakop <kuravina@pe28vega.us.cray.com>
2024-01-27[clang, SystemZ] Support -munaligned-symbols (#73511)Jonas Paulsson1-1/+1
When this option is passed to clang, external (and/or weak) symbols are not assumed to have the minimum ABI alignment normally required. Symbols defined locally that are not weak are however still given the minimum alignment. This is implemented by passing a new parameter to getMinGlobalAlign() named HasNonWeakDef that is used to return the right alignment value. This is needed when external symbols created from a linker script may not get the ABI minimum alignment and must therefore be treated as unaligned by the compiler.
2024-01-17[Clang][Sema][NFC] Remove unused Scope* parameter from ↵Krystian Stasiowski1-2/+2
Sema::GetTypeForDeclarator and Sema::ActOnTypeName (#78325) Split from #78274
2024-01-09[OpenMP] Patch for Support to loop bind clause : Checking Parent Region (#76938)SunilKuravinakop1-15/+41
Changes uploaded to the phabricator on Dec 16th are lost because the phabricator is down. Hence re-uploading it to the github.com. Changes to be committed: modified: clang/include/clang/Sema/Sema.h modified: clang/lib/Sema/SemaOpenMP.cpp modified: clang/test/OpenMP/generic_loop_ast_print.cpp modified: clang/test/OpenMP/loop_bind_messages.cpp modified: clang/test/PCH/pragma-loop.cpp --------- Co-authored-by: Sunil Kuravinakop
2024-01-02[OpenMP] atomic compare fail : Codegen support (#75709)SunilKuravinakop1-1/+1
This is a continuation of https://reviews.llvm.org/D123235 ([OpenMP] atomic compare fail : Parser & AST support). In this branch Support for codegen support for atomic compare fail is being added. --------- Co-authored-by: Sunil Kuravinakop
2023-12-18[OpenMP][Clang] Force use of `num_teams` and `thread_limit` for bare kernel ↵Shilei Tian1-0/+13
(#68373) This patch makes `num_teams` and `thread_limit` mandatory for bare kernels, similar to a reguar kernel language that when launching a kernel, the grid size has to be set explicitly.
2023-11-29Fix accsessing "PresentModifierLocs" array beyond its end. (#73579)jyu2-git1-3/+3
Currently PresentModifierLocs defined with size DefaultmapKindNum; where DefaultmapKindNum = OMPC_DEFAULTMAP_pointer + 1 Before 5.0 variable-category can not be omitted. For the test like \#pragma omp target map(tofrom: errors) defaultmap(present) error would be mitted. After 5.0 that is allowd. When try to: PresentModifierLocs[DMC->getDefaultmapKind()] = DMC->getDefaultmapModifierLoc(); It is accessed beyond array end. To fix this using OMPC_DEFAULTMAP_unknow instead OMPC_DEFAULTMAP_poiner.
2023-11-26[OpenMP] atomic compare fail : Parser & AST supportSunil Kuravinakop1-0/+34
Diff Revision: https://reviews.llvm.org/D123235
2023-11-20Revert "[OpenMP] atomic compare fail : Parser & AST support"Krzysztof Parzyszek1-34/+0
This reverts commit edd675ac283909397880f85ba68d0d5f99dc1be2. This breaks clang build where every component is a shared library. The file clang/lib/Basic/OpenMPKinds.cpp, which is a part of libclangBasic.so, uses `getOpenMPClauseName` which isn't: /usr/bin/ld: CMakeFiles/obj.clangBasic.dir/OpenMPKinds.cpp.o: in functio n `clang ::getOpenMPSimpleClauseTypeName(llvm::omp::Clause, unsigned int )': OpenMPKinds.cpp:(.text._ZN5clang29getOpenMPSimpleClauseTypeNameEN4llvm3o mp6ClauseEj+0x9b): undefined reference to `llvm::omp::getOpenMPClauseNam e(llvm::omp::Clause)'
2023-11-20[OpenMP] atomic compare fail : Parser & AST supportSunil Kuravinakop1-0/+34
Diff Revision: https://reviews.llvm.org/D123235
2023-11-09[Clang][OpenMP] Return empty QualType when a negative array was created (#71552)Baodi1-0/+2
Fix #69198
2023-11-08Revert "[OpenMP] atomic compare fail : Parser & AST support"Mitch Phillips1-39/+0
This reverts commit 086b65340cca2648a2a91a0a47d28c7d9bafd1e5. Reason: Broke under -Werror. More details in https://reviews.llvm.org/D123235
2023-11-07[OpenMP] atomic compare fail : Parser & AST supportSunil Kuravinakop1-0/+39
This is a support for " #pragma omp atomic compare fail ". It has Parser & AST support for now. Reviewed By: tianshilei1992, ABataev Differential Revision: https://reviews.llvm.org/D123235