From c08c0fc6eddf601785abfbc5e5a9ab5c89d7cfbf Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 24 Sep 2023 14:37:36 -0700 Subject: revert "compiler: packed structs cache bit offsets" This is mostly a revert of a7088fd9a3edb037f0f51bb402a3c557334634f3. Measurement revealed the commit actually regressed performance. --- src/codegen/c.zig | 2 +- src/codegen/llvm.zig | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src/codegen') diff --git a/src/codegen/c.zig b/src/codegen/c.zig index ff472f7375..54e13db9a1 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -5429,7 +5429,7 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue { const bit_offset_ty = try mod.intType(.unsigned, Type.smallestUnsignedBits(int_info.bits - 1)); - const bit_offset = struct_type.fieldBitOffset(ip, extra.field_index); + const bit_offset = mod.structPackedFieldBitOffset(struct_type, extra.field_index); const bit_offset_val = try mod.intValue(bit_offset_ty, bit_offset); const field_int_signedness = if (inst_ty.isAbiInt(mod)) diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 7057516a51..dc2e2f3859 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -6192,7 +6192,6 @@ pub const FuncGen = struct { fn airStructFieldVal(self: *FuncGen, body_tail: []const Air.Inst.Index) !Builder.Value { const o = self.dg.object; const mod = o.module; - const ip = &mod.intern_pool; const inst = body_tail[0]; const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; const struct_field = self.air.extraData(Air.StructField, ty_pl.payload).data; @@ -6208,7 +6207,7 @@ pub const FuncGen = struct { .Struct => switch (struct_ty.containerLayout(mod)) { .Packed => { const struct_type = mod.typeToStruct(struct_ty).?; - const bit_offset = struct_type.fieldBitOffset(ip, field_index); + const bit_offset = mod.structPackedFieldBitOffset(struct_type, field_index); const containing_int = struct_llvm_val; const shift_amt = try o.builder.intValue(containing_int.typeOfWip(&self.wip), bit_offset); -- cgit v1.2.3