A lookup local was always an i64*, whatever the map's value type, so a
c_uint32 value was read with an 8-byte load (the verifier rejects an
access past value_size) and its spare `v_tmp` slot, typed i32, could not
take the i64 a rebind stored into it. The local now points at the
value's own width for an integer value (a struct value keeps the generic
pointer; field access casts it), and the generic pointer the lookup
helper returns is cast to it on assignment.
The sites that read the local by its pointer type follow:
- A comparison reads it as get_typed_operand does, at its width and
with the map's declared sign, so `u == 3` on a c_uint32 value is a
zext and an unsigned compare where needed (on c_uint64 values it was a
signed compare before).
- print() takes the format from the declared value type and widens by
its sign: a c_uint8 value was about to print as a string (%s on i8*),
and integers narrower than 32 bits now print as %d, promoted as C
varargs are.
- A rebind converts the i64 result to the slot's width.
holds_map_int_value names the predicate those sites share.
One IR-shape case per fix: u32 >>= / //= / %= emit lshr/udiv/urem;
ktime() >> 1 and pid() // 3 emit lshr/udiv; p >> 63 on a c_uint64 map
value is lshr; ctx.data - c_int32 is a u32 subtraction with the
trunc/zext pair rather than a 64-bit one.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Seven programs under passing_tests/signedness, one per case in
tests/c-form/signedness.bpf.c: unsigned and signed widening, mixed
division and remainder, unsigned comparison, u32 * u32 wrapping before
the widening, right shifts, and literal rank. Levels 1 and 2 compile
them like any other case; test_signedness_ir.py asserts the shape of the
IR against what clang emits for the C (zext vs sext, udiv vs sdiv,
icmp ugt vs sgt, lshr vs ashr, the trunc/zext pair around the wrap).
The XDP xfail note no longer claims the guard is a signed compare.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BSDVsZH5NtoASyxB8FCtGU