aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-09-20 17:57:18 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-09-21 14:48:40 -0700
commitd06bf707ed374ca42a580ee7acf1cecaab078d0d (patch)
tree09056238283ef9041bb2e3389d59522664088f76 /src/Module.zig
parent51b1a2a6cb1a48260a37c407adbb4b796cf58a54 (diff)
downloadzig-d06bf707ed374ca42a580ee7acf1cecaab078d0d.tar.gz
zig-d06bf707ed374ca42a580ee7acf1cecaab078d0d.zip
compiler: make pointer type canonicalization always work
Previously it would canonicalize or not depending on some volatile internal state of the compiler, now it forces resolution of the element type to determine the alignment if it needs to.
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/Module.zig b/src/Module.zig
index 712122f1b4..cb6600696d 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -5937,7 +5937,6 @@ pub fn optionalType(mod: *Module, child_type: InternPool.Index) Allocator.Error!
pub fn ptrType(mod: *Module, info: InternPool.Key.PtrType) Allocator.Error!Type {
var canon_info = info;
- const have_elem_layout = info.child.toType().layoutIsResolved(mod);
if (info.flags.size == .C) canon_info.flags.is_allowzero = true;
@@ -5945,7 +5944,7 @@ pub fn ptrType(mod: *Module, info: InternPool.Key.PtrType) Allocator.Error!Type
// type, we change it to 0 here. If this causes an assertion trip because the
// pointee type needs to be resolved more, that needs to be done before calling
// this ptr() function.
- if (info.flags.alignment != .none and have_elem_layout and
+ if (info.flags.alignment != .none and
info.flags.alignment == info.child.toType().abiAlignment(mod))
{
canon_info.flags.alignment = .none;
@@ -5955,7 +5954,7 @@ pub fn ptrType(mod: *Module, info: InternPool.Key.PtrType) Allocator.Error!Type
// Canonicalize host_size. If it matches the bit size of the pointee type,
// we change it to 0 here. If this causes an assertion trip, the pointee type
// needs to be resolved before calling this ptr() function.
- .none => if (have_elem_layout and info.packed_offset.host_size != 0) {
+ .none => if (info.packed_offset.host_size != 0) {
const elem_bit_size = info.child.toType().bitSize(mod);
assert(info.packed_offset.bit_offset + elem_bit_size <= info.packed_offset.host_size * 8);
if (info.packed_offset.host_size * 8 == elem_bit_size) {