authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-06-01 01:25:01-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:47:58-07:00
log123cfab98481554946208bd20a42ccc0c94681ef
tree6e8e6c5bb3269c1b68e4d6ad1b6256575cad0ca5
parent828756ceebaed09a90da81a5fc9a492443e2e8bb

codegen: fix doubled global sentinels


1 files changed, 18 insertions(+), 28 deletions(-)

src/codegen.zig+18-28
......@@ -387,36 +387,26 @@ pub fn generateSymbol(
387387 }
388388 },
389389 .aggregate => |aggregate| switch (mod.intern_pool.indexToKey(typed_value.ty.toIntern())) {
390 .array_type => |array_type| {
391 switch (aggregate.storage) {
392 .bytes => |bytes| try code.appendSlice(bytes),
393 .elems, .repeated_elem => {
394 var index: u64 = 0;
395 while (index < array_type.len) : (index += 1) {
396 switch (try generateSymbol(bin_file, src_loc, .{
397 .ty = array_type.child.toType(),
398 .val = switch (aggregate.storage) {
399 .bytes => unreachable,
400 .elems => |elems| elems[@intCast(usize, index)],
401 .repeated_elem => |elem| elem,
402 }.toValue(),
403 }, code, debug_output, reloc_info)) {
404 .ok => {},
405 .fail => |em| return .{ .fail = em },
406 }
390 .array_type => |array_type| switch (aggregate.storage) {
391 .bytes => |bytes| try code.appendSlice(bytes),
392 .elems, .repeated_elem => {
393 var index: u64 = 0;
394 var len_including_sentinel =
395 array_type.len + @boolToInt(array_type.sentinel != .none);
396 while (index < len_including_sentinel) : (index += 1) {
397 switch (try generateSymbol(bin_file, src_loc, .{
398 .ty = array_type.child.toType(),
399 .val = switch (aggregate.storage) {
400 .bytes => unreachable,
401 .elems => |elems| elems[@intCast(usize, index)],
402 .repeated_elem => |elem| elem,
403 }.toValue(),
404 }, code, debug_output, reloc_info)) {
405 .ok => {},
406 .fail => |em| return .{ .fail = em },
407407 }
408 },
409 }
410
411 if (array_type.sentinel != .none) {
412 switch (try generateSymbol(bin_file, src_loc, .{
413 .ty = array_type.child.toType(),
414 .val = array_type.sentinel.toValue(),
415 }, code, debug_output, reloc_info)) {
416 .ok => {},
417 .fail => |em| return .{ .fail = em },
418408 }
419 }
409 },
420410 },
421411 .vector_type => |vector_type| {
422412 switch (aggregate.storage) {