makepad/libs/relax/compiler/tests/domain_base_dominator.rs
Admin ad03c2f488 makepad run / Relax: library stability, attribute shapes, more lints, x64 TLS fix
- stability: unstable std/core/alloc items need their feature (E0658) on every
  path, from a table generated from rustc's library sources (std/gen_stability.py)
- attributes: malformed `inline`/`must_use`/`deprecated`/`link*` (E0539/E0805/
  E0565) and other attribute-shape checks; `main` entry checks
- typeck: ManuallyDrop is a transparent lang-item struct (dyn unsizing through
  it works); invalid assignment targets (E0070/E0067); wide_pointer_comparisons
- consts: generic param order/defaults, const param types, E0572, cycles; NaN
  and non-structural constants in patterns; E0491/E0478 well-formedness
- parser: cfg paren-expr meta, `$t:ty` not a bound, items in impl/trait bodies
- lints: unused_imports from recorded import use; unused_mut through closures,
  non_shorthand_field_patterns, drop_bounds, dyn_drop and more
- codegen: x64 domain-base TLS read no longer skips its block (segfault fixed);
  arm64 constant-size copies of 32 B+ as 16-byte vector pairs
- rustc tests/ui agreement ~93.4%

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 23:20:42 +02:00

40 lines
960 B
Rust

// A function whose only domain-static uses sit in two branches below an if/else: the block that reads the
// domain base is their common dominator, which holds no instruction of its own; it must still run the read
// (x64 skips empty jump blocks). Output matches rustc.
use std::hint::black_box;
static TABLE_A: [u32; 4] = [1, 2, 3, 4];
static TABLE_B: [u32; 4] = [10, 20, 30, 40];
fn pick(mode: u32, i: usize) -> u32 {
let mut s = 0;
if mode & 1 == 0 {
if mode & 2 == 0 {
s += TABLE_A[i & 3];
} else {
s += TABLE_B[i & 3];
}
} else if mode & 4 == 0 {
s += TABLE_B[(i + 1) & 3] * 2;
} else {
s += TABLE_A[(i + 2) & 3] * 3;
}
s
}
fn run() {
let mut t = 0u64;
for r in 0..4000u32 {
t += pick(black_box(r % 8), black_box(r as usize)) as u64;
}
println!("{t}");
}
#[test]
fn base_read_in_empty_dominator() {
run();
}
fn main() {
run();
}