1. [OpenMP][Part 2] Use reusable OpenMP context/traits handling (details)
  2. [lli] Add a '-dlopen <library-path>' option to lli. (details)
  3. Don't call computeHostNumPhysicalCores when LLVM_ENABLE_THREADS is off (details)
Commit 1228d42ddab832a236563515da5e6de3312fd93c by johannes
[OpenMP][Part 2] Use reusable OpenMP context/traits handling

This patch implements an almost complete handling of OpenMP
contexts/traits such that we can reuse most of the logic in Flang
through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP.

All but construct SIMD specifiers, e.g., inbranch, and the device ISA
selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From
these definitions we generate the enum classes `TraitSet`,
`TraitSelector`, and `TraitProperty` as well as conversion and helper
functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`.

The above enum classes are used in the parser, sema, and the AST
attribute. The latter is not a collection of multiple primitive variant
arguments that contain encodings via numbers and strings but instead a
tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`).

The changes to the parser make it more forgiving when wrong syntax is
read and they also resulted in more specialized diagnostics. The tests
are updated and the core issues are detected as before. Here and
elsewhere this patch tries to be generic, thus we do not distinguish
what selector set, selector, or property is parsed except if they do
behave exceptionally, as for example `user={condition(EXPR)}` does.

The sema logic changed in two ways: First, the OMPDeclareVariantAttr
representation changed, as mentioned above, and the sema was adjusted to
work with the new `OpenMPTraitInfo`. Second, the matching and scoring
logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat
representation of the `match` clause that is not tied to clang.
`OpenMPTraitInfo` provides a method to generate this flat structure (see
`struct VariantMatchInfo`) by computing integer score values and boolean
user conditions from the `clang::Expr` we keep for them.

The OpenMP context is now an explicit object (see `struct OMPContext`).
This is in anticipation of construct traits that need to be tracked. The
OpenMP context, as well as the `VariantMatchInfo`, are basically made up
of a set of active or respectively required traits, e.g., 'host', and an
ordered container of constructs which allows duplication. Matching and
scoring is kept as generic as possible to allow easy extension in the


Test changes:

The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have
been auto generated to match the new warnings and notes of the parser.
The "subset" checks were reversed causing the wrong version to be
picked. The tests have been adjusted to correct this.
We do not print scores if the user did not provide one.
We print spaces to make lists in the `match` clause more legible.

Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim

Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits

Tags: #clang, #llvm

Differential Revision:
The file was modifiedclang/include/clang/Serialization/ASTRecordWriter.h (diff)
The file was modifiedclang/include/clang/Basic/ (diff)
The file was modifiedclang/utils/TableGen/ClangAttrEmitter.cpp (diff)
The file was modifiedclang/test/OpenMP/declare_variant_device_kind_codegen.cpp (diff)
The file was modifiedclang/lib/Serialization/ASTWriter.cpp (diff)
The file was modifiedclang/test/OpenMP/declare_variant_messages.c (diff)
The file was modifiedclang/lib/Parse/ParseOpenMP.cpp (diff)
The file was modifiedclang/include/clang/AST/OpenMPClause.h (diff)
The file was modifiedclang/lib/Serialization/ASTReader.cpp (diff)
The file was modifiedclang/test/OpenMP/declare_variant_ast_print.c (diff)
The file was modifiedclang/include/clang/Serialization/ASTRecordReader.h (diff)
The file was modifiedclang/lib/Serialization/ASTReaderDecl.cpp (diff)
The file was modifiedllvm/unittests/Frontend/OpenMPContextTest.cpp (diff)
The file was modifiedclang/test/OpenMP/nvptx_declare_variant_device_kind_codegen.cpp (diff)
The file was modifiedclang/lib/Sema/SemaTemplateInstantiateDecl.cpp (diff)
The file was modifiedclang/include/clang/Basic/OpenMPKinds.h (diff)
The file was modifiedclang/test/OpenMP/declare_variant_messages.cpp (diff)
The file was modifiedclang/include/clang/Basic/OpenMPKinds.def (diff)
The file was modifiedclang/include/clang/Basic/ (diff)
The file was modifiedclang/lib/Basic/OpenMPKinds.cpp (diff)
The file was modifiedclang/lib/Sema/SemaOpenMP.cpp (diff)
The file was modifiedclang/lib/AST/OpenMPClause.cpp (diff)
The file was modifiedllvm/include/llvm/Frontend/OpenMP/OMPContext.h (diff)
The file was modifiedclang/include/clang/AST/Attr.h (diff)
The file was modifiedllvm/lib/Frontend/OpenMP/OMPContext.cpp (diff)
The file was modifiedclang/include/clang/Parse/Parser.h (diff)
The file was modifiedclang/test/OpenMP/declare_variant_ast_print.cpp (diff)
The file was modifiedclang/include/clang/Sema/Sema.h (diff)
The file was modifiedclang/lib/CodeGen/CGOpenMPRuntime.cpp (diff)
The file was modifiedclang/test/OpenMP/declare_variant_mixed_codegen.cpp (diff)
The file was modifiedclang/include/clang/Basic/ (diff)
Commit b7be6b480b8681902e4b7aa4eb479ccedbde1990 by Lang Hames
[lli] Add a '-dlopen <library-path>' option to lli.

Passing '-dlopen <library-path>' to lli will cause the specified library to be
loaded (via llvm::sys::DynamicLibrary::LoadLibraryPermanently) before JIT'd code
is executed, making the library's symbols accessible to JIT'd code.
The file was modifiedllvm/tools/lli/lli.cpp (diff)
Commit 01b02a73de78146c2072e0b5399d2a40c01eca08 by akhuang
Don't call computeHostNumPhysicalCores when LLVM_ENABLE_THREADS is off

Fix change from 8404aeb56a73 to avoid calling
computeHostNumPhysicalCores if LLVM_ENABLE_THREADS is off.

Reviewers: rnk, aganea

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision:
The file was modifiedllvm/lib/Support/Host.cpp (diff)