[AMDGPU] Use SADDR with out-of-range offsets
Add the part of a constant offset that does not fit the immediate field
to the SGPR base with a scalar add, instead of falling back to a 64-bit
VGPR address. This matters most for async LDS DMA loads, which have no
immediate field for the global address.
[AMDGPU] Restore SADDR add sharing in GlobalISel
Before GFX12, the scalar add expands into an s_add_u32/s_addc_u32 pair
linked through SCC, which MachineCSE cannot merge. Without the per-block
cache, each access in GlobalISel built its own pair, so code for those
targets grew, in some functions beyond what upstream generates. Restore
the cache and add a MIR test that checks two loads share one add.
[flang] Add an interface for operations that store values (#247411)
FortranObjectStoreOpInterface names the values that an operation stores
and the operands that receive them. It has the same shape as the OpenACC
StoreLikeOpInterface, so that the two can later be merged into one MLIR
interface. It is implemented on fir.store, fir.copy, fir.save_result,
fir.char_convert, hlfir.assign, hlfir.copy_in, hlfir.copy_out and
cuf.data_transfer.
Alias analysis will use it to tell an address that is stored to memory
from an address that is only used to access memory.
Related to #243650.
Assisted-by: AI
[CodeGenPrepare] Add tests for weighted selects (NFC) (#245217)
Precommit tests for #244382 (issue #236043), which keeps CodeGenPrepare
from turning a select into a branch when the target does not treat it
like a select (TTI::shouldTreatInstructionLikeSelect()):
- logical and/or selects, most of them with branch weights and feeding a
conditional branch in the same block;
- selects of two constants with branch weights, alone and next to other
selects on the same condition;
- selects of vectors on PowerPC, which does not support a select of
vectors on a scalar condition.
The CodeGenPrepare tests are for x86-64. The llc tests are for x86-64,
AArch64 (neoverse-v2, where a predictable select is expensive) and
PowerPC. The IR of the new tests is what opt -O2 produces.
Assisted-by: Claude Code (Claude Opus 5.5)
Don't treat distinct literal substrings as equal
Expression equality compares dummy arguments by position, as needed
when comparing interfaces (F2023 15.3.2.2). As a result, a host dummy
and an internal procedure dummy at the same position currently compare
equal, even though they are distinct entities (19.5.1.4).
This was not a problem before because literal substrings never compared
equal, so their bounds were never considered. Now that literal
substrings are compared by value, 'ab'(i:i) with host dummy i compares
equal to 'ab'(j:j) with internal dummy j. This can cause Semantics to
reject valid code, such as an ATOMIC READ of a(iachar('ab'(j:j))) into
a(iachar('ab'(i:i))).
For literal substring bounds, only match dummy arguments by position
when both name dummy arguments of their own procedures, as interface
comparison already does for whole symbols. A host dummy referenced in
an internal procedure or imported into an interface body does not.
[8 lines not shown]
fix: [CIR][OpenCL] Use a 4-bit element in the unsupported hint test
Use a `_BitInt(4)` vector so the type passes CIR verification and reaches the `vec_type_hint` lowering diagnostic for unsupported sub-byte elements.
Assisted-by: Codex / GPT-6
[compiler-rt] Preserve errno around isatty in color-support detection
ColorizeReports() calls isatty() on the report file, which sets errno to
ENOTTY when the file is not a terminal. Reports can be printed from within
instrumented user code (e.g. a TSan race report from __tsan_write*), so this
silently changed the program's errno.
Add ScopedPreserveErrno and use it around the probe, and add a TSan test.
[libc++] Fix cfi-unrelated-cast failures in allocator, __new_at_least, and shared_ptr
Fix three `cfi-unrelated-cast` failures in libc++ headers discovered while bringing up a CFI CI job (https://github.com/llvm/llvm-project/issues/245696):
- Annotate `__operator_new_wrapper` in `__memory/allocator.h` with `_LIBCPP_NO_SANITIZE("cfi-unrelated-cast")`. Commit edad54e08d3b (https://github.com/llvm/llvm-project/pull/229771) replaced `__libcpp_allocate` (which had `_LIBCPP_NO_CFI`) with `__operator_new_wrapper`, so Clang's `matchesStlAllocatorFn` exemption no longer applies to its `static_cast<_Tp*>` on uninitialized memory.
- Annotate `__new_at_least<_Tp>` in `__new/new_at_least.h` with `_LIBCPP_NO_SANITIZE("cfi-unrelated-cast")`. Commit f59521e7ec81 (https://github.com/llvm/llvm-project/pull/215813) introduced a `static_cast<_Tp*>` on freshly allocated `void*` memory that breaks polymorphic `std::vector` allocations across standard modes.
- Construct `_ControlBlock` directly with placement `::new (static_cast<void*>(...))` in `__allocate_shared_unbounded_array` (`__memory/shared_ptr.h`), matching `__allocate_shared_impl`, instead of casting uninitialized storage to polymorphic `_ControlBlock*` before construction. (Bounded arrays already allocate `_ControlBlock` directly and do not trigger a cast check.)
Assisted-by: Gemini
[GVN] Process Foldable Terminator beforehead
GVN generates phi node to replace a load call. However, addDeadBlock
modify such phi so that any deadblock sucessor in a phi becomes
poison.
This causes disagreement on SSAUpdater as [%a, %b1] [poison, %b2] is
considered as different with [%a, %b1] [0, %b2] even if poison is
replace with 0.
As a result, we make processFoldableTerminator (which is the only
caller of addDeadBlock now) runs before processInstruction. This is
before what we have on phi node generation so that non of the mismatch
happens.
Asissted-by: Claude # Test
Revert "[libc++] Add __repeat_iterator and use it in the sequence containers (#240378)" (#248213)
This reverts commit 484552add0fb92195f2e3f70734adf4a57f8ebc0.
This breaks std::vector::insert(const_iterator, size_type, const_reference)
in C++23 (-std=c++23 -stdlib=libc++), leaving newly inserted elements appended
at the end of the vector instead of at pos when n > (end - pos) and
n <= __remaining_capacity(), which is actively breaking builds in our CI.
See https://github.com/llvm/llvm-project/pull/240378#issuecomment-7322947076
for the minimal C++23 reproducer and root-cause analysis:
1. __repeat_iterator lacks a default constructor, so it does not model
std::forward_iterator in C++20/23 (and lacks relational operators for
std::random_access_iterator).
2. In vector::__insert_with_size, the C++23 !forward_iterator path calls
std::rotate(__p, __old_last, __end) with a stale cached __end (== __old_last)
instead of __layout_.__end_ptr() (a latent regression from bd338806e423 /
#155330, which already has an open fix in #229763).
Verified that this clean revert builds libc++/libc++abi/libunwind and makes the
minimal C++23 reproducer pass (Result (5): 1 9 9 9 2).
[mlir][EmitC][MLGO] Emit reflectionSizeMap in mlgo-add-reflection-map (#242627)
Let callers check the byte size of a field before writing through
reflectionMap
User: In MLGO input shapes became runtime options since #224598, so a
compiled field can be smaller than the tensor, this PR is a prerequisite
for #242629
[SPIR-V] Restore image, sampler, event and queue types from MIR (#247729)
Without them, -start-after crashes when instruction selection looks up
these types
Signed images are recovered from their OpName
[analyzer][NFC] Out-line CheckerManager::CheckerTags accessors (#248205)
- `CheckerManager::getChecker` and `isRegisteredChecker` are templates
instantiated in every checker TU. Their inline `DenseMap<void *,
std::unique_ptr<CheckerBackend>>` lookup/insert code was therefore
re-instantiated and re-compiled in each of them.
- Route both through the new private out-of-line members
`getCheckerSlot` and `hasCheckerWithTag`, defined in
`CheckerManager.cpp`.
- `getChecker` runs only at checker registration, so there is no
analysis run-time cost.
Build-time impact (instructions retired, 196 `lib/StaticAnalyzer` TUs):
- Total: -0.77% median (-0.12..-0.88% over 5 paired sweeps, noise 0.2%).
Run-time impact (analyzer, 20 TUs of clang/lib/{AST,Sema,Parse,CodeGen},
elapsed cycles, 10 interleaved rounds per binary, before = merge base
a26d5a8):
- Result: no slowdown detected. Median of per-round totals -0.32%: no
[9 lines not shown]
[analyzer][NFC] Drop `SourceManager.h` from `CallEvent.h` (#248179)
- `CallEvent::isInSystemHeader` was the only user of `SourceManager` in
`CallEvent.h`, yet its inline body made every includer of the header
parse `clang/Basic/SourceManager.h`. Move the body into `CallEvent.cpp`
and drop the include.
- Include `clang/Basic/SourceManager.h` explicitly in
`ErrnoChecker.cpp`, `ErrnoModeling.cpp`, `LocalizationChecker.cpp`,
`NullabilityChecker.cpp`, `VirtualCallChecker.cpp` and
`ExprEngineCallAndReturn.cpp`, which relied on it transitively.
Build-time impact (instructions retired, 196 `lib/StaticAnalyzer` TUs):
- Total: -0.79% (5 paired sweeps, all faster; run-to-run noise 0.3%).
- 140 TUs change by more than 0.15%, by -1.07% over those (net,
including the TUs that regain the include).
Run-time impact (analyzer, 20 TUs of clang/lib/{AST,Sema,Parse,CodeGen},
elapsed cycles, 10 interleaved rounds per binary, before = merge base
a26d5a8):
[9 lines not shown]
[analyzer][NFC] Out-line `CheckerContext::addTransitionImpl` (#248181)
- `CheckerContext::addTransitionImpl` is reached from every
`addTransition` overload and instantiated `CoreEngine::makeNode` and the
`ExplodedNodeSet` calls in every checker TU. Move it into
`CheckerContext.cpp`.
Build-time impact (instructions retired, 196 `lib/StaticAnalyzer` TUs):
- Total: -1.23% (4 paired sweeps, all faster; run-to-run noise 0.2%).
- 97 TUs change by more than 0.15%, by -2.5% over those.
Run-time impact (analyzer, 20 TUs of clang/lib/{AST,Sema,Parse,CodeGen},
elapsed cycles, 10 interleaved rounds per binary, before = merge base
a26d5a8):
- Result: no slowdown detected. Median of per-round totals -0.12%: no
slowdown; total cycles are slightly lower (95% CI -0.21%..-0.08%
excludes zero).
- Total per round (%): -0.05, -0.12, -0.20, -0.11, -0.32, -0.02, -0.01,
-0.30, -0.10, -0.19.
[5 lines not shown]
[NVPTX] Fold predicate only when it has one user (#248159)
This is a perf fix for 9386502801a033a676d9dce8ca8482c0d50e4f43. Folding
the predicate is not beneficial if there are multiple users. In that
case the shared predicate can be kept in a register and we need a
shorter code sequence in the final codegen.
NAS-145549 / 27.1.0 / Fix infinite loop in path_in_ctldir() on paths starting with // (by ixhamza) (#20355)
### Motivation
`path_in_ctldir()` can enter an infinite loop when a path starts with
exactly two slashes, such as `//mnt/tank/share`. This can happen when a
user accidentally enters an extra leading slash in an SMB share path or
supplies such a path through the API. Linux treats `//` like `/`,
allowing the path to pass the earlier existence checks.
### Description
The loop assumes that the root is always `/`, but `pathlib` preserves
exactly two leading slashes. Since the parent of `//` is itself,
terminate the loop when `path == path.parent` instead of comparing
against `/`.
### Testing
[6 lines not shown]
NAS-145547 / 27.1.0 / Fix autorid migration (by anodos325) (#20358)
Prior to TrueNAS 25.10 we exposed a non-default idmap backend for Active
Directory (added in TrueNAS 9.10) that users really shouldn't have been
using because it was non-deterministic in ways that are quite painful to
fix. We removed the backend in 25.10 and had a best-effort migration to
put the user into something equivalent that wouldn't require redoing
ACLs. Overall, the backend was rarely used and so an edge-case in the
migration was missed until recently. This commit fixes the migration
in-place (e.g. doesn't add a new migration). Anyone who was impacted by
it most likely simply rejoined AD after failure on upgrade.
Original PR: https://github.com/truenas/middleware/pull/20352
Co-authored-by: Andrew Walker <andrew.walker at truenas.com>
Fix autorid migration
Prior to TrueNAS 25.10 we exposed a non-default idmap backend
for Active Directory (added in TrueNAS 9.10) that users really
shouldn't have been using because it was non-deterministic in
ways that are quite painful to fix. We removed the backend in
25.10 and had a best-effort migration to put the user into something
equivalent that wouldn't require redoing ACLs. Overall, the
backend was rarely used and so an edge-case in the migration
was missed until recently. This commit fixes the migration in-place
(e.g. doesn't add a new migration). Anyone who was impacted by
it most likely simply rejoined AD after failure on upgrade.
(cherry picked from commit 1d6e57042f6b636513a60337ebedeeb89e93a22d)