[MLIR][XeGPU] Check that a split shape_cast layout collapses at subgroup level (#245861)
For a shape_cast that splits a source dim, the source layout is derived
by collapsing the result layout. That is only exact when each sg tile is
contiguous in the collapsed dim. setupShapeCastResultLayout already
checks this for inst_data and lane layouts, but not at subgroup level.
In simple_mxfp_gemm_quantizeA_F4/F8, the result layout sg_layout = [2,
1, 2], sg_data = [16, 32, 16] of a 32x1024 -> 32x32x32 shape_cast was
collapsed to sg_data = [16, 512]. Its sg tile is not contiguous, so the
scales came out wrong.
This PR adds the subgroup check. When a group does not collapse, its
subgroups move to the group's outer dims (here [2, 2, 1] / [16, 16,
32]), and a convert_layout gives the consumer its layout.
assisted-by-claude
---------
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[lld][MachO] Avoid redundant work in Writer::scanRelocations()
During relocation scanning, `Writer::scanRelocations()` looks up
`target->getRelocAttrs(r.type)` up to three times per symbol relocation
(in `scanRelocations()`, `validateSymbolRelocation()`, and
`prepareSymbolRelocation()`), tests `r.referent` twice for symbol
referents, and runs the full `validateSymbolRelocation()` body on every
symbol relocation even though it only rejects two rare
thread-local-variable cases.
Split the rare TLV validation logic in `validateSymbolRelocation()` into
a `LLVM_ATTRIBUTE_NOINLINE` helper, and mark `DylibSymbol` `final` so
`dysym->isTlv()` avoids a virtual call on the fast path. Fetch
`RelocAttrs` once per relocation, pass it to
`validateSymbolRelocation()` and `prepareSymbolRelocation()`, hoist
loop-invariant `target->relocAttrs` and `config->emitChainedFixups`, and
dispatch on `r.referent` once for non-subtractor relocations.
[lld][MachO][NFC] Move validateSymbolRelocation() into Writer.cpp (#248324)
`Writer::scanRelocations()` is the only caller of
`validateSymbolRelocation()`. Move it as-is into `Writer.cpp` as a
`static` helper in preparation for #246903 (which optimizes
`Writer::scanRelocations()` and includes the full benchmark results).
[SampleProfile] Keep inline-root discovery in the sample loader
Move the IR inline-frame scan and selective root discovery out of the
public SampleProfileReader API. The loader retains the same depth-ordered
algorithm and delegates named profile reads to the existing reader API.
Preserve nested-profile preference, missing-outer-frame discovery,
request deduplication, remapping, and error propagation.
Reject a missing or zero-head root before looking up the call target.
Use the matched profile's function identity directly, without changing
the target-count, definition, checksum, or phase checks.
Assisted-by: Metamate
[MC,RISCV] Use a symbol for the skip target of linker-relaxable long branches (#247437)
When the assembler relaxes an out-of-range conditional branch to an
inverted branch over a JAL, the branch should carry a relocation but
doesn't:
```
0: c.beqz a0, 0x6 # no relocation
2: jal zero, ext # R_RISCV_JAL ext, R_RISCV_RELAX
6:
```
Add a MCAsmBackend::relaxInstruction overload, overridden by RISC-V to
define a temporary symbol at the start of the next fragment and append
it to the long branch pseudo. The inverted branch targets that symbol
and gets an R_RISCV_BRANCH or R_RISCV_RVC_BRANCH relocation.
Fixes #236343
LLM-aided
[llvm-exegesis] Use memfd_create over shm_open (#246568)
The shm_open strategy relied on having a unique filename in /dev/shm per
exegesis invocation (which might be called on multiple threads in the
same process by API users). This is fundamentally fragile (see past
commits to add support for threads). The most recent example is that
bazel will try and run tests in some cases in their own PID namespaces
which breaks the current assumption that PIDs are globally unique.
Instead, use memfd_create so that we do not need to come up with a
globally unique name at all. This also removes a bunch of string
handling to construct filenames which is nice. The only potential issue
is that memfd_create was only introduced in Linux 3.4/a glibc of a
similar era. I remember people complaining that some parts of
llvm-exegesis broke builds on RHEL6 which uses Linux kernel 2 and does
not support memfd_create. But RHEL6 is extra dead at this point, so
hopefully that's not an issue anymore.
Assisted-By: LLM
[lld][MachO][NFC] Introduce SectionView for section-level predicates (#248238)
Add a lightweight `SectionView` wrapper implicitly constructible from
either a `Section` or an `InputSection`, and convert all section-level
predicate functions (`isCodeSection`, `isCfStringSection`,
`isClassRefsSection`, `isSelRefsSection`, `isEhFrameSection`,
`isGccExceptTabSection`, `usesAuthGot`, and ICF's
`isFoldableIgnoringRelocatedBytes`) to accept `SectionView`.
This avoids duplicating `(const Section &)` / `(const InputSection *)`
overloads as we refactor loops over `InputSection`s (which are generally
grouped by their originating `Section`) to hoist or cache section-level
predicate results across consecutive subsections of the same `Section`.
Assisted by Gemini.
RuntimeLibcalls: Make asan runtime available with out of tree support (#248131)
The previous set of systems was based on what targets are built in the
compiler-rt sources. However a few targets have out of tree runtimes,
so list those too (MSVC on AArch64, AMDGPU, Emscripten and the
PlayStation SDK). Also, drop the stack poisoning functions from
AMDGPU since the pass skips inserting those for it.
Assisted-by: Claude
[SampleProfile] Split stale inline-frame matching into a follow-up
Keep the basic inline-profile recovery in #245375 and move the stale-location
extension into a separate stacked change. Preserve selective root discovery,
nested-profile preference, missing-outer-frame handling, and the definition,
call-count, zero-head, and available-checksum checks.
Restore the existing stale-profile matcher, remove matching-only retrieval
policy and location-map accessors, and reject known checksum mismatches in
root fallback. Move the synthetic moved-probe tests with the extension while
retaining the basic recovery and negative checksum tests.
This commit is directly on top of 76cd07eceb984b3c248387a1c8f6ee0e891e7343,
so the published recovery commit does not need to be rewritten. The stacked
follow-up restores the original combined source tree exactly.
Assisted-by: OpenAI
[SampleProfile] Retrieve root profiles for inlined functions
Pre-link inlining can leave an inline frame whose samples are stored in a
separate root. Reading profiles only for surviving Function objects misses
that root. Looking only under the caller also fails when the profile and
IR inline trees disagree, including when an inner function is inlined first.
Put selective inline-root retrieval in the sample-profile reader so sample
loading and stale matching can both use it. Collect inline frames once,
prefer matching nested profiles, and batch missing-root reads by depth.
Do not let a missing outer profile hide a deeper frame or repeatedly request
names that are absent from the profile.
Let stale matching collect anchors inside eliminated inline frames and
reuse its existing matching algorithm and location-map distribution. For
MD5 profiles, resolve known callee hashes before the comparison loop.
Keep retrieval separate from permission to reuse sample counts. Post-link
fallback still checks the caller's count and probe checksum. Reject zero-head
[4 lines not shown]
[lld][MachO][NFC] Move validateSymbolRelocation() into Writer.cpp
`Writer::scanRelocations()` is the only caller of
`validateSymbolRelocation()`. Move it as-is into `Writer.cpp` as a
`static` helper in preparation for #246903 (which optimizes
`Writer::scanRelocations()` and includes the full benchmark results).
netipsec: Do not zero the IPv6 UDP checksum after NAT-T decapsulation
When transport mode ESP arrives in UDP and the IKE daemon gave no
original addresses (NAT-OA) for the SA, the default
net.inet.ipsec.natt_cksum_policy has udp_ipsec_adjust_cksum() ignore the
checksum of the inner header: a TCP segment is marked as verified and
the checksum of a UDP datagram is set to zero. This is option c of RFC
3948, section 3.1.2, which was written with IPv4 in mind. UDP over IPv6
has no "no checksum" value, so udp6_input() dropped every such datagram.
With strongSwan, which installs no NAT-OA for these SAs, TCP and ICMPv6
worked over an IPv6 transport mode SA with UDP encapsulation and UDP
did not.
Mark the datagram as verified instead, as is done for TCP. Linux does
the same for both address families. A datagram that the sender gave a
zero checksum is still dropped.
Fixes: 80044c785cb0 ("Add UDP encapsulation of ESP in IPv6")
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
[LoongArch] Prefer ALSL + LD/ST over SLLI + LDX/STX when the address is materialized anyway (#238715)
When (add Base, (shl Index, 1..4)) also has users other than the base
address of loads/stores, the add is selected as ALSL anyway. Folding it
into LDX/STX then needs a separate SLLI for the index, so use the ALSL
result with a zero offset instead:
```
alsl.d $a2, $a1, $a0, 3 alsl.d $a2, $a1, $a0, 3
slli.d $a1, $a1, 3 => ld.d $a3, $a2, 0
ldx.d $a3, $a0, $a1 ld.d $a2, $a2, 8
ld.d $a2, $a2, 8
```
rustc-perf fmt-write-str on LA664: 3988.1M -> 3973.1M instructions
(-0.38%).
Assisted-By: LLM
[lld][MachO][NFC] Introduce SectionView for section-level predicates
Add a lightweight `SectionView` wrapper implicitly constructible from
either a `Section` or an `InputSection`, and convert all section-level
predicate functions (`isCodeSection`, `isCfStringSection`,
`isClassRefsSection`, `isSelRefsSection`, `isEhFrameSection`,
`isGccExceptTabSection`, `usesAuthGot`, and ICF's
`isFoldableIgnoringRelocatedBytes`) to accept `SectionView`.
This avoids duplicating `(const Section &)` / `(const InputSection *)`
overloads as we refactor loops over `InputSection`s (which are generally
grouped by their originating `Section`) to hoist or cache section-level
predicate results across consecutive subsections of the same `Section`.
Planned follow-up sites include:
- `foldIdenticalSections()`, which evaluates `isCfStringSection`,
`isClassRefsSection`, `isSelRefsSection`, `isCodeSection`,
`isFoldableIgnoringRelocatedBytes`, and `isEhFrameSection` on every
subsection in `inputSections`:
[16 lines not shown]
[SampleProfile] Merge import GUIDs directly during inlining
Replace pending import metadata with a union of the callee's import GUIDs
into the caller's existing MD_prof record after a successful inline.
Preserve the caller's entry count, including unknown counts, and leave the
callee's hints intact even when its standalone definition survives.
Remove origin/deletion tracking and writer cleanup. Keep inherited hints
when pre-link sample annotation replaces the caller's entry-count record.
Use -sample-profile-preserve-import-hints at the inline propagation site.
Expand regressions for retained/deleted bodies, nested/repeated inlines,
counts, serialization, profile encodings, and a real ThinLTO import with
an enabled/disabled control.
[BOLT] Defer entry patch creation until after the fuIl function scan (#242986)
When a function's entry points cannot be patched, setIgnored() scans its
original code and may ignore an earlier target or mark a previously
skipped target as needing a patch. Emitting entry patches during the
same traversal can therefore leave stale trampolines, including
self-loops or miss required patches. This patch collects entry patches
in complete sweeps until these decisions stabilize, then emits them.
For RISC-V, small functions and compressed instructions make the 8-byte
entry trampoline harder to fit. Register clobbering may also require
retaining targets of nonstandard calls or branches to interior entries,
invalidating earlier entry patches.
For AArch64, the same issue can occur when a function cannot fit a
12-byte trampoline. Scanning its ADR or literal LDR references may force
an earlier target to remain in place, leaving a stale entry patch. But
for X86, ignore decisions are less likely.
lang/guile30: Update to 3.0.12
Upstream NEWS:
Changes in 3.0.12 (since 3.0.11)
* Notable changes
** Prettify compiler warnings à la GCC
** Circular imports that lead to `unbound-variable' are now better reported
(<https://codeberg.org/guile/guile/issues/250>)
** File I/O are now more responsive to asyncs
** New `scm_atfork()' C procedure
** Linux support for `clone' and `'unshare' system calls
[136 lines not shown]
powerpc: Avoid panicking on alignment errors
PowerPC ISA specifies that an alignment fault can occur when any load or
store accesses cache-inhibited or write-through memory. Since
copyin/copyout don't know what type of memory they will access we can't
always trust that memory is well behaved, or that it's properly aligned.
Avoid a panic by giving the fault handler a chance to deal with it and
propagate the fault back up.