julia
e3176e22 - codegen: fix struct-path TBAA for union array elements

Commit
44 days ago
codegen: fix struct-path TBAA for union array elements When reading fields of a struct that was loaded from a union array element, the data was written to a stack alloca via memcpy with `jtbaa_arraybuf` TBAA. Subsequently, `best_field_tbaa` returned struct-path TBAA tags (e.g., `{jtbaa_struct_UnitRange, jtbaa_Int64, 0}`) for field reads from that alloca. These struct-path tags are in a disjoint TBAA subtree from `jtbaa_arraybuf`, causing LLVM to conclude the memcpy does not alias with the field loads — a miscompilation. Fix by only applying struct-path field TBAA when the parent struct's TBAA tag is compatible (the per-type tag, or generic value/data tags). When the parent TBAA is an arraybuf or other leaf tag (indicating data from a union array element), fall through to use the parent's TBAA for field loads, preserving correct aliasing. Also adds `type_metadata` alias scope region for GenericMemory metadata fields, and properly propagates alias scope region for union selector byte loads (previously defaulted to Region::unknown, losing all scope information). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Committer
Parents
Loading