Skip to content

Commit e3ff592

Browse files
committed
loongarch64: fix slice_ptr on non-slice types
It is a weird AIR construction. I am just doing what the x86-64 backend is doing.
1 parent 625a87b commit e3ff592

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/arch/loongarch64/CodeGen.zig

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3816,9 +3816,14 @@ fn airIsErr(cg: *CodeGen, inst: Air.Inst.Index, inverted: bool) !void {
38163816
fn airSlicePtr(cg: *CodeGen, inst: Air.Inst.Index) !void {
38173817
const ty_op = cg.getAirData(inst).ty_op;
38183818
const op = (try cg.tempsFromOperands(inst, .{ty_op.operand}))[0];
3819-
const ptr_ty = ty_op.ty.toType().slicePtrFieldType(cg.pt.zcu);
3820-
const dst = try op.getLimb(ptr_ty, 0, cg, cg.liveness.operandDies(inst, 0));
3821-
try dst.finish(inst, &.{op}, cg);
3819+
const ty = ty_op.ty.toType();
3820+
if (ty.isSlice(cg.pt.zcu)) {
3821+
const ptr_ty = ty_op.ty.toType().slicePtrFieldType(cg.pt.zcu);
3822+
const dst = try op.getLimb(ptr_ty, 0, cg, cg.liveness.operandDies(inst, 0));
3823+
try dst.finish(inst, &.{op}, cg);
3824+
} else {
3825+
try op[0].finish(inst, &.{op}, cg);
3826+
}
38223827
}
38233828

38243829
fn airSliceLen(cg: *CodeGen, inst: Air.Inst.Index) !void {

0 commit comments

Comments
 (0)