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 {
11041104 ) !bool {
11051105 try vi.reextendToPcs(isel);
11061106 try vi.collectDefs(isel);
1107 if (opts.@"volatile")
1108 try (try vi.mat(isel, .{})).finish(isel);
11071109 const loc = vi.takeLocationMarkWritten(isel) orelse return false;
11081110 wip_mir_log.debug(" | # load {f} <- [${t}, #{d}] ({d}B)", .{ vi, base_reg, offset, vi.size(isel) });
1109 _ = opts;
11101111
11111112 try isel.moveLoc(
11121113 loc,
......@@ -1277,7 +1278,6 @@ pub const Value = struct {
12771278 }
12781279
12791280 const MemoryAccessOptions = struct {
1280 // TODO unimplemented, remove?
12811281 @"volatile": bool = false,
12821282 };
12831283
......@@ -3971,7 +3971,8 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) codegen.Error!void
39713971 const ptr_info = ptr_ty.ptrInfo(zcu);
39723972 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());
39753976 if (isel.live_values.fetchRemove(air.inst_index)) |dst_vi| {
39763977 defer dst_vi.value.deref(isel);
39773978