[RISCV][GlobalISel] Widen narrow G_CTTZ before lowering for XTHeadBb (#238214)
With XTHeadBb, `G_CTLZ` is legal only at XLEN. Narrow `G_CTTZ` and
`G_CTTZ_ZERO_POISON` were lowered at their original width, so
`LegalizerHelper` could not use `G_CTLZ` and fell back to the
popcount-based expansion.
This patch widens them to XLEN before lowering. The generic lowering
then emits `XLEN - ctlz(~x & (x - 1))`, which selects to `th.ff1`.
Closes https://github.com/llvm/llvm-project/issues/237492
CodeGen: Remove -verify-machineinstrs from llc -stop-after IR tests
llc verifies MIR outputs by default, so all -stop-after will perform a
final verifier run. They no longer run the verifier after every pass
in the pipeline, which is much more expensive and has low chance of
catching a transient verifier error. The full pipeline verification is
still covered in EXPENSIVE_CHECKS builds.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
AMDGPU: Remove kill flags on virtual registers from MIR tests
Soon the verifier will disallow this. Delete redundant tests which
only differed from others by kill flag uses. twoaddr-bundle.mir relied
on the input kill flags in TwoAddressInstruction, so compute
LiveIntervals first as the real pipeline does.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
libc/locale: Check EILSEQ return
_citrus_iconv_std_iconv_convert can return EILSEQ without setting
invlen. As a result, we should check EILSEQ in the return value or it
will incorrectly return -2
Reviewed by: kevans
Fixes: e2030ca246a7 ("libc: fix c*rtomb/mbrtoc*")
MFC after: 2 days
Differential Revision: https://reviews.freebsd.org/D61151
[clang][NFC] Test msvc multilib resource dirs (#238210)
As with other similar tests, explicitly add checks for the resource dir
paths added by the driver when using multilibs.
Assisted-by: AI
libunwind: Use libgcc's function context layout for sjlj (#238128)
Make call_site an i32 and the __data words pointer
sized. compiler-rt's SjLj_Function_Context was not defined in the same
way as libgcc.
This was broken for all 64-bit targets. Every field was i32, so the
exception pointer in __data[0] was truncated. It just happens that no
64-bit target defaults to SJLJ exceptions except VE. Instead of fixing
that, a VE special case was introduced in the libunwind sources and
SjLjEHPrepare, which had a special TargetMachine hook for this data
size. In reality it should just be a uintptr_t which we can already
infer from the DataLayout.
This is an ABI break for 64-bit targets other than VE when using
libunwind built for SjLj: the __data, personality, lsda and jbuf
offsets move, so compiled code and libunwind must be updated
together. That configuration was already broken by the pointer
truncation and is not the default anywhere. 32-bit targets are
[3 lines not shown]
Attributor: Add new call graph references before reanalyzing (#238535)
If a reference moved between two functions of the SCC, e.g. an argument
was replaced by the function passed at its only call site, reanalyzing the
caller first removed the edge that kept the target a descendant. Adding
the edge for the callee then failed the trivial edge assertion with
EXPENSIVE_CHECKS in cgscc-new-ref-edge.ll.
Add the reference edges of a new constant when it replaces a use, before
any function is reanalyzed.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[BOLT] Batch instruction insertion during instrumentation (#237930)
Insert each instrumentation snippet as a range to avoid repeatedly
shifting the remaining instructions in a basic block.
| Variant | Instrumentation Time (s) |
| --- | ---: |
| Baseline (before optimization) | 51.93 |
| commit | 40.19 |
---------
Co-authored-by: Jinjie Huang <huangjinjie at bytedance.com>
[LoopUnroll] Cap unrolling and peeling in very large loop nests (#221702)
Add an option, `-unroll-max-nest-loops` (default 128), that suppresses
**heuristic run-time unrolling, partial unrolling, and peeling** of a
loop when the outermost loop of its nest contains more than that many
loops.
Each of these transforms calls `forgetTopmostLoop` (from LoopUnroll and
LoopPeel), which invalidates ScalarEvolution for the entire top-level
nest. In a nest with a very large number of sibling/child loops,
transforming each candidate re-invalidates the whole nest, so compile
time grows quadratically with the nest size while the run-time benefit
of these transforms is negligible.
The nest size for each top-level loop is computed once per function, so
the guard adds only a constant-factor check per candidate loop. None of
the gated transforms enqueue new loops (remainder/peeled bodies are
never added to the worklist), and a nest that shrinks later only makes
the cap more conservative. Explicit unroll pragmas and forced counts are
[14 lines not shown]
AArch64: Remove kill flags on virtual registers from MIR tests
These will soon be disallowed by the verifier. Delete tests which only
tested kill flag maintenance and only differed from other functions in
kill flag uses.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[libc] Use a syscall wrapper for poll (#238266)
This PR move poll behind the centralized syscall wrappers, following
libc/docs/dev/syscall_wrapper_refactor.md.
---
<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
[libc] Use a syscall wrapper for openat (#238264)
This PR move openat behind the centralized syscall wrappers, following
libc/docs/dev/syscall_wrapper_refactor.md.
---
<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
[LoongArch] Select MULW_D_WU for zext i32 multiplied by a 32-bit constant
i32 udiv/urem by a constant is lowered on LA64 to
(mul (bstrpick X, 31, 0), C). MULW_D_WU only reads the low 32 bits of
its operands, so select it directly: the BSTRPICK goes away and, when
bit 31 of C is set, the constant can be materialized sign-extended
without LU32I_D.
rustc-perf fmt-write-str on LA664: 3998.1M -> 3988.1M instructions
(-0.25%).
Assisted-by: LLM
[Hexagon] Enable SlotIndexes compaction by default
Opt Hexagon in to dropping dead SlotIndexes entries before greedy
allocation, as AMDGPU already does, so live range sizes count only
instructions that still exist.
The test updates are register allocation changes; two pipeliner tests
get back their original, shorter kernels.
RuntimeLibcalls: Add signatures for size returning new and GPU profiling
__size_returning_new and its variants return __sized_ptr_t, a pointer
and size pair. The GPU profiling functions use the compiler-rt
prototypes.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
libunwind: Use libgcc's function context layout for sjlj
Make call_site an i32 and the __data words pointer
sized. compiler-rt's SjLj_Function_Context was not defined in the same
way as libgcc.
This was broken for all 64-bit targets. Every field was i32, so the
exception pointer in __data[0] was truncated. It just happens that no
64-bit target defaults to SJLJ exceptions except VE. Instead of fixing
that, a VE special case was introduced in the libunwind sources and
SjLjEHPrepare, which had a special TargetMachine hook for this data
size. In reality it should just be a uintptr_t which we can already
infer from the DataLayout.
This is an ABI break for 64-bit targets other than VE when using
libunwind built for SjLj: the __data, personality, lsda and jbuf
offsets move, so compiled code and libunwind must be updated
together. That configuration was already broken by the pointer
truncation and is not the default anywhere. 32-bit targets are
[4 lines not shown]
[Hexagon] Enable SlotIndexes compaction by default
Opt Hexagon in to dropping dead SlotIndexes entries before greedy
allocation, as AMDGPU already does, so live range sizes count only
instructions that still exist.
The test updates are register allocation changes; two pipeliner tests
get back their original, shorter kernels.
RuntimeLibcalls: Add a signature for __llvm_deoptimize
llvm.experimental.deoptimize is lowered to a call to __llvm_deoptimize
with the intrinsic's arguments and return type, which vary between
calls, so declare it as void (...). No actual output change because
this happens to be the filler signature used for unhandled functions.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Add signatures for size returning new and GPU profiling
__size_returning_new and its variants return __sized_ptr_t, a pointer
and size pair. The GPU profiling functions use the compiler-rt
prototypes.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[flang][NFC] Explain the -Waix-compat suppression in real-value.h (#238635)
Follow-up to 238605, which suppressed `-Waix-compat` on
`RealValue::opaque_` without saying why the warning does not point at a
real problem.
The warning flags a by-value struct with a 16-byte-aligned member as not
binary compatible with IBM XL C/C++ for AIX 16.1.0 or older. Here the
alignment is required: it is that of `RealValueImpl`, which comes from
`Real<>::word_`, and `real.h` already suppresses the same warning there.
Those older compilers cannot compile flang's C++17 code, so there is no
compatibility to preserve. This adds a comment saying so; no functional
change.
Assisted-by: AI
Set IsLittleEndian in arm64e-input-abi.s
#238122 makes IsLittleEndian required in Mach-O YAML. Set it here so this test works whichever of the two lands first.
Assisted-by: Claude Code