diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-02-28 19:22:16 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-02-28 19:22:16 -0700 |
| commit | 157f66ec077ad02f08891bec1a426c0ffef98e09 (patch) | |
| tree | 75b207ed6ccbbd2af83a338e09b86bc8de2965c4 /src/Module.zig | |
| parent | a7ca40b2817dbf3f2085141f32f20f431707391b (diff) | |
| download | zig-157f66ec077ad02f08891bec1a426c0ffef98e09.tar.gz zig-157f66ec077ad02f08891bec1a426c0ffef98e09.zip | |
Sema: fix pointer type hash and equality functions
Several issues with pointer types are fixed:
Prior to this commit, Zig would not canonicalize a pointer type with
an explicit alignment to alignment=0 if it matched the pointee ABI
alignment. In order to fix this, `Type.ptr` now takes a Target
parameter. I also moved the host_size canonicalization to `Type.ptr`
since target is now available. Similarly, is_allowzero in the case of
C pointers is now treated as a canonicalization done by the function
rather than a precondition.
in-memory coercion for pointers now properly checks ABI alignment
of pointee types instead of incorrectly treating the 0 value as an
alignment.
Type equality is completely reworked based on the tag() rather than the
zigTypeTag(). It's still semantically based on zigTypeTag() but that
knowledge is implied rather than dictating the control flow of the
logic. Importantly, this fixes cases for opaques, structs, tuples,
enums, and unions, where type equality was incorrectly returning based
on whether the tag() values were equal.
Additionally, pointer type equality now takes into account alignment.
Because we canonicalize non-zero alignment which equals pointee type ABI
alignment to alignment=0, this now can be a simple integer comparison.
Type hashing is implemented for pointers and floats. Array types now
additionally hash their sentinels.
This regressed some behavior tests that were passing but only because
of bugs regarding type equality.
The C backend has a noticeable problem with lowering differently-aligned
pointers (particularly slices) as the same type, causing C compilation
errors due to duplicate declarations.
Diffstat (limited to 'src/Module.zig')
0 files changed, 0 insertions, 0 deletions
