[Flang][MLIR] Move setOpenMPIntegerWrapAround function into the OpenMP dialect (#217448)
- Fixed the linker error: `undefined reference
to'mlir::omp::IntegerWrapAroundAttr::get(mlir::MLIRContext*, bool)'`
mentioned in mentioned in
[PR#214165](https://github.com/llvm/llvm-project/pull/214165#issuecomment-5323821248)
by moving the `setOpenMPIntegerWrapAround(...)` helper function out of
`flang/Tools/CrossToolHelpers.h` and placed it into the OpenMP dialect
utilities.
[WebAssembly][GlobalISel] Implement pointer and memory ops (v2) (#219072)
Implements a variety of pointer and memory related ops
(`G_GLOBAL_VALUE`, `G_PTR_ADD`, `G_LOAD`, `G_STORE`, etc.).
Split from #157161
-----
TODO (in future PR)
- Move `G_PTRTOINT`, `G_INTTOPTR`, `G_PTRMASK` selection to tablegen
(for all targets)
- MAYBE try to shuffle `G_GLOBAL_VALUE` selection elsewhere (e.g.
legalizer). Doesn't seem worth it?
-----
Reapplication of #206885 with some fixes and extensions.
[mlir][LLVM] Verify that constant attribute and result types match
`llvm.mlir.constant` only checked that the kind of the value attribute suits
the kind of the result type, never that the types themselves agree. All of the
following verified:
%0 = llvm.mlir.constant(1 : index) : i64
%1 = llvm.mlir.constant(1 : i8) : i16
%2 = llvm.mlir.constant(dense<1> : vector<4xi32>) : vector<4xi64>
Translation ignores the attribute type and uses the result type, so the
attribute type was effectively decorative for integers, and passes that read it
back could observe a type that has nothing to do with the value.
Require exact type equality for integer attributes and exact element type
equality for integer elements attributes, mirroring the `AllTypesMatch`
constraint `arith.constant` gets from ODS. The op cannot use that trait itself
because `value` is an `AnyAttr` that also holds `StringAttr` and `ArrayAttr`.
The element type check is also run on the scalable vector path, which
[11 lines not shown]
[mlir] Build llvm.mlir.constant attributes from the result type (#218607)
Many conversion patterns created `llvm.mlir.constant` with a value
attribute whose type does not match the result type. The most common
case was pairing an `index`-typed attribute with the converted index
type:
```
llvm.mlir.constant(1 : index) : i64
```
but there were also plain width and signedness mismatches, e.g. NVGPU's
`makeI64Const` built `i64` constants from `i32` attributes, and the NVVM
`fdiv` expansion used `ui32` attributes on `i32` values.
Translation to LLVM IR ignores the attribute type and uses the result
type, so the emitted IR was correct, but the attribute type is
meaningless in this state and anything that reads it back sees the wrong
type. Derive the attribute from the result type in every case; where the
[21 lines not shown]
[AArch64][GlobalISel] Combine trunc_nsw(smin) to truncsat (#218605)
The midend of LLVM, in CVP, will often transform the canonical pattern
for a saturate trunc(smin(smax)) into trunc nsw (smin), as the range
analysis proves that the smax is outside of range. This adds a fold
back, converting the trunc with nsw + smin into G_TRUNC_SSAT_S.
https://alive2.llvm.org/ce/z/xfPEXE
Support for widening is added for truncsat nodes too, to prevent
fallbacks. They can be widened in the same way as a standard trunc using
buildPadVectorWithUndefElements.
[libc++] Kickstart C++29 support (#215820)
Based on https://github.com/llvm/llvm-project/pull/203992: Clang adds
`c++2d` flag
Also based on
https://github.com/llvm/llvm-project/commit/00c97cbc570042a49d8b1906c1a6f39106a21259
libc++ C++26 support
1. Adds C++29 flag and macros (unlike Clang's `c++2d` uses the `c++29`
flag, supported also by GCC)
2. Updates FTM tests with C++29 details
3. Updates generated files
---------
Co-authored-by: Lucas Mellone <github.snugness349 at passinbox.com>
Co-authored-by: Hristo Hristov <zingam at outlook.com>
Co-authored-by: A. Jiang <de34 at live.cn>
[ADT] Simplify FoldingSetIterator (NFC) (#219073)
This patch simplifies FoldingSetIterator by defining it entirely in the
header without the type-erased FoldingSetIteratorImpl.
Now that FoldingSet uses an open-addressing hash table, we just have to
march through the entire bucket array while skipping empty slots. It
does not make sense to call out-of-line advance().
This also reduces the .text section size of a release build of bin/clang
by 647 bytes (from 185,968,635 to 185,967,988 bytes).
Assisted-by: Antigravity
[C++20] [Modules] Load friends for classes in ADL (#219094)
Close https://github.com/llvm/llvm-project/issues/218228
The root cause of the problem is the corresponding friend is not loaded
at the point of ADL.
This patch tries to fix this simply by loading the friends at the point
of ADL. Note that this may be best efficient if there are a lot of
friends. We just think it is rare. If it is really possible, we can
change the structure of friends from a list to a name lookup table.
[orc-rt] Add SimpleRemoteCA, a SimpleRemote protocol base (#219093)
SimpleRemoteCA implements the transport-independent parts of the
SimpleRemote protocol: opcode and header validation, setup-message
encoding, hang-up encoding and decoding, pending-call tracking, and
completion of controller calls onto the Session::ControllerAccess
contract. Subclasses own wire framing and byte transport entirely --
they de-frame incoming messages and hand the header fields to
handleMessage, and build outgoing ones from the Opcode set and the
encode helpers.
Header validation rejects fields the protocol requires to be unset: a
Result may not carry a handler tag, a hang-up may not carry a sequence
number or tag. It does not interpret fields the protocol requires to be
present -- in particular a Call's handler tag is passed through as
given, since the executor's job is to jump where the controller tells it
to.
A hang-up carries a serialized Error giving the reason the session is
[6 lines not shown]
[NFC][clang][Serialization] Fix std::set_difference sorting mismatch in ASTReader (#219053)
Fixes a `std::set_difference` sorting violation in
`ASTReader::checkTargetOptions` that causes a crash when building clang
with `LLVM_ENABLE_EXPENSIVE_CHECKS` on libstdc++.
`accumulateFeaturesAsWritten` sorts target features using a custom
comparator that strips the `+`/`-` prefix (i.e. comparing `A.substr(1) <
B.substr(1)`). However, `std::set_difference` was being called with the
default `std::string::operator<` comparator, which does not match the
sorting order because `+` (ASCII 0x2B) is less than `-` (ASCII 0x2D).
For example, `["-cx16", "+sse2"]` is correctly sorted according to the
custom comparator, but incorrectly sorted according to the default
lexicographical comparator.
This patch fixes the issue by passing the same custom comparator used
for sorting to both `std::set_difference` calls.
Fixes #219046.
[SLP]Trim combined nodes only at their roots
Combined subnodes were added to the trimming worklist as independent
candidates, carrying their descendants' aggregated costs. Trimming such
a subnode on its own deleted operands still referenced by the combined
root, producing instructions that no longer dominated their uses.
Skip CombinedVectorize subnodes in subtree-cost aggregation and worklist
construction so only combined roots are evaluated as trim candidates.
Fixes #218974
Reviewers:
Pull Request: https://github.com/llvm/llvm-project/pull/219095
[lsan][llvm-profdata] Suppress leak check on abnormal exit (#219088)
This is common issue with lsan after exit().
`exit()` is no return, we can't expect that compiler
will preserve pointers to allocations done by callers.
Fixes new build bot report after upgrading base compiler to clang 23.1.0
https://lab.llvm.org/buildbot/#/builders/169/builds/26007
It probably has improved stack or registers re-use.
[flang][docs] Mention --driver-mode=flang in FlangDriver.md (#207659)
This patch adds a description about the `--driver-mode=flang` flag.
The behavior will be ensured by #207658.
---------
Co-authored-by: Tarun Prabhu <tarunprabhu at gmail.com>
[libc][bazel] Add a repo with linux kernel UAPI headers
This will be used to support libc's -DFULL_BUILD option, which uses `-nostdlibinc` and thus requires a copy of linux kernel headers.
[libc][bazel] Allow building with -DLIBC_FULL_BUILD
This PR defines a flag `--@llvm-project//libc:build_mode` that configures LLVM-libc to build with full-build flags. This is only compatible with clang at the moment, since it relies on the `-nostdlibinc` flag.
[compiler-rt][cmake] Change orc-rt target names (#216901)
When configured with `LLVM_ENABLE_RUNTIMES=compiler-rt;orc-rt`,
following two CMake errors occur.
```
CMake Error at llvm-project/llvm/cmake/modules/AddLLVM.cmake:2245 (add_custom_target):
add_custom_target cannot create target "check-orc-rt" because another
target with the same name already exists. The existing target is a custom
target created in source directory
"llvm-project/compiler-rt/test/orc". See documentation
for policy CMP0002 for more details.
Call Stack (most recent call first):
llvm-project/llvm/cmake/modules/AddLLVM.cmake:2326 (add_lit_target)
llvm-project/orc-rt/test/CMakeLists.txt:24 (add_lit_testsuite)
CMake Error at llvm-project/orc-rt/test/unit/CMakeLists.txt:1 (add_custom_target):
add_custom_target cannot create target "OrcRTUnitTests" because another
target with the same name already exists. The existing target is a custom
[10 lines not shown]