Metal's compiler leaves OpenCL C's barrier(flags) and mem_fence(flags) out of line: an internal
function passes its parameter on as air.wg.barrier's flags, and mem_fence computes
air.atomic.fence's flags from it through llvm.bitreverse.i2. Every call site passes a constant.
Decode refused the call (Intrinsic(ImmediateNotConstant)), and so every OpenCL kernel that
synchronizes was refused.
Decode now keeps such a call as Callee::Unbound, with the family its declaration names
(intrinsics::Template). Once inlining has made the parameter the call site's constant, SCCP's
edit binds it in the same rebuild, with no pass of its own. SCCP also folds the integer llvm.*
operations (min/max, ctpop, bitreverse, bswap) over constants. LlvmIntrinsic::NarrowInt decodes
those operations on widths no SPIR-V type has (i2), so the fence's flags fold. An immediate still
not constant after canonicalization is refused at the call, in post_check, with the inlined
entry's function location. A NarrowInt that survives is refused as Lowering(Arith).
Tests:
- canon::tests::unbound_immediates: each call site binds its own flags; binding meters no more
work than the constant twin (264 vs 265 units) and prints the same module; the i2 fence binds
after folding; flags read from a buffer are refused at the call.
- intrinsics::tests: the narrow-width decode.
- runtime tests::opencl_kernels: a barrier and a fence out of line compute what the M3 and the
Intel UHD 630 compute.
Verified on the same changes at base c956a4236c: metal2vulkan-air 516/516 (m3-max-4223), the
runtime test on lavapipe (m3-max-4223), and the consumer's glcheck b, b0, f and f0 passing with
the 5080 and 780M profiles (m3-max-4227).
(cherry picked from commit f49960f427b2f1371468b97a215788dea8018d45)
What: text_fingerprint no longer counts a call of `asm sideeffect "", ""` at the call type
`void ()` (llvm-dis's `call void asm sideeffect "", ""()`, then attributes or metadata
only). That's the one structure decode drops. Any other inline assembly stays an indirect call:
a flag, a template, a constraint or an operand.
Why: since decode drops that call, the decoded fingerprint of engine/kernel_inline_asm had 1
call where the text had 3 (2 through <indirect>), and public_fixtures_audit_as_matches failed
on stack5's gate.
Verified: bitcode_audit tests 8/8 on the M3, among them public_fixtures_audit_as_matches (which
failed in the gate before this) and the new the_text_scanner_skips_the_empty_inline_assembly_decode_drops
(two dropped spellings, four kept); clippy -p metal2vulkan-validation clean.
(cherry picked from commit bd573b20de31f693b5e1df1663432624f76a44e5)
Rolls up everything since 43c46ac8 into a single commit. Its tree is
identical to the tree of private master at
b3c77f2d2b20a432be10591a2129547c10b1c24b.
- A Cargo workspace of five crates under crates/: metal2vulkan (the
translator and the metal2vulkan command), metal2vulkan-runtime (the
Metal API on Vulkan), metal2vulkan-air (the AIR front end),
metal2vulkan-validation and metal2vulkan-devtools.
- Dual license: GPL-2.0-or-later OR LGPL-3.0-or-later.
- docs/: API, architecture, fast paths, how-to, Metal coverage,
refusals, runtime porting and validation guides.
Private-Commit: b3c77f2d2b20a432be10591a2129547c10b1c24b