[all-commits] [llvm/llvm-project] befb4b: [OpenMP] `omp begin/end declare variant` - part 2, ...
Johannes Doerfert via All-commits
all-commits at lists.llvm.org
Fri Mar 27 00:32:48 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: befb4be3a89678cea1531d963c565cab05b731d4
https://github.com/llvm/llvm-project/commit/befb4be3a89678cea1531d963c565cab05b731d4
Author: Johannes Doerfert <johannes at jdoerfert.de>
Date: 2020-03-27 (Fri, 27 Mar 2020)
Changed paths:
M clang/include/clang/AST/Decl.h
M clang/include/clang/AST/OpenMPClause.h
M clang/include/clang/Basic/DiagnosticParseKinds.td
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/include/clang/Basic/IdentifierTable.h
M clang/include/clang/Sema/Sema.h
M clang/lib/AST/DeclarationName.cpp
M clang/lib/AST/OpenMPClause.cpp
M clang/lib/CodeGen/CGOpenMPRuntime.cpp
M clang/lib/CodeGen/CGOpenMPRuntime.h
M clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
M clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
M clang/lib/CodeGen/CodeGenModule.cpp
M clang/lib/CodeGen/CodeGenModule.h
M clang/lib/Parse/ParseOpenMP.cpp
M clang/lib/Sema/SemaDecl.cpp
M clang/lib/Sema/SemaExpr.cpp
M clang/lib/Sema/SemaOpenMP.cpp
M clang/lib/Sema/SemaPseudoObject.cpp
M clang/lib/Sema/SemaStmt.cpp
R clang/test/AST/ast-dump-openmp-begin-declare-variant.c
A clang/test/AST/ast-dump-openmp-begin-declare-variant_1.c
A clang/test/AST/ast-dump-openmp-begin-declare-variant_2.c
A clang/test/AST/ast-dump-openmp-begin-declare-variant_3.c
A clang/test/AST/ast-dump-openmp-begin-declare-variant_4.c
A clang/test/AST/ast-dump-openmp-begin-declare-variant_5.c
A clang/test/AST/ast-dump-openmp-begin-declare-variant_6.c
A clang/test/AST/ast-dump-openmp-begin-declare-variant_7.c
A clang/test/AST/ast-dump-openmp-begin-declare-variant_8.c
A clang/test/AST/ast-dump-openmp-begin-declare-variant_9.c
A clang/test/AST/ast-dump-openmp-begin-declare-variant_addr_1.c
A clang/test/AST/ast-dump-openmp-begin-declare-variant_decl_1.c
R clang/test/OpenMP/begin-declare-variant_no_end_for_matching_selector.c
A clang/test/OpenMP/begin_declare_variant_elided_range_withouth_end.c
M clang/test/OpenMP/begin_declare_variant_messages.c
A clang/test/OpenMP/begin_declare_variant_no_end_for_matching_selector.c
A clang/test/OpenMP/begin_declare_variant_range_withouth_end.c
A clang/test/OpenMP/begin_declare_variant_using_messages.cpp
M clang/test/OpenMP/declare_variant_ast_print.cpp
M clang/test/OpenMP/declare_variant_device_kind_codegen.cpp
M clang/test/OpenMP/declare_variant_implementation_vendor_codegen.cpp
M clang/test/OpenMP/declare_variant_messages.c
M clang/test/OpenMP/declare_variant_messages.cpp
M clang/test/OpenMP/declare_variant_mixed_codegen.c
M clang/test/OpenMP/declare_variant_mixed_codegen.cpp
M clang/test/OpenMP/nvptx_declare_variant_device_kind_codegen.cpp
M clang/test/OpenMP/nvptx_declare_variant_implementation_vendor_codegen.cpp
Log Message:
-----------
[OpenMP] `omp begin/end declare variant` - part 2, sema ("+CG")
This is the second part loosely extracted from D71179 and cleaned up.
This patch provides semantic analysis support for `omp begin/end declare
variant`, mostly as defined in OpenMP technical report 8 (TR8) [0].
The sema handling makes code generation obsolete as we generate "the
right" calls that can just be handled as usual. This handling also
applies to the existing, albeit problematic, `omp declare variant
support`. As a consequence a lot of unneeded code generation and
complexity is removed.
A major purpose of this patch is to provide proper `math.h`/`cmath`
support for OpenMP target offloading. See PR42061, PR42798, PR42799. The
current code was developed with this feature in mind, see [1].
The logic is as follows:
If we have seen a `#pragma omp begin declare variant match(<SELECTOR>)`
but not the corresponding `end declare variant`, and we find a function
definition we will:
1) Create a function declaration for the definition we were about to generate.
2) Create a function definition but with a mangled name (according to
`<SELECTOR>`).
3) Annotate the declaration with the `OMPDeclareVariantAttr`, the same
one used already for `omp declare variant`, using and the mangled
function definition as specialization for the context defined by
`<SELECTOR>`.
When a call is created we inspect it. If the target has an
`OMPDeclareVariantAttr` attribute we try to specialize the call. To this
end, all variants are checked, the best applicable one is picked and a
new call to the specialization is created. The new call is used instead
of the original one to the base function. To keep the AST printing and
tooling possible we utilize the PseudoObjectExpr. The original call is
the syntactic expression, the specialized call is the semantic
expression.
[0] https://www.openmp.org/wp-content/uploads/openmp-TR8.pdf
[1] https://reviews.llvm.org/D61399#change-496lQkg0mhRN
Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim, aaron.ballman
Subscribers: bollu, guansong, openmp-commits, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75779
More information about the All-commits
mailing list