authorgravatar for xtex@astrafall.orgxtex <xtex@astrafall.org> 2026-09-30 19:49:12+08:00
committergravatar for xtex@astrafall.orgxtex <xtex@astrafall.org> 2026-09-30 19:57:45+08:00
loge2d0773388ae25b3a55787968a5a652efdae07ea
tree6bb8dc142ef15642a16be23517ea7951edd642cd
parent874c40e7474ddfcbc5e96094e7c91f6918d5a32e
signature Signed by SSH key SHA256:IEYEjkZlkUTr5U9GiDAmZU/4eZus2t2RsxusyhQqwao

loongarch: fix volatile loads may be optimized


1 files changed, 4 insertions(+), 3 deletions(-)

src/codegen/loongarch/Select.zig+4-3
...@@ -1104,9 +1104,10 @@ pub const Value = struct {...@@ -1104,9 +1104,10 @@ pub const Value = struct {
1104 ) !bool {1104 ) !bool {
1105 try vi.reextendToPcs(isel);1105 try vi.reextendToPcs(isel);
1106 try vi.collectDefs(isel);1106 try vi.collectDefs(isel);
1107 if (opts.@"volatile")
1108 try (try vi.mat(isel, .{})).finish(isel);
1107 const loc = vi.takeLocationMarkWritten(isel) orelse return false;1109 const loc = vi.takeLocationMarkWritten(isel) orelse return false;
1108 wip_mir_log.debug(" | # load {f} <- [${t}, #{d}] ({d}B)", .{ vi, base_reg, offset, vi.size(isel) });1110 wip_mir_log.debug(" | # load {f} <- [${t}, #{d}] ({d}B)", .{ vi, base_reg, offset, vi.size(isel) });
1109 _ = opts;
11101111
1111 try isel.moveLoc(1112 try isel.moveLoc(
1112 loc,1113 loc,
...@@ -1277,7 +1278,6 @@ pub const Value = struct {...@@ -1277,7 +1278,6 @@ pub const Value = struct {
1277 }1278 }
12781279
1279 const MemoryAccessOptions = struct {1280 const MemoryAccessOptions = struct {
1280 // TODO unimplemented, remove?
1281 @"volatile": bool = false,1281 @"volatile": bool = false,
1282 };1282 };
12831283
...@@ -3971,7 +3971,8 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) codegen.Error!void...@@ -3971,7 +3971,8 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) codegen.Error!void
3971 const ptr_info = ptr_ty.ptrInfo(zcu);3971 const ptr_info = ptr_ty.ptrInfo(zcu);
3972 if (ptr_info.packed_offset.host_size > 0) return isel.fail("packed load", .{});3972 if (ptr_info.packed_offset.host_size > 0) return isel.fail("packed load", .{});
39733973
3974 if (ptr_info.flags.is_volatile) _ = try isel.use(air.inst_index.toRef());3974 if (ptr_info.flags.is_volatile)
3975 _ = try isel.use(air.inst_index.toRef());
3975 if (isel.live_values.fetchRemove(air.inst_index)) |dst_vi| {3976 if (isel.live_values.fetchRemove(air.inst_index)) |dst_vi| {
3976 defer dst_vi.value.deref(isel);3977 defer dst_vi.value.deref(isel);
39773978