| author | |
| committer | |
| log | d4bc64038ce40ac3829c3f1d0dc21dfb7484818c |
| tree | c19a38a7dbaac04cccf9d29271eadca25a0bb1eb |
| parent | ec337051a92b6f65bb29ddf41a290ea8e46b37b1 |
These instructions are not emitted by AstGen. They also would have no
effect even if they did appear in ZIR: the Sema handling for these
instructions creates a Decl which the name strategy is applied to, and
proceeds to never use it. This pointless CPU heater is now gone, saving
2 ZIR tags in the process.4 files changed, 3 insertions(+), 39 deletions(-)
lib/std/zig/AstGen.zig-2| ... | ... | @@ -2728,8 +2728,6 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As |
| 2728 | 2728 | .union_init, |
| 2729 | 2729 | .field_type_ref, |
| 2730 | 2730 | .error_set_decl, |
| 2731 | .error_set_decl_anon, | |
| 2732 | .error_set_decl_func, | |
| 2733 | 2731 | .enum_from_int, |
| 2734 | 2732 | .int_from_enum, |
| 2735 | 2733 | .type_info, |
lib/std/zig/Zir.zig-8| ... | ... | @@ -372,8 +372,6 @@ pub const Inst = struct { |
| 372 | 372 | /// An error set type definition. Contains a list of field names. |
| 373 | 373 | /// Uses the `pl_node` union field. Payload is `ErrorSetDecl`. |
| 374 | 374 | error_set_decl, |
| 375 | error_set_decl_anon, | |
| 376 | error_set_decl_func, | |
| 377 | 375 | /// Declares the beginning of a statement. Used for debug info. |
| 378 | 376 | /// Uses the `dbg_stmt` union field. The line and column are offset |
| 379 | 377 | /// from the parent declaration. |
| ... | ... | @@ -1078,8 +1076,6 @@ pub const Inst = struct { |
| 1078 | 1076 | .cmp_gt, |
| 1079 | 1077 | .cmp_neq, |
| 1080 | 1078 | .error_set_decl, |
| 1081 | .error_set_decl_anon, | |
| 1082 | .error_set_decl_func, | |
| 1083 | 1079 | .dbg_stmt, |
| 1084 | 1080 | .dbg_var_ptr, |
| 1085 | 1081 | .dbg_var_val, |
| ... | ... | @@ -1385,8 +1381,6 @@ pub const Inst = struct { |
| 1385 | 1381 | .cmp_gt, |
| 1386 | 1382 | .cmp_neq, |
| 1387 | 1383 | .error_set_decl, |
| 1388 | .error_set_decl_anon, | |
| 1389 | .error_set_decl_func, | |
| 1390 | 1384 | .decl_ref, |
| 1391 | 1385 | .decl_val, |
| 1392 | 1386 | .load, |
| ... | ... | @@ -1624,8 +1618,6 @@ pub const Inst = struct { |
| 1624 | 1618 | .@"try" = .pl_node, |
| 1625 | 1619 | .try_ptr = .pl_node, |
| 1626 | 1620 | .error_set_decl = .pl_node, |
| 1627 | .error_set_decl_anon = .pl_node, | |
| 1628 | .error_set_decl_func = .pl_node, | |
| 1629 | 1621 | .dbg_stmt = .dbg_stmt, |
| 1630 | 1622 | .dbg_var_ptr = .str_op, |
| 1631 | 1623 | .dbg_var_val = .str_op, |
src/Sema.zig+2-23| ... | ... | @@ -1156,9 +1156,7 @@ fn analyzeBodyInner( |
| 1156 | 1156 | .round => try sema.zirUnaryMath(block, inst, .round, Value.round), |
| 1157 | 1157 | .trunc => try sema.zirUnaryMath(block, inst, .trunc_float, Value.trunc), |
| 1158 | 1158 | |
| 1159 | .error_set_decl => try sema.zirErrorSetDecl(block, inst, .parent), | |
| 1160 | .error_set_decl_anon => try sema.zirErrorSetDecl(block, inst, .anon), | |
| 1161 | .error_set_decl_func => try sema.zirErrorSetDecl(block, inst, .func), | |
| 1159 | .error_set_decl => try sema.zirErrorSetDecl(inst), | |
| 1162 | 1160 | |
| 1163 | 1161 | .add => try sema.zirArithmetic(block, inst, .add, true), |
| 1164 | 1162 | .addwrap => try sema.zirArithmetic(block, inst, .addwrap, true), |
| ... | ... | @@ -3468,9 +3466,7 @@ fn zirOpaqueDecl( |
| 3468 | 3466 | |
| 3469 | 3467 | fn zirErrorSetDecl( |
| 3470 | 3468 | sema: *Sema, |
| 3471 | block: *Block, | |
| 3472 | 3469 | inst: Zir.Inst.Index, |
| 3473 | name_strategy: Zir.Inst.NameStrategy, | |
| 3474 | 3470 | ) CompileError!Air.Inst.Ref { |
| 3475 | 3471 | const tracy = trace(@src()); |
| 3476 | 3472 | defer tracy.end(); |
| ... | ... | @@ -3478,7 +3474,6 @@ fn zirErrorSetDecl( |
| 3478 | 3474 | const mod = sema.mod; |
| 3479 | 3475 | const gpa = sema.gpa; |
| 3480 | 3476 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 3481 | const src = inst_data.src(); | |
| 3482 | 3477 | const extra = sema.code.extraData(Zir.Inst.ErrorSetDecl, inst_data.payload_index); |
| 3483 | 3478 | |
| 3484 | 3479 | var names: InferredErrorSet.NameMap = .{}; |
| ... | ... | @@ -3495,23 +3490,7 @@ fn zirErrorSetDecl( |
| 3495 | 3490 | assert(!result.found_existing); // verified in AstGen |
| 3496 | 3491 | } |
| 3497 | 3492 | |
| 3498 | const error_set_ty = try mod.errorSetFromUnsortedNames(names.keys()); | |
| 3499 | ||
| 3500 | const new_decl_index = try sema.createAnonymousDeclTypeNamed( | |
| 3501 | block, | |
| 3502 | src, | |
| 3503 | error_set_ty.toValue(), | |
| 3504 | name_strategy, | |
| 3505 | "error", | |
| 3506 | inst, | |
| 3507 | ); | |
| 3508 | const new_decl = mod.declPtr(new_decl_index); | |
| 3509 | new_decl.owns_tv = true; | |
| 3510 | errdefer mod.abortAnonDecl(new_decl_index); | |
| 3511 | ||
| 3512 | const decl_val = sema.analyzeDeclVal(block, src, new_decl_index); | |
| 3513 | try mod.finalizeAnonDecl(new_decl_index); | |
| 3514 | return decl_val; | |
| 3493 | return Air.internedToRef((try mod.errorSetFromUnsortedNames(names.keys())).toIntern()); | |
| 3515 | 3494 | } |
| 3516 | 3495 | |
| 3517 | 3496 | fn zirRetPtr(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { |
src/print_zir.zig+1-6| ... | ... | @@ -452,9 +452,7 @@ const Writer = struct { |
| 452 | 452 | .try_ptr, |
| 453 | 453 | => try self.writeTry(stream, inst), |
| 454 | 454 | |
| 455 | .error_set_decl => try self.writeErrorSetDecl(stream, inst, .parent), | |
| 456 | .error_set_decl_anon => try self.writeErrorSetDecl(stream, inst, .anon), | |
| 457 | .error_set_decl_func => try self.writeErrorSetDecl(stream, inst, .func), | |
| 455 | .error_set_decl => try self.writeErrorSetDecl(stream, inst), | |
| 458 | 456 | |
| 459 | 457 | .switch_block, |
| 460 | 458 | .switch_block_ref, |
| ... | ... | @@ -1968,13 +1966,10 @@ const Writer = struct { |
| 1968 | 1966 | self: *Writer, |
| 1969 | 1967 | stream: anytype, |
| 1970 | 1968 | inst: Zir.Inst.Index, |
| 1971 | name_strategy: Zir.Inst.NameStrategy, | |
| 1972 | 1969 | ) !void { |
| 1973 | 1970 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 1974 | 1971 | const extra = self.code.extraData(Zir.Inst.ErrorSetDecl, inst_data.payload_index); |
| 1975 | 1972 | |
| 1976 | try stream.print("{s}, ", .{@tagName(name_strategy)}); | |
| 1977 | ||
| 1978 | 1973 | try stream.writeAll("{\n"); |
| 1979 | 1974 | self.indent += 2; |
| 1980 | 1975 |