llvm-project/clang/tools
Michael Kruse b119120673 [clang][OpenMP] Use OpenMPIRBuilder for workshare loops.
Initial support for using the OpenMPIRBuilder by clang to generate loops using the OpenMPIRBuilder. This initial support is intentionally limited to:
 * Only the worksharing-loop directive.
 * Recognizes only the nowait clause.
 * No loop nests with more than one loop.
 * Untested with templates, exceptions.
 * Semantic checking left to the existing infrastructure.

This patch introduces a new AST node, OMPCanonicalLoop, which becomes parent of any loop that has to adheres to the restrictions as specified by the OpenMP standard. These restrictions allow OMPCanonicalLoop to provide the following additional information that depends on base language semantics:
 * The distance function: How many loop iterations there will be before entering the loop nest.
 * The loop variable function: Conversion from a logical iteration number to the loop variable.

These allow the OpenMPIRBuilder to act solely using logical iteration numbers without needing to be concerned with iterator semantics between calling the distance function and determining what the value of the loop variable ought to be. Any OpenMP logical should be done by the OpenMPIRBuilder such that it can be reused MLIR OpenMP dialect and thus by flang.

The distance and loop variable function are implemented using lambdas (or more exactly: CapturedStmt because lambda implementation is more interviewed with the parser). It is up to the OpenMPIRBuilder how they are called which depends on what is done with the loop. By default, these are emitted as outlined functions but we might think about emitting them inline as the OpenMPRuntime does.

For compatibility with the current OpenMP implementation, even though not necessary for the OpenMPIRBuilder, OMPCanonicalLoop can still be nested within OMPLoopDirectives' CapturedStmt. Although OMPCanonicalLoop's are not currently generated when the OpenMPIRBuilder is not enabled, these can just be skipped when not using the OpenMPIRBuilder in case we don't want to make the AST dependent on the EnableOMPBuilder setting.

Loop nests with more than one loop require support by the OpenMPIRBuilder (D93268). A simple implementation of non-rectangular loop nests would add another lambda function that returns whether a loop iteration of the rectangular overapproximation is also within its non-rectangular subset.

Reviewed By: jdenny

Differential Revision: https://reviews.llvm.org/D94973
2021-03-04 22:52:59 -06:00
..
apinotes-test [gn build] (manually) port 82f86ae01 2020-11-05 14:11:26 -05:00
arcmt-test ARCMigrate: Stop abusing PreprocessorOptions for passing back file remappings, NFC 2020-12-02 16:28:33 -08:00
c-arcmt-test
c-index-test [ASTReader] Allow controlling separately whether validation should be disabled for a PCH vs a module file 2021-01-21 20:45:54 -08:00
clang-check [clang-check] Add tokens-dump in clang-check. 2021-02-11 09:40:47 +01:00
clang-diff clang-{tools,unittests}: Stop using SourceManager::getBuffer, NFC 2020-10-15 00:35:16 -04:00
clang-extdef-mapping [clang-tooling] Prevent llvm::fatal_error on invalid CLI option 2021-01-29 10:15:06 +01:00
clang-format [clang-format] Add case aware include sorting. 2021-02-02 15:12:27 +01:00
clang-format-vs clang-format-vs : Fix Unicode formatting 2019-11-27 09:58:59 +01:00
clang-fuzzer [llvm][clang][mlir] Add checks for the return values from Target::createXXX to prevent protential null deref 2020-11-21 21:04:12 -08:00
clang-import-test Fixup for 8c86197de3 to avoid making it platform-dependent 2020-12-11 17:34:00 -08:00
clang-offload-bundler [clang-offload-bundler] Add option -list 2021-01-06 16:23:01 -05:00
clang-offload-wrapper [CMake] Make `intrinsics_gen` dependency unconditional. 2020-07-17 16:43:17 -07:00
clang-refactor [clang-tooling] Prevent llvm::fatal_error on invalid CLI option 2021-01-29 10:15:06 +01:00
clang-rename [clang-tooling] Prevent llvm::fatal_error on invalid CLI option 2021-01-29 10:15:06 +01:00
clang-scan-deps Revert "[clang-scan-deps] Support clang-cl" 2020-12-14 13:32:38 -05:00
clang-shlib [clang-shlib] Don't link with static clang libraries 2020-07-10 14:28:05 -07:00
diag-build
diagtool Recommit "[CUDA][HIP] Defer overloading resolution diagnostics for host device functions" 2020-10-19 17:48:04 -04:00
driver [Driver] Print process statistics report on CC_PRINT_PROC_STAT env variable. 2021-02-26 16:16:00 -08:00
libclang [clang][OpenMP] Use OpenMPIRBuilder for workshare loops. 2021-03-04 22:52:59 -06:00
scan-build Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk 2021-02-25 11:32:27 +01:00
scan-build-py [scan-build-py] Add sarif-html support in scan-build-py 2021-02-23 14:41:48 -08:00
scan-view Partially Revert "scan-view: Remove Reporter.py and associated AppleScript files" 2021-02-11 19:10:46 -08:00
CMakeLists.txt APINotes: add APINotesYAMLCompiler 2020-11-05 18:55:13 +00:00