sema: add comptime condbr, enable 15 new corpus tests

- Handle comptime-known conditions in condbr (BOOL_TRUE/BOOL_FALSE)
  by analyzing only the taken branch, matching upstream Sema.zig.
- Fix CoveragePoint encoding in branch_hints (1-bit enum, not 2-bit).
- Enable corpus tests: btf_ext, abs, arg, conj, scalbn, SplitMix64,
  shell_parameters, EH, generic, crypt32, isfinite, copysign.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-20 18:48:08 +00:00
parent 061353e55d
commit 7cedd3fe9a
2 changed files with 31 additions and 20 deletions

View File

@@ -3729,6 +3729,17 @@ static bool analyzeBodyInner(
AirInstRef cond = resolveInst(sema, condition_ref);
// Comptime-known condition: only analyze the taken branch
// on the parent block (matches Zig sema line 18343-18353).
if (cond == AIR_REF_FROM_IP(IP_INDEX_BOOL_TRUE)) {
return analyzeBodyInner(
sema, block, then_body, then_body_len);
}
if (cond == AIR_REF_FROM_IP(IP_INDEX_BOOL_FALSE)) {
return analyzeBodyInner(
sema, block, else_body, else_body_len);
}
// Analyze then-body in a sub-block.
SemaBlock then_block;
semaBlockInit(&then_block, sema, block);

View File

@@ -107,7 +107,7 @@ const corpus_files = .{
"../lib/compiler_rt/absvdi2.zig", // 311 -- needs alloc_mut, block, condbr, panic, call
"../lib/compiler_rt/absvsi2.zig", // 311
"../lib/compiler_rt/absvti2.zig", // 314
//"../lib/compiler_rt/addhf3.zig", // 319
//"../lib/compiler_rt/addhf3.zig", // 319 -- needs typeof_log2_int for non-int types
//"../lib/compiler_rt/addxf3.zig", // 323
//"../lib/compiler_rt/mulhf3.zig", // 323
//"../lib/compiler_rt/mulxf3.zig", // 323
@@ -146,8 +146,8 @@ const corpus_files = .{
//"../lib/std/crypto/pcurves/p384/field.zig", // 376
//"../lib/compiler_rt/subxf3.zig", // 399
//"../lib/compiler_rt/subhf3.zig", // 406
//"../lib/compiler_rt/negtf2.zig", // 409
//"../lib/std/os/linux/bpf/btf_ext.zig", // 419
//"../lib/compiler_rt/negtf2.zig", // 409 -- comptime if on cross-module bool (want_ppc_abi)
"../lib/std/os/linux/bpf/btf_ext.zig", // 419
//"../lib/compiler_rt/muldc3.zig", // 425
//"../lib/compiler_rt/mulhc3.zig", // 425
//"../lib/compiler_rt/mulsc3.zig", // 425
@@ -156,16 +156,16 @@ const corpus_files = .{
//"../lib/compiler_rt/divhc3.zig", // 434
//"../lib/compiler_rt/divsc3.zig", // 434
//"../lib/compiler_rt/divxc3.zig", // 434
//"../lib/std/math/complex/abs.zig", // 452
//"../lib/c/common.zig", // 457
//"../lib/std/math/complex/arg.zig", // 458
//"../lib/std/math/complex/conj.zig", // 484
//"../lib/std/math/scalbn.zig", // 503
//"../lib/compiler_rt/negdf2.zig", // 530
//"../lib/compiler_rt/negsf2.zig", // 530
//"../lib/std/Random/SplitMix64.zig", // 530
"../lib/std/math/complex/abs.zig", // 452
//"../lib/c/common.zig", // 457 -- resolvePeerType crash
"../lib/std/math/complex/arg.zig", // 458
"../lib/std/math/complex/conj.zig", // 484
"../lib/std/math/scalbn.zig", // 503
//"../lib/compiler_rt/negdf2.zig", // 530 -- comptime if on cross-module bool (want_aeabi)
//"../lib/compiler_rt/negsf2.zig", // 530 -- comptime if on cross-module bool (want_aeabi)
"../lib/std/Random/SplitMix64.zig", // 530
//"../lib/compiler_rt/gexf2.zig", // 531
//"../lib/std/os/uefi/protocol/shell_parameters.zig", // 544
"../lib/std/os/uefi/protocol/shell_parameters.zig", // 544
//"../lib/c/strings.zig", // 549
//"../lib/compiler_rt/fixdfei.zig", // 564
//"../lib/compiler_rt/fixhfei.zig", // 564
@@ -214,11 +214,11 @@ const corpus_files = .{
//"../lib/compiler_rt/unorddf2.zig", // 634
//"../lib/compiler_rt/unordsf2.zig", // 634
//"../lib/std/math/complex/asinh.zig", // 641
//"../lib/std/dwarf/EH.zig", // 643
"../lib/std/dwarf/EH.zig", // 643
//"../lib/compiler_rt/extendsfdf2.zig", // 644
//"../lib/std/math/complex/atanh.zig", // 645
//"../lib/compiler_rt/unordtf2.zig", // 656
//"../lib/std/Target/generic.zig", // 665
"../lib/std/Target/generic.zig", // 665
//"../lib/compiler_rt/absv.zig", // 671
//"../lib/std/math/complex/acosh.zig", // 678
//"../lib/compiler_rt/fixdfdi.zig", // 701
@@ -265,11 +265,11 @@ const corpus_files = .{
//"../lib/compiler_rt/udivti3.zig", // 770
//"../lib/compiler_rt/extenddftf2.zig", // 781
//"../lib/compiler_rt/extendsftf2.zig", // 781
//"../lib/std/Build/Step/Fail.zig", // 831
//"../lib/std/Build/Step/Fail.zig", // 831 -- 33 funcs in zig, 0 in C
//"../lib/std/crypto/test.zig", // 835
//"../lib/compiler_rt/bswapsi2_test.zig", // 840
//"../lib/compiler_rt/umodti3.zig", // 846
//"../lib/std/os/windows/crypt32.zig", // 850
"../lib/std/os/windows/crypt32.zig", // 850
//"../lib/compiler_rt/subvsi3.zig", // 860
//"../lib/compiler_rt/fixtfti.zig", // 867
//"../lib/compiler_rt/floattitf.zig", // 872
@@ -303,18 +303,18 @@ const corpus_files = .{
//"../lib/compiler_rt/divdf3_test.zig", // 1051
//"../lib/c/stdlib.zig", // 1067
//"../lib/compiler_rt/parityti2_test.zig", // 1078
//"../lib/std/math/isfinite.zig", // 1083
"../lib/std/math/isfinite.zig", // 1083
//"../lib/compiler_rt/bitreversedi2_test.zig", // 1102
//"../lib/compiler_rt/popcountti2_test.zig", // 1111
//"../lib/compiler_rt/divti3.zig", // 1113
//"../lib/std/math/copysign.zig", // 1136
"../lib/std/math/copysign.zig", // 1136
//"../lib/compiler_rt/negXi2.zig", // 1171
//"../lib/std/math/lcm.zig", // 1194
//"../lib/std/Target/lanai.zig", // 1207
//"../lib/std/Target/lanai.zig", // 1207 -- ptrChildType assertion
//"../lib/compiler_rt/negvdi2_test.zig", // 1209
//"../lib/compiler_rt/absvdi2_test.zig", // 1216
//"../lib/std/Io/counting_reader.zig", // 1227
//"../lib/std/Target/xcore.zig", // 1234
//"../lib/std/Target/xcore.zig", // 1234 -- ptrChildType assertion
//"../lib/std/zon.zig", // 1242
//"../lib/compiler_rt/modti3_test.zig", // 1243
//"../lib/std/valgrind/cachegrind.zig", // 1249