aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2022-12-04 23:50:28 -0500
committerAndrew Kelley <andrew@ziglang.org>2022-12-06 12:15:04 -0700
commitf421efbcc1eebfca5a723a5d4ee5aa685bcc10d8 (patch)
tree4ffeebda36c712ac185bde4a70cefe59e9a2464f /src/codegen
parentce4e5fee6346d142a7a98d5c56a056ff8a25e1f1 (diff)
downloadzig-f421efbcc1eebfca5a723a5d4ee5aa685bcc10d8.tar.gz
zig-f421efbcc1eebfca5a723a5d4ee5aa685bcc10d8.zip
CBE: fix bad local reuse for volatile memset
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/c.zig5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
index a569e47401..f32d53ef0d 100644
--- a/src/codegen/c.zig
+++ b/src/codegen/c.zig
@@ -5935,16 +5935,15 @@ fn airMemset(f: *Function, inst: Air.Inst.Index) !CValue {
const dest_ptr = try f.resolveInst(pl_op.operand);
const value = try f.resolveInst(extra.lhs);
const len = try f.resolveInst(extra.rhs);
- try reap(f, inst, &.{ pl_op.operand, extra.lhs, extra.rhs });
const writer = f.object.writer();
if (dest_ty.isVolatilePtr()) {
var u8_ptr_pl = dest_ty.ptrInfo();
u8_ptr_pl.data.pointee_type = Type.u8;
const u8_ptr_ty = Type.initPayload(&u8_ptr_pl.base);
+ const index = try f.allocLocal(inst, Type.usize);
try writer.writeAll("for (");
- const index = try f.allocLocal(inst, Type.usize);
try f.writeCValue(writer, index, .Other);
try writer.writeAll(" = ");
try f.object.dg.renderValue(writer, Type.usize, Value.zero, .Initializer);
@@ -5966,11 +5965,13 @@ fn airMemset(f: *Function, inst: Air.Inst.Index) !CValue {
try f.writeCValue(writer, value, .FunctionArgument);
try writer.writeAll(";\n");
+ try reap(f, inst, &.{ pl_op.operand, extra.lhs, extra.rhs });
try freeLocal(f, inst, index.local, 0);
return CValue.none;
}
+ try reap(f, inst, &.{ pl_op.operand, extra.lhs, extra.rhs });
try writer.writeAll("memset(");
try f.writeCValue(writer, dest_ptr, .FunctionArgument);
try writer.writeAll(", ");