weir
GPU-resident dataflow primitives over Vyre IR.
Weir 0.1.0 is the standalone dataflow crate in the Vyre 0.4.2 release train. The release package token is weir@0.1.0.
The default feature set is empty (default = []), library consumers that only
need program builders get a minimal compile. Enable serde for release-facing
witness and soundness evidence types: cargo add weir --features serde. The
standalone serde_evidence example declares required-features = ["serde"]
so feature-minimal builds do not accidentally compile serialization evidence
against a disabled feature. Enable cpu-parity to pull in the host reference
oracles used by the df_* integration tests and parity bench gates.
Stats at a glance
| Metric | Count |
|---|---|
| Test functions | ~1,443 |
| Fuzz targets | 9 |
| Benchmark suites | 12 |
Source files (src/*.rs) |
77 |
Lines of code (src/*.rs) |
~26,385 |
Feature flags
| Flag | Effect |
|---|---|
cpu-parity |
Enables weir::oracle CPU reference oracles and the full df_* parity/integration test suite. |
gpu-telemetry |
Enables GPU-accelerated telemetry (count_set_domain_bits_gpu, count_changed_domain_bits_gpu) for frontiers above 64 words. |
simd-oracle |
Enables AVX2-accelerated CPU parity oracles on x86_64. Performance-neutral fallback to scalar path when disabled or on other architectures. |
test-harness |
Pulls in vyre-primitives/cpu-parity and exposes weir::test_harness (mock backends, fixtures, adversarial generators). |
serde |
Enables serialization for witness and soundness evidence types. |
Weir is the dataflow layer that sits above vyre. It builds compiler-analysis
and security-analysis primitives as composable vyre::Programs: SSA, reaching
definitions, IFDS, points-to, range checks, slicing, callgraph queries, and
proof witness extraction.
What Weir is
Weir turns graph/fact buffers into dataflow results.
frontend graph buffers -> weir primitive -> vyre::Program -> CUDA/WGPU backend
|
+-> CPU oracle for parity
Frontends own source-language parsing. Weir owns the dataflow computation after the program has been lowered into graph and fact buffers.
CPU reference routines live under weir::oracle and are for parity,
conformance, fuzzing, and release evidence only. Production consumers should
build weir::* Programs and dispatch them through a concrete Vyre GPU backend;
direct cpu_ref / solve_cpu / compute_cpu helpers are not part of the production surface. Any remaining crate-private helpers with those names are
deprecated reference oracles and are gated by tests so they cannot become
fallback hooks.
What Weir is not
Weir is not a C parser, rule language, scanner, or raw shader library. It does not emit CUDA, WGSL, or PTX directly. Every GPU path is expressed through Vyre IR so backends and conformance stay centralized.
Current release surface
Core modules include:
| Module | Purpose |
|---|---|
ssa |
SSA helpers and phi-placement support |
def_use |
Def-use chain and def-use query programs |
reaching / reaching_def |
Reaching and reaching-definition GPU programs with parity oracles behind weir::oracle |
ifds_gpu |
GPU-native IFDS step construction; CPU reachability is parity-only behind weir::oracle |
reachability_witness |
Source-to-sink witness extraction from reachability masks |
points_to / may_alias |
Points-to and may-alias queries |
callgraph |
Callgraph reachability and query programs |
control_dependence |
Control-dependence bitset construction |
cross_language |
Cross-language edge fusion for multi-language graph analysis |
dominators / post_dominates |
Dominator, post-dominator, and post-dominates analyses |
escape / escapes |
Escape-analysis helpers and predicates |
live / live_at |
Liveness and point-query liveness programs |
must_init |
Must-initialize dataflow contracts |
range / range_check |
Value-range, range-check, and bound-check primitives |
scc_query |
Strongly connected component query programs |
slice |
Backward slicing |
summary / loop_sum |
Summary and loop acceleration helpers |
value_set |
Value-set membership summaries |
Analysis families
Weir's four bitset fixed-point analysis families (reaching, live, points_to, slice) share a single generic driver ladder. The AnalysisFamily trait (see src/analysis_family.rs) captures the invariant machinery:
KIND: analysis discriminant for plan/graph kind checking.NAME: human-readable prefix for error messages.build_program: constructs the Vyre transfer-stepProgramfor one iteration.prepare_graph/prepare_graph_with_scratch: builds invariant CSR graph buffers.closure_labels/resident_labels: label bundles for telemetry and diagnostics.
New families are added with the define_analysis_family! declarative macro:
cratedefine_analysis_family!
The macro generates the full suite of closure_* and resident_* wrapper functions so call sites stay stable during migration. See TESTING.md for the full guide on adding a family.
IFDS to witness flow
The full proof path is:
- Build or receive an exploded IFDS supergraph.
- Dispatch the Weir GPU step to produce reached nodes; use
weir::oracleonly for parity evidence. - Convert exploded
(proc, block, fact)nodes into statement reachability withexploded_reachability_to_statement_mask. - Prepare the proof graph once with
prepare_witness_graph. - Extract one or many source-to-sink witnesses with
extract_path_prepared.
The prepared graph path avoids rebuilding reverse CSR state for every finding.
Soundness
Every primitive soundness contract is explicit:
| Tag | Meaning |
|---|---|
Exact |
No false positives or false negatives given correct input buffers |
MayOver |
Over-approximates; safe for recall-first analysis with a filter |
MustUnder |
Under-approximates; only safe when false negatives are acceptable |
Compositions must join soundness conservatively. Use
PrecisionContract and PrimitiveSoundness to reject pipelines whose primitive
soundness cannot satisfy the consumer contract.
use ;
let joined = validate_pipeline?;
assert_eq!;
# Ok::
Minimal example
use ;
Release status
For this release, Weir's critical path is IFDS reachability plus witness extraction. Source parsing and full frontend integration live outside this crate.
Release evidence:
release/evidence/weir/weir-analysis-api-matrix.jsonrelease/evidence/weir/weir-vyre-integration-tests.jsonrelease/evidence/weir/weir-readme-contracts.jsonrelease/evidence/weir/weir-flow-release-contracts.json
Release evidence
Release readiness for this document is proven through the Vyre/Weir evidence manifest and generated artifacts under release/evidence/. Claims here must map to concrete gate output, benchmark output, conformance output, parser corpus output, or documentation proof files before the release requirement can be closed.
Weir release claims also depend on the Vyre backend release path: dataflow programs must remain backend-neutral Vyre IR while the release train proves CUDA as the NVIDIA fast path through vyre-driver-cuda@0.4.2 and WGPU as the secondary portable GPU backend through vyre-driver-wgpu@0.4.2.
Performance budget (host micro-LO)
Regression gates live in benches/primitive_micro.rs. Re-baseline with:
Document median time per iteration; CI should compare against the constants below multiplied by the regression factor.
| Primitive | Fixture | Baseline (ns/iter) | Regression factor |
|---|---|---|---|
stable_csr_layout_hash |
4-node diamond CSR, 4 edges | 1_200 | 1.15× |
fold_summary_partials |
DEFAULT_PARTIAL_BINS triples (3072 words) |
1_800 | 1.20× |
try_compute_dominators |
4-block diamond CFG | 8_500 | 1.25× |
resident_fixed_point_hot_cached_graph |
2-node reaching plan, window=2 | see resident_fixed_point_hot_path bench |
1.20× vs local baseline file |
Hot-path rules enforced in code:
- No
format!()on GPU decode success paths; cold diagnostics useerror_format+write!. - Dense
u32domains usedense_domain::DenseU32Slotsinstead ofHashMapwhere ids are bounded (SSA dominator postorder index). dispatch_decode::unpack_exact_u32_intoreuses callerVec<u32>and usesbytemuckon little-endian hosts.- CSR layout hashing uses word-slice FNV mixing without per-word
to_le_bytesallocation on LE hosts.
Testing
Quick-start commands:
# Fastest check, lib-only unit tests (~1,400 tests, ~20 s)
# Full host check including doc tests and examples
&& &&
# Full parity gate (requires CUDA-capable host + `cpu-parity`)
Weir's testing strategy is documented in TESTING.md, covering:
- The 4-vector strategy (Test Density, Performance & Innovation, Deduplication & Legoblock, Corpus & Fuzz).
- How to use
FakeResidentBackend,CsrFactory,IfdsProblemBuilder, andDominatorFixture. - Test categories: unit, integration, property-based, contract, doc, example, adversarial.
- How to run the full test suite and how to add a new analysis family.
Performance
Detailed optimization decisions, benchmark methodology, and profiling instructions live in PERF.md. Key decisions include:
- GPU telemetry threshold at 64 words.
bitset::equalfor unified host/device convergence.ScratchPoolfor zero-allocation staging.- SIMD oracle feature-gated and performance-neutral.
- Dominator GPU threshold at 1,000 nodes.
See INVENTORY.md for full crate layout and test coverage.