[llvm-jitlink] Fix a memory leak in llvm-jitlink-executor. (#223904)
In openListener, use a scope_exit to call freeaddrinfo on the struct
allocated by getaddrinfo.
No testcase: We have no in-tree tests for llvm-jitlink-executor. This
bug was found by inspection.
[lldb] Add HostInfoEmscripten (#223169)
Emscripten currently selects `HostInfoLinux`. That was useful as an initial bootstrap, but it also introduces Linux-specific assumptions such as `/proc/self/exe`, invoking `lsb_releas`e through `popen`, and
Linux-specific architecture handling.
This patch introduces a small `HostInfoEmscripten` implementation derived from `HostInfoPosix` and selects it when LLDB is built with Emscripten.
The implementation intentionally remains minimal. A browser-hosted LLDB process does not currently have a meaningful native executable path, so `GetProgramFileSpec()` returns an empty FileSpec.
A dedicated PlatformEmscripten and browser-specific process behavior will be handled separately so this change remains atomic !
[RISCV] Add DecodeSingleRegister template class to replace DecodeSPRegisterClass and similar. (#223889)
This can avoid adding more explicitly written decode functions for
https://github.com/llvm/llvm-project/pull/177073
[VPlan] Use frozen combined condition in early exit first-active-lane
Combined is used both to compute if an early exit was taken via VPInstruction::AnyOf, as well as the index of the early-exited lane in VPInstruction::FirstActiveLane.
Combined can have poison lanes past the exited lane, so the AnyOf uses freeze to prevent branching on poison. However FirstActiveLane on a vector with a poison lane is poison, so we need to also use the frozen version of Combined to prevent poison there.
[VPlan] Fix VPInstruction::AnyOf combine undoing freeze
There is an any-of combine for unrolled VPlans which does:
any-of (fcmp uno A, A), (fcmp uno B, B), ...-> any-of (fcmp uno A, B)
However any-of implicitly freezes each individual operand and this means we go from `freeze (fcmp uno A, A)` to `freeze (fcmp uno A, B)` which isn't sound: alive2.llvm.org/ce/z/UdQM7C
This causes miscompiles today with early exit loops, see the attached test case in single-early-exit-anyof-fold.ll.
This fixes it by explicitly modelling the freeze in VPlan. There are three places where we use AnyOf:
1) early exit loops: the freeze needs to be applied per-lane, so apply it to `(any-of (freeze (combined-conds-to-exit)))`
2) handleMaxMinNumReductions: If any lane of the reduction was poison in the scalar loop, the final result will be poison. We only need to freeze the result of AnyOf to prevent immediate UB when branching. Freezing individual operands blocks the any-of combine otherwise.
3) handleFindLastReductions: we need to freeze Cond itself since it's got multiple uses, but I plan on fixing this in a separate PR
[LLVM][NVPTX] Add async bulk copy global to shared extensions (#222323)
This change adds following things to bulk copy intrinsics.
1. Relaxed memory ordering semantics with a scope argument.
2. Data-validity reporting patterns (introduced in Rubin).
3. 32-bit multicast mask for global to shared::cluster variants
(introduced in Rubin).
4. Ignore out of bound checks for global to shared::cta variants.
Note: MLIR lowering is updated to emit the new intrinsic signatures.
Support for the new features in MLIR will be done in a separate change.
[VPlan] Append recipes created via builder to worklist
The previous PR appended the top most created recipe to the worklist, and this PR extends it to any other nested recipes that were created, similar to InstCombine.
This removes the header mask in a good few more places on RISC-V as measured on SPEC CPU 2017, e.g. for the following loop:
```c
long f(const int *p, const int *q, long n) {
long a = 0, b = 0;
for (long i = 0;; i++) {
if (p[i] && q[i]) { a += i; b += i; }
if (i + 1 == n) break;
}
return a + b;
}
```
Before:
[49 lines not shown]
[VPlan] Process combineRecipes in a worklist (#213899)
This brings combineRecipes further in line with InstCombine, and asides
from unlocking more simplifications it also helps avoid test churn
whenever passes are moved around combineRecipes.
For now just push the new recipe onto the worklist, not its users.
This uses a post order traversal so we maintain the same simplification
order as before.
[RISCV] Remap mop.rr.7 and mop.r.28 to sspush/sspopchk/ssrdp in the assembler. (#223894)
This makes llvm-mc output match llvm-objdump. And is more consistent
with the InstAliases we use c.mop.
[MC] Increase asm-macro-max-nesting-depth default to 100 (#218455)
GNU as accepts assembly we reject at the current default of 20, e.g.
glibc's
`sysdeps/unix/sysv/linux/alpha/rt_sigaction.S`, which nests 31 deep.
Raise the
default to 100, matching GNU as.
Assisted-by: Claude Code
[mlir][python] Register linalg.ElementwiseOp wrapper as op view
The hand-written ElementwiseOp wrapper subclassed the generated OpView but
was not registered in the op-view registry, so ops reconstructed from the
registry (e.g. Operation.opview) were instances of the generated base class
rather than the publicly exported subclass. This made
isinstance(op.opview, linalg.ElementwiseOp) and match/case dispatch return
False for real linalg.elementwise ops.
Register the wrapper with replace=True (as pdl.py does) so the exported
class is the one the registry instantiates.
Fixes #223673
[MLIR][NVVM] Fix the lowering of legacy mbar.arrive_drop (#222916)
`nvvm.mbarrier.arrive_drop` fails to compile for sm_80:
LLVM ERROR: Cannot select: intrinsic
%llvm.nvvm.mbarrier.arrive.drop.scope.cta.space.cta
The op always lowers to the `scope.*.space.*` intrinsics, which need
sm_90. The legacy `llvm.nvvm.mbarrier.arrive.drop{,.shared}` intrinsics
work from sm_80 but are never used.
This uses the legacy intrinsic for the basic case only, space=cta,
scope=cta, no relaxed, no explicit count, the same fix as #172476 for
`mbarrier.arrive`. The count forms need sm_90, so they are unchanged.
Assisted-by: Claude
[flang][cuda] Fix matching distance for use_device and none (#223849)
https://docs.nvidia.com/hpc-sdk/compilers/cuda-fortran-prog-guide/#unified-data
the table set the matching distance for actual `use_device` and dummy
argument `none` to 1 but the implementation set it to 3.
@wangzpgi Was there a specific reason to set 3 instead of 1?
[RISCV] Call DecodeGPRPairRegisterClass from DecodeGPRPairCRegisterClass. NFC (#223882)
GPRPairC is a subset of GPRPair. We just need to do the range check and
let DecodeGPRPairRegisterClass do the rest of the work.
[RISCV] Remove Zicfiss DecoderNamespace. NFC (#223891)
This used to be needed to prioritize c.sspopchk and c.sspush over
c.mop.1 and c.mop.5, but those are treated as InstAliases now.