authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-03-04 10:06:25+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-03-08 11:23:38+02:00
log1f4a097117a75b053d620658df4cb4e81c40fe1a
tree121da35d4732ae008b662911428198cae3a7cb71
parentba17552b4eb8def495053013eebbe39fc324c8ae

stage2: fix mem{set,cpy} for non comptime mutable pointers


4 files changed, 16 insertions(+), 15 deletions(-)

src/Sema.zig+8-12
...@@ -13831,13 +13831,11 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -13831,13 +13831,11 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
13831 const src_ptr = try sema.coerce(block, wanted_src_ptr_ty, uncasted_src_ptr, src_src);13831 const src_ptr = try sema.coerce(block, wanted_src_ptr_ty, uncasted_src_ptr, src_src);
13832 const len = try sema.coerce(block, Type.usize, sema.resolveInst(extra.byte_count), len_src);13832 const len = try sema.coerce(block, Type.usize, sema.resolveInst(extra.byte_count), len_src);
1383313833
13834 const maybe_dest_ptr_val = try sema.resolveDefinedValue(block, dest_src, dest_ptr);13834 const runtime_src = if (try sema.resolveDefinedValue(block, dest_src, dest_ptr)) |dest_ptr_val| rs: {
13835 const maybe_src_ptr_val = try sema.resolveDefinedValue(block, src_src, src_ptr);13835 if (!dest_ptr_val.isComptimeMutablePtr()) break :rs dest_src;
13836 const maybe_len_val = try sema.resolveDefinedValue(block, len_src, len);13836 if (try sema.resolveDefinedValue(block, src_src, src_ptr)) |src_ptr_val| {
1383713837 if (!src_ptr_val.isComptimeMutablePtr()) break :rs src_src;
13838 const runtime_src = if (maybe_dest_ptr_val) |dest_ptr_val| rs: {13838 if (try sema.resolveDefinedValue(block, len_src, len)) |len_val| {
13839 if (maybe_src_ptr_val) |src_ptr_val| {
13840 if (maybe_len_val) |len_val| {
13841 _ = dest_ptr_val;13839 _ = dest_ptr_val;
13842 _ = src_ptr_val;13840 _ = src_ptr_val;
13843 _ = len_val;13841 _ = len_val;
...@@ -13876,11 +13874,9 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -13876,11 +13874,9 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
13876 const value = try sema.coerce(block, elem_ty, sema.resolveInst(extra.byte), value_src);13874 const value = try sema.coerce(block, elem_ty, sema.resolveInst(extra.byte), value_src);
13877 const len = try sema.coerce(block, Type.usize, sema.resolveInst(extra.byte_count), len_src);13875 const len = try sema.coerce(block, Type.usize, sema.resolveInst(extra.byte_count), len_src);
1387813876
13879 const maybe_dest_ptr_val = try sema.resolveDefinedValue(block, dest_src, dest_ptr);13877 const runtime_src = if (try sema.resolveDefinedValue(block, dest_src, dest_ptr)) |ptr_val| rs: {
13880 const maybe_len_val = try sema.resolveDefinedValue(block, len_src, len);13878 if (!ptr_val.isComptimeMutablePtr()) break :rs dest_src;
1388113879 if (try sema.resolveDefinedValue(block, len_src, len)) |len_val| {
13882 const runtime_src = if (maybe_dest_ptr_val) |ptr_val| rs: {
13883 if (maybe_len_val) |len_val| {
13884 if (try sema.resolveMaybeUndefVal(block, value_src, value)) |val| {13880 if (try sema.resolveMaybeUndefVal(block, value_src, value)) |val| {
13885 _ = ptr_val;13881 _ = ptr_val;
13886 _ = len_val;13882 _ = len_val;
test/behavior.zig+2-2
...@@ -17,6 +17,7 @@ test {...@@ -17,6 +17,7 @@ test {
17 _ = @import("behavior/bugs/656.zig");17 _ = @import("behavior/bugs/656.zig");
18 _ = @import("behavior/bugs/679.zig");18 _ = @import("behavior/bugs/679.zig");
19 _ = @import("behavior/bugs/704.zig");19 _ = @import("behavior/bugs/704.zig");
20 _ = @import("behavior/bugs/718.zig");
20 _ = @import("behavior/bugs/1025.zig");21 _ = @import("behavior/bugs/1025.zig");
21 _ = @import("behavior/bugs/1076.zig");22 _ = @import("behavior/bugs/1076.zig");
22 _ = @import("behavior/bugs/1111.zig");23 _ = @import("behavior/bugs/1111.zig");
...@@ -124,6 +125,7 @@ test {...@@ -124,6 +125,7 @@ test {
124 _ = @import("behavior/bugs/10970.zig");125 _ = @import("behavior/bugs/10970.zig");
125 _ = @import("behavior/cast_int.zig");126 _ = @import("behavior/cast_int.zig");
126 _ = @import("behavior/eval.zig");127 _ = @import("behavior/eval.zig");
128 _ = @import("behavior/export_self_referential_type_info.zig");
127 _ = @import("behavior/int128.zig");129 _ = @import("behavior/int128.zig");
128 _ = @import("behavior/merge_error_sets.zig");130 _ = @import("behavior/merge_error_sets.zig");
129 _ = @import("behavior/translate_c_macros.zig");131 _ = @import("behavior/translate_c_macros.zig");
...@@ -154,7 +156,6 @@ test {...@@ -154,7 +156,6 @@ test {
154 }156 }
155 _ = @import("behavior/await_struct.zig");157 _ = @import("behavior/await_struct.zig");
156 _ = @import("behavior/bugs/529.zig");158 _ = @import("behavior/bugs/529.zig");
157 _ = @import("behavior/bugs/718.zig");
158 _ = @import("behavior/bugs/920.zig");159 _ = @import("behavior/bugs/920.zig");
159 _ = @import("behavior/bugs/1120.zig");160 _ = @import("behavior/bugs/1120.zig");
160 _ = @import("behavior/bugs/1851.zig");161 _ = @import("behavior/bugs/1851.zig");
...@@ -166,7 +167,6 @@ test {...@@ -166,7 +167,6 @@ test {
166 _ = @import("behavior/bugs/10147.zig");167 _ = @import("behavior/bugs/10147.zig");
167 _ = @import("behavior/const_slice_child.zig");168 _ = @import("behavior/const_slice_child.zig");
168 _ = @import("behavior/export.zig");169 _ = @import("behavior/export.zig");
169 _ = @import("behavior/export_self_referential_type_info.zig");
170 _ = @import("behavior/select.zig");170 _ = @import("behavior/select.zig");
171 _ = @import("behavior/shuffle.zig");171 _ = @import("behavior/shuffle.zig");
172 _ = @import("behavior/struct_contains_slice_of_itself.zig");172 _ = @import("behavior/struct_contains_slice_of_itself.zig");
test/behavior/bugs/718.zig+5
...@@ -1,4 +1,5 @@...@@ -1,4 +1,5 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
2const mem = std.mem;3const mem = std.mem;
3const expect = std.testing.expect;4const expect = std.testing.expect;
4const Keys = struct {5const Keys = struct {
...@@ -9,6 +10,10 @@ const Keys = struct {...@@ -9,6 +10,10 @@ const Keys = struct {
9};10};
10var keys: Keys = undefined;11var keys: Keys = undefined;
11test "zero keys with @memset" {12test "zero keys with @memset" {
13 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
14 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
15 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
16
12 @memset(@ptrCast([*]u8, &keys), 0, @sizeOf(@TypeOf(keys)));17 @memset(@ptrCast([*]u8, &keys), 0, @sizeOf(@TypeOf(keys)));
13 try expect(!keys.up);18 try expect(!keys.up);
14 try expect(!keys.down);19 try expect(!keys.down);
test/behavior/export_self_referential_type_info.zig+1-1
...@@ -1 +1 @@...@@ -1 +1 @@
1export const foo = @typeInfo(@This()).Struct.decls;1export const foo: c_int = @boolToInt(@typeInfo(@This()).Struct.is_tuple);