[CIR][AMDGPU] Implement __builtin_amdgcn_ds_append and __builtin_amdgcn_ds_consume (#244656)
Adds CIRGen support for `__builtin_amdgcn_ds_append` and
`__builtin_amdgcn_ds_consume`. Adds CIR and LLVM IR test coverage in
`clang/test/CIR/CodeGenHIP/builtins-amdgcn.hip`.
Part of #241525
[Mips] Use libcalls for constrained FP arithmetic on R5900 (#246083)
The R5900 FPU does not implement NaN and infinity, so FADD, FSUB, FMUL,
FDIV and FSQRT only use it when fast-math flags rule those out and are
libcalls otherwise. Their constrained counterparts were Legal for all
hard-float subtargets though, so constrained arithmetic on the R5900
went to the FPU unconditionally.
Make them libcalls on the R5900. The FPU also always rounds toward zero,
so it cannot follow the rounding mode that constrained operations use,
even with fast-math flags.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[wasm] Swift async ABI p3: Lower llvm.swift.async.context.addr to local 0
In functions with a swiftasync argument, the async context is in local 0.
Loads and stores through llvm.swift.async.context.addr become local.get 0
and local.set 0. In functions without a swiftasync argument, the intrinsic
returns the address of a stack slot, as on X86 without an extended frame.
The swiftasync argument also arrives in local 0, so a store through the
intrinsic would also change the argument. Await resume funclets store their
own context through the intrinsic and can then read the argument, which is
the callee's context. To keep the argument intact, WebAssemblyExplicitLocals
copies it to another local in functions that use the intrinsic.
[CIR] Mark calls in strictfp functions strictfp
LangRef requires every call in a function that uses constrained FP
intrinsics to be `strictfp`, at the call site or on the callee, and
LLVM checks the call, not its caller, before it folds or simplifies a
libcall. Classic codegen gets the attribute from IRBuilder's
constrained mode. ClangIR marked only the function, so at -O1 LLVM
folded `erf(1.0)` to a constant under `FENV_ACCESS ON`.
The lowering now maps the CIR `strictfp` function attribute to the
`strictfp` attribute of `llvm.func` instead of a `passthrough` entry.
After the conversion to the LLVM dialect, it sets `strictfp` on every
`llvm.call`, `llvm.invoke`, `llvm.inline_asm` and `llvm.call_intrinsic`
in a `strictfp` function. That covers direct and indirect calls,
invokes, inline assembly, constrained intrinsics, and the calls that
LoweringPrepare and EH lowering create. CIR does not change, `strictfp`
stays a function attribute. The marks are part of the LLVM dialect, so
they survive any route to LLVM IR.
[11 lines not shown]
[mlir][ExecutionEngine] Move the OpenMP translation dependency to the C API (#246443)
`MLIRExecutionEngine` linked `MLIROpenMPToLLVMIRTranslation` although
the execution engine never uses OpenMP. Every C++ JIT user therefore
pulled in the OpenMP dialect.
The only user of the translation is the C API, which registers it since
db7cc0348c9a.
Link it from `MLIRCAPIExecutionEngine` instead.
Co-authored-by: Claude <noreply at anthropic.com>
[mlir][LLVM] Add strictfp to llvm.func and the call ops (#246250)
In a function that uses constrained floating-point intrinsics, LLVM
requires every call to be `strictfp`, at the call site or on the callee,
and its folders check the call before they fold or simplify a libcall.
The LLVM dialect could mark only the function, through `passthrough`, so
a frontend lowering to it had no way to mark its calls.
This adds a `strictfp` unit attribute to `llvm.func`, `llvm.call`,
`llvm.invoke`, `llvm.inline_asm` and `llvm.call_intrinsic`, the way the
dialect already models `convergent`, `no_unwind` and `will_return`.
Export turns it into the LLVM `strictfp` attribute and import reads it
back, so a `strictfp` function no longer lands in `passthrough`; the
tests cover round-trip, export and import for each op. Calls of the
constrained intrinsic ops already get the attribute from IRBuilder.
Other named intrinsic ops have no call-site attributes.
The inliner now refuses a callee marked `strictfp` and no longer looks
for `strictfp` in `passthrough`.
Assisted-by: Claude Code (Opus 5.5).
[libc] Implement getifaddrs for link-level (AF_PACKET) entries (#246355)
This is the first part of the real getifaddrs implementation. It dumps
the network interfaces (RTM_GETLINK) using the netlink code shared with
if_nameindex, and creates an AF_PACKET entry for each of them. The
entries contain the interface name and flags, and the hardware and
broadcast addresses (as struct sockaddr_ll). IPv4 and IPv6 addresses and
ifa_data will come in follow-up patches.
Like in if_nameindex, the entries are collected in a BlockStore while we
parse the messages, and then copied into a single allocation, which also
holds the names and addresses they point to. This makes freeifaddrs a
single delete[] (glibc does the same thing). Unlike if_nameindex, we
report allocation failures as ENOMEM, as that's what other getifaddrs
implementations do.
struct sockaddr_ll only has room for 8 bytes of hardware address, which
is not enough for e.g. InfiniBand (20 bytes). Like glibc and musl, I'm
using a version of the struct with a larger (MAX_ADDR_LEN = 32 byte)
[5 lines not shown]
[llvm][TableGen] Resolve intra-record field references to `?`
An inconsistency existed in TableGen prior to this PR:
* Referencing a template argument whose value was `?` resolved to and propagated `?`
* Referencing a record whose field is `?` resolved and propagated `?`
However, referencing a field of the record being built remained unresolved, even in the final resolution pass.
This meant that code like:
```tablegen
class Self {
string str = ?;
assert !if(!initialized(str), !ne(str, ""), 1), "str must not be empty";
}
def : Self;
```
would fail to compile as `!initialized(str)` was left unfolded, and `!if` never received a bit value: https://godbolt.org/z/oGh1PzP88
Similar issues arose with other code such as with `!dump` etc.
This PR fixes that issue by resolving a record field to `?` if the record is complete and this is the final resolve pass. As a follow-on effect, some places that previously relied on being kept unresolved now resolve to `?` which required implementing semantics for `?.field` accesses (instead of the current crash using `llvm_unreachable`). This PR therefore also defines `?.field` as resolving to `?`, similar to `?{0}` or `!cast`.
[CIR] Mark LoweringPrepare init functions strictfp
Classic codegen's StartFunction makes a function that has no
FunctionDecl `strictfp` when the TU-wide default FP environment is
constrained: FP exceptions are not ignored or the rounding mode is
dynamic. Of those functions ClangIR creates `_GLOBAL__sub_I_*`,
`_GLOBAL__I_*`, the C++20 module initializer, `__cxx_global_var_init*`,
`__cxx_global_array_dtor*` and `__tls_init`. It marked only
`__cxx_global_var_init*`, through a `strictfp` attribute on `cir.global`,
so the other functions and the calls in them were not `strictfp`.
Classic also marks the `__dtor_*` stubs, `_GLOBAL__D_a` and
`__GLOBAL_cleanup_*`, which ClangIR does not emit.
LoweringPrepare creates these functions after CIRGen, so it reads the
TU-wide default from `#cir.lowering_options`. `no_trapping_math` already
records whether FP exceptions are ignored, and the new `rounding_math`
field mirrors `LangOptions::RoundingMath`. It is omitted when false, so
the module attribute prints as before without `-frounding-math`.
`buildRuntimeFunction` adds `strictfp` together with the other TU-wide
[8 lines not shown]
[Mips] Don't use odd FPRs for single-precision arithmetic before MIPS32 (#245733)
Before MIPS32, single-precision arithmetic can only use the even FPRs
when the FPRs are 32 bits wide, since an odd FPR only holds the upper
half of a double. LLVM still used the odd FPRs for f32 on MIPS I to
MIPS IV with 32-bit FPRs, unless nooddspreg was given, so it emitted
code such as mul.s $f2, $f1, $f0.
Turn off the odd single-precision registers by default there, as GCC
does. This also emits .module nooddspreg and clears the ODDSPREG ABI
flag, as GAS does. A single-float FPU such as the R5900 has 32
single-precision FPRs, so single-float is not changed.
Clang already passes nooddspreg for MIPS II to MIPS V with O32, where
FPXX is the default, so this mostly affects MIPS I, -mfp32 and tools
that don't use the Clang driver.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[CIR] Mark calls in strictfp functions strictfp
LangRef requires every call in a function that uses constrained FP
intrinsics to be `strictfp`, at the call site or on the callee, and
LLVM checks the call, not its caller, before it folds or simplifies a
libcall. Classic codegen gets the attribute from IRBuilder's
constrained mode. ClangIR marked only the function, so at -O1 LLVM
folded `erf(1.0)` to a constant under `FENV_ACCESS ON`.
The lowering now maps the CIR `strictfp` function attribute to the
`strictfp` attribute of `llvm.func` instead of a `passthrough` entry.
After the conversion to the LLVM dialect, it sets `strictfp` on every
`llvm.call`, `llvm.invoke`, `llvm.inline_asm` and `llvm.call_intrinsic`
in a `strictfp` function. That covers direct and indirect calls,
invokes, inline assembly, constrained intrinsics, and the calls that
LoweringPrepare and EH lowering create. CIR does not change, `strictfp`
stays a function attribute. The marks are part of the LLVM dialect, so
they survive any route to LLVM IR.
[11 lines not shown]
[mlir][LLVM] Add strictfp to llvm.func and the call ops
In a function that uses constrained floating-point intrinsics, LLVM
requires every call to be `strictfp`, at the call site or on the callee,
and its folders check the call before they fold or simplify a libcall.
The LLVM dialect could mark only the function, through `passthrough`, so
a frontend lowering to it had no way to mark its calls.
This adds a `strictfp` unit attribute to `llvm.func`, `llvm.call`,
`llvm.invoke`, `llvm.inline_asm` and `llvm.call_intrinsic`, the way the
dialect already models `convergent`, `no_unwind` and `will_return`.
Export turns it into the LLVM `strictfp` attribute and import reads it
back, so a `strictfp` function no longer lands in `passthrough`. Calls
of the constrained intrinsic ops already get the attribute from
IRBuilder. Other named intrinsic ops have no call-site attributes.
The inliner now refuses a callee marked `strictfp` and no longer looks
for `strictfp` in `passthrough`.
Assisted-by: Claude Code (Opus 5.5).
amd64/vmm: Do not fall back to the VMCS for vmxctx registers
vmx_setreg() first calls vmxctx_setreg() and, if that fails, handles the
register as a VMCS field. This relies on vmxctx_setreg() failing only
for registers that are not kept in the vCPU context. Were it to reject
a value for one of its own registers, the error would be dropped and
the request passed on to vmcs_setreg(), which would fail it only
because the register has no VMCS field.
Check whether the register is kept in the vCPU context instead, and if
so return the result of vmxctx_setreg() directly. This lets
vmxctx_setreg() validate values and have its error returned as is. Do
the same in vmx_getreg(), so that the two functions read alike.
No functional change intended.
Reviewed by: markj
Approved by: markj
Sponsored by: Alchemilla Ventures Private Limited
Differential Revision: https://reviews.freebsd.org/D61954
amd64/vmm: Restore vmxctx registers through vmxctx_setreg()
vmx_vcpu_snapshot() copies the guest registers kept in the vCPU context
straight between the context and the snapshot buffer, while
VM_SET_REGISTER stores them through vmxctx_setreg(). A check added to
vmxctx_setreg() would thus not apply to values restored from a
snapshot.
Add vmxctx_snapshot_reg(), modelled on vmcs_snapshot_reg(), and use it
for every register in the vCPU context, so that both paths store values
the same way. The snapshot format does not change.
No functional change intended.
Reviewed by: markj
Approved by: markj
Sponsored by: Alchemilla Ventures Private Limited
Differential Revision: https://reviews.freebsd.org/D61953
lua-check: update to 1.2.0.
## [1.2.0] - 2024-05-24
### Features
- Add builtin standards support for minetest (#108) — @BuckarooBanzay and @appgurueu
### Performance
- Memoize results to addresses speed refression from new feature in v0.26 (#105) — @tomlau10
## [1.1.2] - 2023-12-08
### Features
- Support NO_COLOR environment variable (#102) — @ligurio
### Bug Fixes
[118 lines not shown]