tools: add LLVM IR empty-PHI smoke checker; ensures every 'phi i64' has incoming list; used with NYASH_LLVM_DUMP_IR
This commit is contained in:
38
tools/test/smoke/llvm/ir_phi_empty_check.sh
Normal file
38
tools/test/smoke/llvm/ir_phi_empty_check.sh
Normal file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Small smoke: ensure no empty PHI appears in IR
|
||||
# Usage: tools/test/smoke/llvm/ir_phi_empty_check.sh [nyash_script]
|
||||
|
||||
SCRIPT=${1:-apps/tests/loop_if_phi.nyash}
|
||||
|
||||
echo "[phi-empty-check] building nyash (llvm features)" >&2
|
||||
LLVM_PREFIX=${LLVM_SYS_180_PREFIX:-$(command -v llvm-config-18 >/dev/null 2>&1 && llvm-config-18 --prefix || true)}
|
||||
if [[ -n "${LLVM_PREFIX}" ]]; then
|
||||
LLVM_SYS_180_PREFIX="${LLVM_PREFIX}" cargo build --release --features llvm >/dev/null
|
||||
else
|
||||
cargo build --release --features llvm >/dev/null
|
||||
fi
|
||||
|
||||
IR_OUT=tmp/nyash_harness.ll
|
||||
mkdir -p tmp
|
||||
|
||||
echo "[phi-empty-check] running harness on ${SCRIPT}" >&2
|
||||
NYASH_LLVM_USE_HARNESS=1 \
|
||||
NYASH_LLVM_DUMP_IR="${IR_OUT}" \
|
||||
./target/release/nyash --backend llvm "${SCRIPT}" >/dev/null || true
|
||||
|
||||
if [[ ! -s "${IR_OUT}" ]]; then
|
||||
echo "[phi-empty-check] WARN: IR dump not found; harness may have short-circuited" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check: any phi i64 line must include '[' (incoming pairs)
|
||||
if rg -n "= phi i64( |$)" "${IR_OUT}" | rg -v "\\[" -n >/dev/null; then
|
||||
echo "[phi-empty-check] FAIL: empty PHI found (no incoming list)" >&2
|
||||
rg -n "\\= phi i64( |$)" "${IR_OUT}" | rg -v "\\[" -n || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[phi-empty-check] OK: no empty PHI detected in ${IR_OUT}" >&2
|
||||
exit 0
|
||||
Reference in New Issue
Block a user