diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-05-17 01:52:02 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-05-17 23:50:38 -0700 |
| commit | b6798c26efc4689cf35c5f4ac0436b4510a1f813 (patch) | |
| tree | 9507321f623264de9c5bef41ff53c19c88f09bd3 /src/codegen/llvm.zig | |
| parent | 95f5e17e49d32a301d6a9d6f9948719d65469b09 (diff) | |
| download | zig-b6798c26efc4689cf35c5f4ac0436b4510a1f813.tar.gz zig-b6798c26efc4689cf35c5f4ac0436b4510a1f813.zip | |
stage2: fix pointer arithmetic result type
This makes it so the result of doing pointer arithmetic creates a new
pointer type that has adjusted alignment.
Diffstat (limited to 'src/codegen/llvm.zig')
| -rw-r--r-- | src/codegen/llvm.zig | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index fb7a2c39bc..aba290060a 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -5679,7 +5679,8 @@ pub const FuncGen = struct { fn airPtrAdd(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value { if (self.liveness.isUnused(inst)) return null; - const bin_op = self.air.instructions.items(.data)[inst].bin_op; + const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; + const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data; const base_ptr = try self.resolveInst(bin_op.lhs); const offset = try self.resolveInst(bin_op.rhs); const ptr_ty = self.air.typeOf(bin_op.lhs); @@ -5698,7 +5699,8 @@ pub const FuncGen = struct { fn airPtrSub(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value { if (self.liveness.isUnused(inst)) return null; - const bin_op = self.air.instructions.items(.data)[inst].bin_op; + const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; + const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data; const base_ptr = try self.resolveInst(bin_op.lhs); const offset = try self.resolveInst(bin_op.rhs); const negative_offset = self.builder.buildNeg(offset, ""); |
