[libc++][test] Test SFINAE for `optional`'s operators in C++17 (#221643)
We have been intentionally constraining `optional`'s comparison
operators since C++17, so it is probably better to test the constraints
in C++17 mode. Given the constraints are standardized only since C++26
(via P2944R3), `LIBCPP_STATIC_ASSERT` is used in old modes.
In order to do this, `test_comparisons.h` is reworked to expose
`NonComparable` and `EqualityComparable` in pre-C++20 modes, and a new
type `TotallyOrdered` is invented as a replacement of
`ThreeWayComparable` in old modes.
As drive-by, also switches to use `// REQUIRES: std-at-least-c++17` in
touched test files, and adds previously missed includes of
`<type_traits>`.
[MLIR] AllocaOp canonicalization for array allocation in LLVM dialect (#221508)
Add the following canonicalization pattern to AllocaOp in MLIR's LLVM
dialect:
```
%n = constant(N)
%alloca = llvm.alloca %n x Ty
```
->
```
%one = constant(1)
%alloca = llvm.alloca %one x !llvm.array<N x Ty>
```
Here N is a constant representable with 64-bits. With this
canonicalization, the AllocaOp will be translated to `alloca [N x Ty]`
in LLVM IR. Without this canonicalization, the AllocaOp was translated
to `alloca Ty, N`. We prefer `alloca [N x Ty]` over `alloca Ty, N` for
[6 lines not shown]
[ADT] Document the UniquingSet contracts. NFC (#221860)
#220195 added an isEqual hook, so an Info can now override the
comparison as well as the key and the hash. Name the three hooks, and
correct the guidance on when to prefer UniquingSet over FoldingSet.
Cover getOrInsert, which UniquingSet had no test for: an absent key
inserts, an equal key returns the node already in the set.
Aided by Opus 5
Co-authored-by: Kazu Hirata <kazu at google.com>
[SLP][modularisation][NFC] Move createInsertVector, createExtractVector (#221785)
Move the following BoUpSLP-independent shuffle helpers out of
SLPVectorizer.cpp into SLPVectorizer/SLPUtils.{h,cpp}:
createInsertVector
createExtractVector
They sit with the existing shuffle helpers. Behavior is unchanged.
Part of the SLPVectorizer.cpp modularization effort:
https://discourse.llvm.org/t/modularizing-slpvectorizer-cpp/90922
Iterate DenseMaps with auto and structured bindings. NFC (#221869)
Avoid naming `std::pair` directly. The DenseMap bucket is subject to
change (#221853).
[clang] Unique the QualType-keyed type pools in a UniquingSet. NFC (#221850)
Eight of the ASTContext type pools key on a QualType, or on a QualType
and a bool. The `get*Type()` functions incur the FoldingSetNodeID
serialization overhead before probing the hash table.
Switch to UniquingSet. Define `QualTypeBoolInfo` for three pools that
key on a QualType and a bool, because DenseMapInfo has no bool
specialization.
After the canonical type is built, these getters re-probe to refresh the
insert token. A token is now a hash (#218190), not a bucket, so nothing
invalidates it; fold the re-probe into the assertion it feeds.
Aided by Opus 5
[clang] Reject __super when preceded by a scope specifier (#221492)
The `__super` keyword is an MSVC extension that refers to the base class
of the current class context. It is fundamentally invalid for `__super`
to be qualified by another scope specifier (e.g. `::__super` or
`N::__super`).
Fixes #212988
---------
Co-authored-by: Shengxin Pei <TPPPP72 at outlook.com>
Co-authored-by: Corentin Jabot <corentinjabot at gmail.com>
[GlobalISel] When folding to fma correctly find fpext(fmul) with fewer uses (#218013)
When folding: `(fadd (fpext (fmul x, y)), z) -> (fma (fpext x), (fpext
y), z)` and both addends are candidates, correctly pick the side with
fewer uses. Previously the code looked for a `fmul` with the fewest uses
rather than a `fpext(fmul)`.
---------
Signed-off-by: John Lu <John.Lu at amd.com>
[X86] Prefer carry to overflow flag when using multiplication (#221611)
For all possible MUL/IMUL it will always output CF==OF, and CF is better
folding, so there's absolutely no reason the x86 backend should be
checking OF instead of CF for any form of multiply.
Did the change in FastISel too for consistency.
[MIPS] Support MIPS I hard-float double loads/stores with LWC1/SWC1 (#209362)
MIPS I lacks LDC1/SDC1. This patch implements double precision
loads/stores using LWC1/SWC1 instructions.
* Add BuildPairF64_FPR and ExtractElementF64_FPR nodes
* Use them in lowerLOAD/lowerSTORE for MIPS I hard-float
* Avoid redundant mtc1/mfc1 instructions
Matches GCC behavior for MIPS I hard-float.
Fix #62190.
[libc++][ranges] Implement LWG 3599 (#221573)
Implement [LWG 3599](https://wg21.link/LWG3599) by requiring
`forward_range<const Pattern>` for the `const` overloads of
`lazy_split_view::begin` and `end`.
This adds tests for disabled `begin()` and fallback `end()` on
non-const-forward patterns, as well as a regression test for
`view_interface::front()`.
Closes #189808
[Clang][Modules] Fix ODR handling of types found through using-declarations (#221839)
Fixes #78850.
Clang can diagnose an ODR violation for identical definitions when a
type is
found directly in one module's global module fragment and through a
using-declaration in another. The lookup routes produce different AST
type
wrappers even though they refer to the same declaration.
Normalize `UsingType` to the target declaration's type before hashing
it. Keep
the keyword and qualifier from the use site, rather than from the
using-declaration. This also lets the hash distinguish differently
qualified
uses without canonicalizing away meaningful spelling differences.
The normalization exposes an existing assertion in the enum ODR
[74 lines not shown]
[BOLT][RISCV] Mark newly created tail calls (#221672)
Tail calls created during CFG normalization lack the tail-call
annotation, so FixRISCVCallsPass rewrites them as regular calls that
clobber ra.
Set the annotation in createTailCall(). Clear builder annotations before
moving the originals when rebuilding calls to avoid duplicate annotation
markers.
Add a relocation-mode regression test for a conditional tail call.
[lld][MachO] Ignore relocated bytes when folding LSDAs (#220155)
AArch64 exception tables reference type info through PC-relative
pointer-to-GOT relocations. The assembler leaves the negated field
offset in each relocated field, which the linker ignores, so identical
tables differ in their raw bytes and are never folded. Treat
__gcc_except_tab like __eh_frame and zero the relocated fields before
ICF hashes and compares it.
Folding these LSDAs exposes a latent issue: the LSDA pointer of a DWARF
FDE is resolved to an InputSection when the FDE is parsed and is never
canonicalized after ICF. A function that is unwound via its FDE and
whose LSDA was folded away therefore gets an __unwind_info LSDA entry
computed from the dead input section. Fixed it in the same commit.
This patch is LLM-driven, but the issue was observed in production and
the test is reduced from the production object.
Add openmp test to xfail list (#221854)
Introduced in PR #219323. Looking at the PR, and given we haven't yet
addressed openmp profcheck failures, the change is highly unlikely to
have introduced a new regression (it's exposing existing ones)
[libomp] Set `KMP_USE_YIELD=2` when `OMP_WAIT_POLICY=active` if it's not specified explicitly (#199628)
This patch sets `KMP_USE_YIELD=0` when `OMP_WAIT_POLICY=active` and
`KMP_USE_YIELD` is not explicitly set by the user. This is the same as
the value of `KMP_BLOCKTIME` is set to infinite when `KMP_BLOCKTIME` is
not explicitly set and `OMP_WAIT_POLICY=active`.
### Background
`KMP_USE_YIELD` is an environment variable for libomp to control the
behavior of threads when they are idle. We can specify 0, 1, or 2 as the
value of `KMP_USE_YIELD`. As I read the code, the behavior is as
follows:
- `KMP_USE_YIELD=0`: Threads will NOT yield the CPU when they are idle.
- `KMP_USE_YIELD=1`: Threads will yield the CPU when they are idle.
- `KMP_USE_YIELD=2`: Threads will yield the CPU when they are idle if we
are oversubscribed (i.e., more threads than CPU cores).
[40 lines not shown]
Add openmp test to xfail list
Introduced in PR #219323. Looking at the PR, and given we haven't yet addressed openmp profcheck failures, the change is highly unlikely to have introduced a new regression (it's exposing existing ones)
[OpenMPOpt] Bound indirect-call specialization instead of paying for all of it (#219323)
`registerAAsForFunction()` seeds `AAIndirectCallInfo` unconditionally,
so device
code pays for specializing every indirect call site. Device code routes
many
calls through function-pointer tables and virtual dispatch, so a call
site can
see every address-taken candidate in the module, and the if-cascade
`AAIndirectCallInfo` builds over them is quadratic.
Skip specialization at a call site with more than three possible
callees,
overridable with `-openmp-opt-max-callees-for-specialization`. The bound
is a
threshold on the call site rather than a limit on how many callees get
specialized: the Attributor asks about each callee with the same total,
so a
site above the threshold keeps its indirect call instead of getting
[29 lines not shown]
[orc-rt] Hide symbols by default in Bedrock and Support libs. (#221848)
Hides C/C++ symbols by default in the orc-rt Bedrock and Support
libraries. Only explicitly annotated APIs should be exposed by these
libraries.
[LifetimeSafety][test] Fix UUM of fields added in #221610 and #205764 (#221843)
New LifetimeSafetyOpts fields were added in
https://github.com/llvm/llvm-project/pull/221610 but they are not
initialized in clang/unittests/Analysis/LifetimeSafetyTest.cpp, leading
to use-of-uninitialized-memory
(https://lab.llvm.org/buildbot/#/builders/164/builds/25165):
```
WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x555571559cbc in clang::lifetimes::internal::(anonymous namespace)::LifetimeChecker::LifetimeChecker(clang::lifetimes::internal::LoanPropagationAnalysis const&, clang::lifetimes::internal::MovedLoansAnalysis const&, clang::lifetimes::internal::LiveOriginsAnalysis const&, clang::lifetimes::internal::FactManager&, clang::AnalysisDeclContext&, clang::lifetimes::LifetimeSafetySemaHelper*, clang::lifetimes::LifetimeSafetyOpts const&) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Analysis/LifetimeSafety/Checker.cpp:108:9
#1 0x5555715453cd in clang::lifetimes::internal::runLifetimeChecker(clang::lifetimes::internal::LoanPropagationAnalysis const&, clang::lifetimes::internal::MovedLoansAnalysis const&, clang::lifetimes::internal::LiveOriginsAnalysis const&, clang::lifetimes::internal::FactManager&, clang::AnalysisDeclContext&, clang::lifetimes::LifetimeSafetySemaHelper*, clang::lifetimes::LifetimeSafetyOpts const&) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Analysis/LifetimeSafety/Checker.cpp:575:19
#2 0x555571524c1e in clang::lifetimes::internal::LifetimeSafetyAnalysis::run() /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Analysis/LifetimeSafety/LifetimeSafety.cpp:98:3
#3 0x55555c3da25b in LifetimeTestRunner /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/unittests/Analysis/LifetimeSafetyTest.cpp:71:15
...
Uninitialized value was stored to memory at
#0 0x55555bcd06c7 in __msan_memcpy /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1760:3
#1 0x5555715238ed in clang::lifetimes::internal::LifetimeSafetyAnalysis::LifetimeSafetyAnalysis(clang::AnalysisDeclContext&, clang::lifetimes::LifetimeSafetySemaHelper*, clang::lifetimes::LifetimeSafetyOpts const&) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Analysis/LifetimeSafety/LifetimeSafety.cpp:54:39
#2 0x55555c3da1b9 in make_unique<clang::lifetimes::internal::LifetimeSafetyAnalysis, clang::AnalysisDeclContext &, std::nullptr_t, clang::lifetimes::LifetimeSafetyOpts &, 0> /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/libcxx_install_msan_track_origins/include/c++/v1/__memory/unique_ptr.h:713:30
#3 0x55555c3da1b9 in LifetimeTestRunner /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/unittests/Analysis/LifetimeSafetyTest.cpp:70:9
[9 lines not shown]