[MLIR][Python] Don't terminate when a from_cpp type caster raises
The `type_caster<Mlir*>::from_cpp` functions in NanobindAdaptors.h are
`noexcept`, but they call into Python: they import `mlir.ir`, call
`_CAPICreate` and, for MlirType, MlirAttribute and MlirValue, call
`maybe_downcast`, which runs user-registered type/value casters. If any of
these raises, the resulting `nanobind::python_error` escapes the `noexcept`
function and `std::terminate` aborts the process. For example, with a type
caster that raises registered for IntegerType, accessing
`FunctionType.inputs` aborts instead of raising the caster's exception.
Wrap the bodies of all `from_cpp` casters in a helper that catches
`nanobind::python_error`, restores it as the Python error indicator and
returns an invalid handle. nanobind then propagates the original exception
to the Python caller: function return values go through the
`nb_func_error_noconvert` path, which keeps a set error indicator, and
`nb::cast` raises it via `raise_python_or_cast_error`.
Add a regression test covering the list (`FunctionType.inputs`) and
[2 lines not shown]
[GlobalISel] Canonicalize more constants
Move scalar constants behind casts and copies, and vector splats, to
the RHS of commutative operations. Keep two constant operands in their
existing order.
Retain commuted identity coverage for casts and splats that constant
folding cannot simplify, and update affected AArch64 and AMDGPU output.
[GlobalISel] Fixup commuted combine matching
Match the subtraction on either side of (A-C1)+C2. Check constants and
use counts through the matched operands.
Look through single-use copies when unmerging constants to avoid extra
AMDGPU materializations. Preserve shared constants and copies, physical
register copies, and constant-fold barriers.
Cover commuted subtraction and copied constants in MIR tests, and update
affected AMDGPU assembly checks.
[GlobalISel] Auto-commute combine patterns
Emit both operand orders for constrained commutative generic match
patterns, including each use of a PatFrag. Skip redundant permutations
and enforce MaxPermutations before allocating expanded alternatives.
Give each permutation its own operand expansions so operand indices
cannot leak between alternatives.
Keep commuted immediate patterns available with constant-to-RHS
canonicalization, and consolidate AMDGPU carry rules while preserving
zero-addend and RHS-first matching.
Make the integer and AMDGPU multiply/select helpers accept either operand
order.
Add emitter documentation and TableGen, MIR, and codegen regressions.
[libc][math] Add integer-only implementation for exp10f.
- Add `src/__support/math/exp10f_integer_eval.h` using the shared `exp2_eval` and fixed-point utilities from `exp2f_integer_utils.h`.
- Select `exp10f_integer_eval` in `src/__support/math/exp10f.h` when `!defined(LIBC_TARGET_CPU_HAS_FPU_DOUBLE) && defined(LIBC_MATH_HAS_ASSUME_ROUND_NEAREST_ONLY) && defined(LIBC_MATH_HAS_NO_EXCEPT) && defined(LIBC_MATH_HAS_NO_ERRNO)`.
- Expose `exp10f` with explicit rounding mode parameter under `LIBC_NAMESPACE::shared::static_rounding`.
- Add smoke, unit, exhaustive, and shared math test coverage for `exp10f_integer_eval` and `static_rounding::exp10f`.
Assisted-by: Gemini is used for code size analysis, performance tuning, and test refactoring.
[CUDA][NFCI] Use getEnclosingFunction() for DeclContext casts in SemaCUDA (#236605)
Expansion statements added CXXExpansionStmtDecl, so a local variable's
parent DeclContext is not always the enclosing function.
getEnclosingFunction skips these contexts.
Assisted-by: Claude Opus 5
RuntimeLibcalls: Add signatures for simple FP libcalls
Add signatures for the FP arithmetic, fma, powi, fminimum/fmaximum and
sincospi libcalls, and for the conversions between f32/f64/f80/f128/
ppcf128 and i32/i64.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Fix signatures of fmin/fmax libcalls
These used Floating, which always lowered to float regardless of the
libcall type.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Use explicit types for F80, F128 and PPCF128 libcalls
LDbl only makes sense for encoding the long double libm functions. Other
functions have need of the specific type. Separately, LDbl brokenly assumes
double instead of checking the module's long double format. Some functions
are inappropriately using a specific type instead of LDbl. I'll fix both
of these issues separately.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Use a single LibcallImpl for long double functions (#233872)
Replace the per-format <func>l_{f80|f128|ppcf128} implementations with
a single <func>l implementaton. The concrete type is now derived from
the module/triple's LongDoubleFormat, so this is no longer a static
property.
On targets where long double is double, the l-suffixed functions do
not provide a libcall. This could be fixed in principle, but nothing
would use it in the compiler.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
intro.7: Add editline(7) and tag SPDX
The command interpreter has lots of keyboard bindings documented in
editline(7), the line editing interface. This is kind of arcane lore,
but adding it to this listing of section 7 pages will help it get seen.
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D60854
RuntimeLibcalls: Move initExtensionsForTriple from TargetLibraryInfo (#236988)
Move the i32 extension ABI rules into RuntimeLibcallsInfo so they can
be used to compute libcall signatures. TargetLibraryInfo now starts
calling into RuntimeLibcallsInfo to use it. Eventually these 2 will
merge.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[Support] Detect exited lock file owners on Windows (#236327)
`LockFileManager::processStillExecuting` only checks whether the owner
of a lock file is still running on Unix, and assumes it is running
everywhere else. On Windows, a lock file left behind by a process that
was terminated while holding it is therefore never reclaimed early:
every waiter waits for the full timeout before removing the lock file
and taking over. For clang implicit modules, that means every compile
that needs the module waits 90 seconds
(`-fimplicit-modules-lock-timeout`) before building it, for each module
whose lock file was left behind. Terminating compilers mid-build is
routine for tools that run compiles in the background and cancel them,
such as language servers indexing a project, so on Windows these stalls
are common.
This change checks the owner on Windows with `OpenProcess` and
`GetExitCodeProcess`. A lock file is only reclaimed if its owner is
known to have exited. Every ambiguous case keeps the existing behavior
of waiting for the lock to time out: a failure to query the process, a
[11 lines not shown]
[LAA] Fix off-by-EltSize in negative-step deref bounds check (#211964)
For a negative step, AR at MaxBTC is the lowest accessed address and
must not fall below StartPtr, i.e. `StartOffset >= MaxBTC * |Step|`.
evaluatePtrAddRecAtMaxBTCWillNotWrap compared StartOffset against the
full accessed size, which also includes EltSize. As a result it
rejected loops whose last iteration lands exactly on the base pointer,
and such early-exit loops were not vectorized.
Compare against `MaxBTC * |Step|` instead, and compare unsigned: both
values are unsigned offsets, and the computation type is not
necessarily wider than the index type.
Not addressed here: for a negative step, the end bound Start + EltSize
in getStartAndEndForAccess is neither checked against the deref region
nor saturated on wrap; it is marked with a FIXME for a follow-up.
Related to https://github.com/llvm/llvm-project/issues/211962
Merge tag 'riscv-for-linus-7.4-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V updates from Paul Walmsley:
- Add support for crash hotplug
- Improve user copy performance on cores with fast misaligned accesses
- Optimize code paths involving pgtable_l{4,5}_enabled() by patching in
the return values during early boot (since these don't change during
runtime), or by specifying the return values directly in Kconfig
files (for purpose-built kernels)
- Change the PCIe bus reassignment behavior to depend on the
PCI_REASSIGN_ALL_BUS PCI flag (as ARM64 does)
- Avoid an unnecessary sstatus CSR read during context switch
- Make the sbi_ecall() macro variadic, improving code clarity
[54 lines not shown]