[AArch64][PAC] Reset `killed` operand flags in outlined functions
Presently, MachineOutliner does not take `killed` operand flags into
account when merging instruction sequences. While it sounds perfectly
reasonable not to inhibit merging of the instruction sequences that
only differ in `killed` flags (for N flags there is technically 2^N
valid ways to drop some subset of them), copying these flags from
an arbitrarily chosen representative instruction may result in
incorrect codegen of PAuth-related pseudo instructions on AArch64.
To keep `killed` flags conservatively correct as if `OUTLINED_FUNCTION`s
are virtually re-inserted at every call site, this patch takes the
simplest approach of resetting every `killed` flag inside the
outlined functions.
[libc] Add wcscasecmp and wcsncasecmp implementations. (#222154)
Add a helper to wctype_utils.h for three-way comparison of individual
`wchar_t`s. As is the case in existing code, `wchar_t` is presumed to be
UTF-32.
Assisted-by: Automated tooling, human reviewed.
[ConstantTime] Use ARITH_FENCE as the combine barrier in CT_SELECT expansion
Replace the CopyToReg/CopyFromReg vreg barrier in ExpandCTSELECT with
ISD::ARITH_FENCE. The legalizer no longer creates vregs or picks register
classes via getRegClassFor, and scalable vectors are now covered too.
Codegen tests regenerated; output stays branchless.
[ConstantTime] Move the CT_SELECT expansion into a helper
The CT_SELECT case in ExpandNode was around 180 lines. Move it to
SelectionDAGLegalize::ExpandCTSELECT and name the operands, so the case is
three lines. Pure code motion: emitted assembly is unchanged for every RUN
line of the existing ct.select codegen tests.
Also use a temporary for the promoted SELECT so the call fits on one line
instead of wrapping after the assignment.
Co-Authored-By: Claude Opus 5 <noreply at anthropic.com>
[ConstantTime] Allow dead llvm.ct.select to be removed
An unused llvm.ct.select outlived the InstructionSimplify fold, which kept
both value arguments live and contradicted the LangRef text saying the unused
argument becomes dead code. Add the intrinsic to the wouldInstructionBeTriviallyDead
whitelist next to llvm.allow.runtime.check and llvm.allow.ubsan.check, which
carry IntrInaccessibleMemOnly for the same reason: to pin the call in place,
not to model a real memory access.
Keep IntrInaccessibleMemOnly rather than switching to IntrNoMem. As a pure
value the call is sunk into a conditionally-executed block by InstCombine
(gated on mayWriteToMemory) and split into one copy per branch arm by GVN PRE.
Also correct the undef condition semantics, trim the declaration list, and
drop claims from the definition comment that the memory effect does not
actually provide.
Co-Authored-By: Claude Opus 5 <noreply at anthropic.com>
[ConstantTime] Address reviewer feedback on llvm.ct.select core
- Fix vector-split build error: call the existing SplitRes_Select for
CT_SELECT instead of the nonexistent SplitRes_CT_SELECT.
- Fix a VP_MERGE result-split regression: the CT_SELECT switch reformat had
moved ISD::VP_MERGE onto the SplitRes_SELECT_CC line, which reads operand 4
(out of bounds for VP_MERGE's 4 operands) and builds a SELECT_CC without
splitting the EVL, crashing or miscompiling any vp.merge whose result
vector must be split. Restore it to the SplitRes_Select group.
- Accept byte types (bN and vectors of them) in the Verifier and document
them in LangRef; add byte-typed X86 codegen and Verifier test coverage.
- Drop the redundant `VT0 == MVT::i1` guard in visitCT_SELECT; the inner
condition-type checks already cover correctness after promotion.
- LangRef: reword the constant-fold rule to the enforceable "constant
operand" form, restate fast-math flags via the general FP-call rule (only
nnan/ninf are poison-generating), and switch undef/poison to match select,
dropping the noundef return attribute so poison propagates (both arms always
evaluate, so poison in either yields poison).
- Revert an unrelated whitespace change in LegalizeTypes.h.
[2 lines not shown]
[ConstantTime] Address reviewer feedback for llvm.ct.select core
Model llvm.ct.select as IntrInaccessibleMemOnly so the call stays pinned
without pessimizing alias analysis. Make CT_SELECT flagless (drop the
getCTSelect flags parameter, dead flag propagation, and
setFlags-after-getNode) and assert its condition is scalar. Blend the FP
memory fallback at the widest legal integer width with ext-load and
trunc-store tails instead of illegal i8 chunks. Restore the LangRef
section dropped in the rebase onto the Markdown docs migration and note
RISC-V Zkt/Zvkt. Apply review style fixes and regenerate affected tests.
[ConstantTime] Fix CT_SELECT expansion to preserve constant-time guarantees
Create CT_SELECT nodes for scalar types regardless of target support, so
they survive DAGCombiner (visitCT_SELECT is conservative). Expand to
AND/OR/XOR during operation legalization after SETCC is lowered, preventing
the sext(setcc)->select fold chain that converts constant-time patterns
into data-dependent conditional moves (e.g. movn/movz on MIPS).
The mask uses SUB(0, AND(Cond, 1)) instead of SIGN_EXTEND because type
legalization already promoted i1 to the SetCC result type, making
SIGN_EXTEND a no-op for same-width types.
[ConstantTime][LLVM] Add llvm.ct.select intrinsic with generic SelectionDAG lowering
[LLVM][CodeGen] Improve CTSELECT fallback lowering and target support modeling (#179395)
This pull request refactors and improves the **fallback handling** of
constant-time select (CTSELECT) in LLVM’s code generation
infrastructure. The changes clarify semantics, simplify
target-capability checks, and improve the correctness and
maintainability of fallback lowering, without changing the intended
constant-time guarantees.
- **CTSELECT semantics**
- Clarified documentation for the `CTSELECT` node to explicitly describe
its operands and its role as the lowering target for the constant-time
select intrinsic.
- **TargetLowering cleanup**
- Removed CTSELECT-specific entries from `SelectSupportKind`.
- Introduced a dedicated `isCtSelectSupported(EVT)` hook to cleanly
[23 lines not shown]
[TOSA] Add pass to sanitize gather/scatter indices (#221200)
Add new TosaGatherScatterHardeningPass TOSA pass to clamp indices before
they are fed to a tosa.gather or tosa.scatter unless a suitable clamp
sequence already exists. This enables avoiding out-of-bounds accesses on
untrusted indices in tosa.gather and tosa.scatter lowering.
The pass fails if the dimension indexed by the indices tensor of any of
the tosa.gather or tosa.scatter is dynamic. The pass supports EXT-INT64
by using the same element type in the clamp min/max sequence as the
indices tensor. In case the indexed dimension is bigger than can be
represented in the element type bitwidth the maximum value in that
bitwidth is used.
Assisted-by: codex
Signed-off-by: Thomas Preud'homme <thomas.preudhomme at arm.com>
[CIR] Inline the res_attrs void-return condition
A cir.func with no results can only have res_attrs absent or empty, so
the emptiness guard this drops was protecting an invariant the result
attribute count check already enforces.
Assisted-by: Cursor / claude-opus-5
[CMake] Don't reference unexported targets from dependency-only configs (#222630)
#221724 stopped exporting a project's targets file when that project is
enabled only as another project's dependency, but the build-tree
`ClangConfig.cmake` and `MLIRConfig.cmake` still include it
unconditionally. `find_package()` therefore finds the config and fails
inside it:
```
CMake Error at build/lib/cmake/clang/ClangConfig.cmake:19 (include):
include could not find requested file:
build/lib/cmake/clang/ClangTargets.cmake
Call Stack (most recent call first):
CMakeLists.txt:90 (find_package)
```
This breaks any configuration that enables Flang without also enabling
Clang or MLIR explicitly: `runtimes/CMakeLists.txt` calls
`find_package(Clang ...)`, which is deliberately not `REQUIRED` and is
[16 lines not shown]
[compiler-rt] Support GNU section attributes on Windows (#222707)
MSVC and Clang place sanitizer sentinels and CRT callbacks with
__declspec(allocate) after declaring their sections with #pragma
section. MinGW GCC uses the section attribute instead, so select the
appropriate spelling for each compiler.
Co-authored-by: Hannes Domani <ssbssa at yahoo.de>
[compiler-rt][asan] Include intrin.h for MinGW GCC (#222709)
asan_globals_win.cpp calls __debugbreak in the runtime thunk
configurations. Include MinGW's intrinsic header so the function is
declared when this file is compiled with GCC.
Co-authored-by: Hannes Domani <ssbssa at yahoo.de>
[compiler-rt] Handle weak interfaces with MinGW GCC (#222706)
Windows weak-function emulation uses MSVC linker /alternatename
directives, which GNU ld does not support. Use direct exported
definitions, avoid registering unsupported DLL weak aliases, and
reference UBSan's real C++ implementation.
Co-authored-by: Hannes Domani <ssbssa at yahoo.de>