← Back to Pull requests

Reject integer atomicrmw operations without a SPIR-V opcode #4064

Closed
unknown closed this pull request without merging on Oct 07, 2026 19:10 UTC
View on GitHub
unknown unknown commented on Oct 06, 2026 15:32 UTC
Author

The writer decides whether an integer atomicrmw is supported with a deny list (nand, and since #3964 uinc_wrap/udec_wrap). Every other integer operation is assumed to have an entry in LLVMSPIRVAtomicRmwOpCodeMap, but usub_cond and usub_sat don't. SPIRVMap::map then returns a default opcode that has no instruction factory, and the translator crashes (a call through a null pointer, or the Invalid key assertion in builds with assertions) instead of reporting an error:

define spir_kernel void @test(ptr addrspace(1) %p) {
  %r = atomicrmw usub_sat ptr addrspace(1) %p, i32 1 monotonic
  ret void
}

$ llvm-spirv test.ll
Segmentation fault

This PR replaces the deny list with a lookup in the opcode map: an operation is supported iff it has an opcode, or it is fsub, which has no map entry and is lowered through OpFNegate + OpAtomicFAddEXT. That accepts the same floating-point operations as before (fadd, fsub, fmin, fmax) and exactly the integer operations with an opcode. Anything else, including operations LLVM adds in the future, gets the usual InvalidInstruction: ... Atomic usub_sat is not supported in SPIR-V! diagnostic. AMD targets are unaffected: there, SPIRVRegularizeLLVM rewrites uinc_wrap/udec_wrap into helper calls before the writer sees them.

The new test negative/atomicrmw-unsupported-int.ll covers usub_cond and usub_sat (nand, uinc_wrap and udec_wrap are already covered by existing tests). It fails without the change and passes with it. The rest of the lit suite gives the same results with and without the change.

Diff: 201 lines (+150 / -51) across 2 files Reviewer: MrSidims Review duration: 1658m
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 201 lines diff across 2 files
0.36
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.318
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4064"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 36.2% (MEDIUM) · Higher = larger blast radius
36.2%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 14.3% · Safe to merge
14.3%