[LoongArch] Load scalars into vector lane 0 with FLD/VLDREPL (#234119)
Inserting a loaded integer into lane 0 of an undefined vector, which is
also how sub-128-bit vector loads are legalized, was lowered to a scalar
load plus [X]VINSGR2VR. VINSGR2VR merges into its destination, so it
carries a false dependency on the previous value of that register, and
it needs a GPR-to-vector move.
Use FLD.{S/D} for 32/64-bit elements and [X]VLDREPL.{B/H} for 8/16-bit
elements instead. They write the whole register in one instruction.
When the register allocator reuses one vector register for several such
loads, the false dependency serializes otherwise independent chains. In
the GSM autocorrelation loop (9 x i64 multiply-accumulate over i16 taps)
on LA664:
VF2: 0.953s -> 0.724s
VF4: 1.446s -> 0.856s
[hlsl][spirv] Add late pass in spirv backend to remove dead resources (#225270)
Add a pass to remove unused resource handle intrinsics and unused global
variables used to store these handles.
Also remove stores to aforementioned globals that are generated by Clang
as initializers as well as string names only used in dead handle calls.
Based on DXILUnusedResources pass, but differs by removing a resource
global variable if dead regardless of whether the corresponding handle
intrinsic used in its initializer is dead.
Assisted by: codex
[analyzer] Handle null nodes from CheckerContext node creation (#238414)
Node creation (addTransition, addSink, generateNonFatalErrorNode)
returns null when the node already exists or the state is
overconstrained. Several callers dereferenced or reported against the
result unchecked.
Fixes:
- NullabilityChecker: reportBugIfInvariantHolds got null from 4 callers
and from its own addTransition
- DynamicTypeChecker, DynamicTypePropagation, PutenvStackArrayChecker
- Unit test checkers that fed addSink() into a bug report unchecked
Authored-By: Claude
[flang][OpenACC] Fix remapping of SELECT TYPE associate names in data clauses
Using the associate name of an allocatable or pointer SELECT TYPE selector
in an OpenACC data clause hit an assertion while lowering, because the
associate name's descriptor type still marked it allocatable or pointer
while the data clause's did not. Convert between the two descriptor types
when they differ only in that way.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[mlir][ODS] Include headers required by generated dialect declarations and definitions
Generated dialect declarations and definitions use C++ constructs that are
not declared by any header they include. They therefore relied on the
surrounding source file to include these headers first.
The dialect declarations now include the header declaring the dialect base
class, and the headers declaring `StringAttr` and `Operation` if the
dialect has discardable attributes. The dialect definitions include
`MLIRContext.h` if they load dependent dialects.
Similar to #236155 and #238735 but for the dialect generator.
Co-authored-by: Claude <noreply at anthropic.com>
[libc++][pstl] Statpart backend is unconditionally used when threading is enabled (#237177)
This PR removes the CMake parameter `LIBCXX_PSTL_BACKEND` and instead
moves the backend selection logic purely into the source code:
- If libc++ is built with threading (`_LIBCPP_HAS_THREADS=1`), the
`statpart` PSTL backend is used.
- Otherwise, the `serial` PSTL backend is used.
`pstl/statpart.cpp` is now added to `LIBCXX_EXPERIMENTAL_SOURCES`
unconditionally.
This also cleans up a few places where the CI is now complaining since
the new backend is used.
[mlir][ODS] Allow a space-only separator for bit enums (#237149)
Bit enums required a separator containing `|` or `,`, so a flag set
could not be written as bare keywords like LLVM IR's `nuw nsw`, and
dialects wanting that syntax (e.g. ClangIR overflow flags) had to
hand-write an `EnumProp` parser and printer. This allows `separator = "
"` on new-style `BitEnum`s: the generated `FieldParser` reads case
keywords until the next token is not one, symbolize splits on spaces,
and the op-format `enum` directive parses the same way. Like the
existing check for a separator literal, the format verifier rejects a
case literal written right after such an enum, since the parser would
take it as another case. The `BitEnumBase` assert now requires `|`, `,`,
or a space `" "`, where `|` and `,` may be space-padded, so separators
like `"||"` are rejected; legacy `BitEnumAttr` still requires `|` or
`,`. Builds on llvm/llvm-project#237962, which adds the `EnumInfo`
separator accessors.
Assisted-by: Claude Code (Claude Opus 5.5).
[ControlFlowHub] Keep the incoming value of a redirected self-loop (#237903)
When reconnectPhis moves a PHI entry for a self-loop of Out (BB == Out)
into the new PHI in the guard block, it replaced the incoming value with
the new PHI itself. That is only right if the incoming value is the
original PHI, and that case is already handled: if the original PHI ends
up with no operands it is replaced by the new PHI everywhere, including
in the new PHI's own operand. Any other value, such as the next value
of an induction variable, was lost.
Keep the incoming value instead. This special case goes back to the
original UnifyLoopExits code, where BB == Out cannot happen.
FixIrreducible
reaches it when the header of an irreducible cycle has a self-loop.
In FixIrreducible/basic.ll the value along the self-loop is now the
input's own undef. In FixIrreducible/undef-phis.ll all the moved values
are now undef, so the PHI is replaced by undef (not poison, after
#237407).
[3 lines not shown]
[Flang][NFC] Remove trivial uses of SearchTypes (#238479)
Second cleanup after #216960
Some uses of `evaluate::SearchTypes` only use for a single TypeCategory.
With KIND not a template parameter anymore and uses only single static
TypeCategory, the visitor code does not need to be polymorphic anymore.
Most of these only look for a specific known-in-advance KIND, such that
we don't even need to loop over all kinds.
For the remaining uses I had the idea to turn `SearchTypes` into a
function that takes a polymorphic lambda. However, some visitor classes
such as `LocationHelper` and `AsConstantHelper` contain more methods
than just the callback method which diminishes the advantage over the
additional change churn.
Change applied using AI
[LoongArch] Load scalars into vector lane 0 with FLD/VLDREPL
Inserting a loaded integer into lane 0 of an undefined vector, which is
also how sub-128-bit vector loads are legalized, was lowered to a scalar
load plus [X]VINSGR2VR. VINSGR2VR merges into its destination, so it
carries a false dependency on the previous value of that register, and
it needs a GPR-to-vector move.
Use FLD.{S/D} for 32/64-bit elements and [X]VLDREPL.{B/H} for 8/16-bit
elements instead. They write the whole register in one instruction.
When the register allocator reuses one vector register for several such
loads, the false dependency serializes otherwise independent chains. In
the GSM autocorrelation loop (9 x i64 multiply-accumulate over i16 taps)
on LA664:
VF2: 0.953s -> 0.724s
VF4: 1.446s -> 0.856s
[Clang] Use fixed triple for more Profile tests (NFC) (#239186)
The index type size will differ between 32-bit and 64-bit platforms,
producing slightly different IR. Use a fixed 64-bit triple to
keep output consistent.
[libc] Use a syscall wrapper for pkey_free
This PR move pkey_free behind the centralized syscall wrappers, following libc/docs/dev/syscall_wrapper_refactor.md.
[libc] Use a syscall wrapper for pkey_alloc
This PR move pkey_alloc behind the centralized syscall wrappers, following libc/docs/dev/syscall_wrapper_refactor.md.
[libc] Use a syscall wrapper for mremap
This PR move mremap behind the centralized syscall wrappers, following libc/docs/dev/syscall_wrapper_refactor.md.
[mlir][ODS] Set `cppIncludes` on core traits and interfaces
Set the `cppIncludes` field introduced in #236155 on the traits and
interfaces defined in MLIR's core. Generated declarations using them now include the
headers declaring them.
Dialect interfaces get the field as well, although their generated
declarations do not emit includes yet.
Record-level `let` statements were generally preferred (as is currently convention with e.g., `cppNamespace`) with just occasional use of top-level `let` for e.g., many small trait definitions.
Co-authored-by: Claude <noreply at anthropic.com>
[MachineSink] Don't pass LiveIntervals and SlotIndexes to SplitCriticalEdge (#238888)
LiveIntervals and SlotIndexes are not used by this pass.
SplitCriticalEdge does not need them as well. This removes them and all
mentions of those analysis from MachineSink.
This was causing a crash under NewPM pipeline because SlotIndexes were
passed to SplitCriticalEdge, which was attempting to update it, but the
SI became corrupted in PerformTrivialForwardCoalescing which destroys MI
without updating SI
[CopyProf][NFC] Add argument comments in state test. (#237763)
Split out of #232851 as requested in review.
Stack: #237763 (this PR) → #232851 → #235453 → #235454 → #235455
[LoongArch][MC] Support --print-imm-hex and --no-print-imm-hex (#236024)
Fix llvm-objdump's `--print-imm-hex` and `--no-print-imm-hex` support on
LoongArch, it's worth noticing that the default behaviour is print hex
format immediate, which is different from binutils objdump.
[libc][test] Reference callables in skipped death tests (#234960)
When death or subprocess tests are skipped, expanding EXPECT_DEATH and
ASSERT_DEATH to empty macros discards callables before type checking.
This triggers unused parameter or variable warnings under -Werror when a
test sets up a variable or parameter solely for a death check.
Evaluate callables and expected values in an unevaluated block inside do
{ if (false) { ... } } while (false). The compiler type-checks the
expression and marks captured variables as referenced, while the dead
code is eliminated at compile time.
Assisted-by: Automated tooling, human reviewed.
[libc] Use a syscall wrapper for madvise
This PR move madvise behind the centralized syscall wrappers, following libc/docs/dev/syscall_wrapper_refactor.md.
[LLVM][AArch64] Ensure compatible indices when converting dupq to dup_lane. (#238488)
instCombineSVEDupqLane was not verifying the subvector being splatted
matched the one being inserted. At the same time I've also added a check
to ensure the quad index is zero because otherwise we'll generate the
wrong result for out-of-range indices.
Fixes https://github.com/llvm/llvm-project/issues/235610