authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-06-11 21:00:39+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-06-15 00:57:52+01:00
log07a24bec9a578857920f4c5508f1d7eea65177b8
tree3edd81d1bff8219dd9122291041b28c5ea5ec9ce
parente39cc0dff7fff510c3d72f61947b977589ea5583
signaturelock-open Commit is signed but in an unrecognized format.

compiler: move LazySrcLoc out of std

This is in preparation for some upcoming changes to how we represent source locations in the compiler. The bulk of the change here is dealing with the removal of `src()` methods from `Zir` types.

12 files changed, 632 insertions(+), 679 deletions(-)

lib/std/zig.zig-373
......@@ -350,379 +350,6 @@ pub fn serializeCpuAlloc(ally: Allocator, cpu: std.Target.Cpu) Allocator.Error![
350350 return buffer.toOwnedSlice();
351351}
352352
353pub const DeclIndex = enum(u32) {
354 _,
355
356 pub fn toOptional(i: DeclIndex) OptionalDeclIndex {
357 return @enumFromInt(@intFromEnum(i));
358 }
359};
360
361pub const OptionalDeclIndex = enum(u32) {
362 none = std.math.maxInt(u32),
363 _,
364
365 pub fn init(oi: ?DeclIndex) OptionalDeclIndex {
366 return @enumFromInt(@intFromEnum(oi orelse return .none));
367 }
368
369 pub fn unwrap(oi: OptionalDeclIndex) ?DeclIndex {
370 if (oi == .none) return null;
371 return @enumFromInt(@intFromEnum(oi));
372 }
373};
374
375/// Resolving a source location into a byte offset may require doing work
376/// that we would rather not do unless the error actually occurs.
377/// Therefore we need a data structure that contains the information necessary
378/// to lazily produce a `SrcLoc` as required.
379/// Most of the offsets in this data structure are relative to the containing Decl.
380/// This makes the source location resolve properly even when a Decl gets
381/// shifted up or down in the file, as long as the Decl's contents itself
382/// do not change.
383pub const LazySrcLoc = union(enum) {
384 /// When this tag is set, the code that constructed this `LazySrcLoc` is asserting
385 /// that all code paths which would need to resolve the source location are
386 /// unreachable. If you are debugging this tag incorrectly being this value,
387 /// look into using reverse-continue with a memory watchpoint to see where the
388 /// value is being set to this tag.
389 unneeded,
390 /// Means the source location points to an entire file; not any particular
391 /// location within the file. `file_scope` union field will be active.
392 entire_file,
393 /// The source location points to a byte offset within a source file,
394 /// offset from 0. The source file is determined contextually.
395 /// Inside a `SrcLoc`, the `file_scope` union field will be active.
396 byte_abs: u32,
397 /// The source location points to a token within a source file,
398 /// offset from 0. The source file is determined contextually.
399 /// Inside a `SrcLoc`, the `file_scope` union field will be active.
400 token_abs: u32,
401 /// The source location points to an AST node within a source file,
402 /// offset from 0. The source file is determined contextually.
403 /// Inside a `SrcLoc`, the `file_scope` union field will be active.
404 node_abs: u32,
405 /// The source location points to a byte offset within a source file,
406 /// offset from the byte offset of the Decl within the file.
407 /// The Decl is determined contextually.
408 byte_offset: u32,
409 /// This data is the offset into the token list from the Decl token.
410 /// The Decl is determined contextually.
411 token_offset: u32,
412 /// The source location points to an AST node, which is this value offset
413 /// from its containing Decl node AST index.
414 /// The Decl is determined contextually.
415 node_offset: TracedOffset,
416 /// The source location points to the main token of an AST node, found
417 /// by taking this AST node index offset from the containing Decl AST node.
418 /// The Decl is determined contextually.
419 node_offset_main_token: i32,
420 /// The source location points to the beginning of a struct initializer.
421 /// The Decl is determined contextually.
422 node_offset_initializer: i32,
423 /// The source location points to a variable declaration type expression,
424 /// found by taking this AST node index offset from the containing
425 /// Decl AST node, which points to a variable declaration AST node. Next, navigate
426 /// to the type expression.
427 /// The Decl is determined contextually.
428 node_offset_var_decl_ty: i32,
429 /// The source location points to the alignment expression of a var decl.
430 /// The Decl is determined contextually.
431 node_offset_var_decl_align: i32,
432 /// The source location points to the linksection expression of a var decl.
433 /// The Decl is determined contextually.
434 node_offset_var_decl_section: i32,
435 /// The source location points to the addrspace expression of a var decl.
436 /// The Decl is determined contextually.
437 node_offset_var_decl_addrspace: i32,
438 /// The source location points to the initializer of a var decl.
439 /// The Decl is determined contextually.
440 node_offset_var_decl_init: i32,
441 /// The source location points to the first parameter of a builtin
442 /// function call, found by taking this AST node index offset from the containing
443 /// Decl AST node, which points to a builtin call AST node. Next, navigate
444 /// to the first parameter.
445 /// The Decl is determined contextually.
446 node_offset_builtin_call_arg0: i32,
447 /// Same as `node_offset_builtin_call_arg0` except arg index 1.
448 node_offset_builtin_call_arg1: i32,
449 node_offset_builtin_call_arg2: i32,
450 node_offset_builtin_call_arg3: i32,
451 node_offset_builtin_call_arg4: i32,
452 node_offset_builtin_call_arg5: i32,
453 /// Like `node_offset_builtin_call_arg0` but recurses through arbitrarily many calls
454 /// to pointer cast builtins.
455 node_offset_ptrcast_operand: i32,
456 /// The source location points to the index expression of an array access
457 /// expression, found by taking this AST node index offset from the containing
458 /// Decl AST node, which points to an array access AST node. Next, navigate
459 /// to the index expression.
460 /// The Decl is determined contextually.
461 node_offset_array_access_index: i32,
462 /// The source location points to the LHS of a slice expression
463 /// expression, found by taking this AST node index offset from the containing
464 /// Decl AST node, which points to a slice AST node. Next, navigate
465 /// to the sentinel expression.
466 /// The Decl is determined contextually.
467 node_offset_slice_ptr: i32,
468 /// The source location points to start expression of a slice expression
469 /// expression, found by taking this AST node index offset from the containing
470 /// Decl AST node, which points to a slice AST node. Next, navigate
471 /// to the sentinel expression.
472 /// The Decl is determined contextually.
473 node_offset_slice_start: i32,
474 /// The source location points to the end expression of a slice
475 /// expression, found by taking this AST node index offset from the containing
476 /// Decl AST node, which points to a slice AST node. Next, navigate
477 /// to the sentinel expression.
478 /// The Decl is determined contextually.
479 node_offset_slice_end: i32,
480 /// The source location points to the sentinel expression of a slice
481 /// expression, found by taking this AST node index offset from the containing
482 /// Decl AST node, which points to a slice AST node. Next, navigate
483 /// to the sentinel expression.
484 /// The Decl is determined contextually.
485 node_offset_slice_sentinel: i32,
486 /// The source location points to the callee expression of a function
487 /// call expression, found by taking this AST node index offset from the containing
488 /// Decl AST node, which points to a function call AST node. Next, navigate
489 /// to the callee expression.
490 /// The Decl is determined contextually.
491 node_offset_call_func: i32,
492 /// The payload is offset from the containing Decl AST node.
493 /// The source location points to the field name of:
494 /// * a field access expression (`a.b`), or
495 /// * the callee of a method call (`a.b()`)
496 /// The Decl is determined contextually.
497 node_offset_field_name: i32,
498 /// The payload is offset from the containing Decl AST node.
499 /// The source location points to the field name of the operand ("b" node)
500 /// of a field initialization expression (`.a = b`)
501 /// The Decl is determined contextually.
502 node_offset_field_name_init: i32,
503 /// The source location points to the pointer of a pointer deref expression,
504 /// found by taking this AST node index offset from the containing
505 /// Decl AST node, which points to a pointer deref AST node. Next, navigate
506 /// to the pointer expression.
507 /// The Decl is determined contextually.
508 node_offset_deref_ptr: i32,
509 /// The source location points to the assembly source code of an inline assembly
510 /// expression, found by taking this AST node index offset from the containing
511 /// Decl AST node, which points to inline assembly AST node. Next, navigate
512 /// to the asm template source code.
513 /// The Decl is determined contextually.
514 node_offset_asm_source: i32,
515 /// The source location points to the return type of an inline assembly
516 /// expression, found by taking this AST node index offset from the containing
517 /// Decl AST node, which points to inline assembly AST node. Next, navigate
518 /// to the return type expression.
519 /// The Decl is determined contextually.
520 node_offset_asm_ret_ty: i32,
521 /// The source location points to the condition expression of an if
522 /// expression, found by taking this AST node index offset from the containing
523 /// Decl AST node, which points to an if expression AST node. Next, navigate
524 /// to the condition expression.
525 /// The Decl is determined contextually.
526 node_offset_if_cond: i32,
527 /// The source location points to a binary expression, such as `a + b`, found
528 /// by taking this AST node index offset from the containing Decl AST node.
529 /// The Decl is determined contextually.
530 node_offset_bin_op: i32,
531 /// The source location points to the LHS of a binary expression, found
532 /// by taking this AST node index offset from the containing Decl AST node,
533 /// which points to a binary expression AST node. Next, navigate to the LHS.
534 /// The Decl is determined contextually.
535 node_offset_bin_lhs: i32,
536 /// The source location points to the RHS of a binary expression, found
537 /// by taking this AST node index offset from the containing Decl AST node,
538 /// which points to a binary expression AST node. Next, navigate to the RHS.
539 /// The Decl is determined contextually.
540 node_offset_bin_rhs: i32,
541 /// The source location points to the operand of a switch expression, found
542 /// by taking this AST node index offset from the containing Decl AST node,
543 /// which points to a switch expression AST node. Next, navigate to the operand.
544 /// The Decl is determined contextually.
545 node_offset_switch_operand: i32,
546 /// The source location points to the else/`_` prong of a switch expression, found
547 /// by taking this AST node index offset from the containing Decl AST node,
548 /// which points to a switch expression AST node. Next, navigate to the else/`_` prong.
549 /// The Decl is determined contextually.
550 node_offset_switch_special_prong: i32,
551 /// The source location points to all the ranges of a switch expression, found
552 /// by taking this AST node index offset from the containing Decl AST node,
553 /// which points to a switch expression AST node. Next, navigate to any of the
554 /// range nodes. The error applies to all of them.
555 /// The Decl is determined contextually.
556 node_offset_switch_range: i32,
557 /// The source location points to the capture of a switch_prong.
558 /// The Decl is determined contextually.
559 node_offset_switch_prong_capture: i32,
560 /// The source location points to the tag capture of a switch_prong.
561 /// The Decl is determined contextually.
562 node_offset_switch_prong_tag_capture: i32,
563 /// The source location points to the align expr of a function type
564 /// expression, found by taking this AST node index offset from the containing
565 /// Decl AST node, which points to a function type AST node. Next, navigate to
566 /// the calling convention node.
567 /// The Decl is determined contextually.
568 node_offset_fn_type_align: i32,
569 /// The source location points to the addrspace expr of a function type
570 /// expression, found by taking this AST node index offset from the containing
571 /// Decl AST node, which points to a function type AST node. Next, navigate to
572 /// the calling convention node.
573 /// The Decl is determined contextually.
574 node_offset_fn_type_addrspace: i32,
575 /// The source location points to the linksection expr of a function type
576 /// expression, found by taking this AST node index offset from the containing
577 /// Decl AST node, which points to a function type AST node. Next, navigate to
578 /// the calling convention node.
579 /// The Decl is determined contextually.
580 node_offset_fn_type_section: i32,
581 /// The source location points to the calling convention of a function type
582 /// expression, found by taking this AST node index offset from the containing
583 /// Decl AST node, which points to a function type AST node. Next, navigate to
584 /// the calling convention node.
585 /// The Decl is determined contextually.
586 node_offset_fn_type_cc: i32,
587 /// The source location points to the return type of a function type
588 /// expression, found by taking this AST node index offset from the containing
589 /// Decl AST node, which points to a function type AST node. Next, navigate to
590 /// the return type node.
591 /// The Decl is determined contextually.
592 node_offset_fn_type_ret_ty: i32,
593 node_offset_param: i32,
594 token_offset_param: i32,
595 /// The source location points to the type expression of an `anyframe->T`
596 /// expression, found by taking this AST node index offset from the containing
597 /// Decl AST node, which points to a `anyframe->T` expression AST node. Next, navigate
598 /// to the type expression.
599 /// The Decl is determined contextually.
600 node_offset_anyframe_type: i32,
601 /// The source location points to the string literal of `extern "foo"`, found
602 /// by taking this AST node index offset from the containing
603 /// Decl AST node, which points to a function prototype or variable declaration
604 /// expression AST node. Next, navigate to the string literal of the `extern "foo"`.
605 /// The Decl is determined contextually.
606 node_offset_lib_name: i32,
607 /// The source location points to the len expression of an `[N:S]T`
608 /// expression, found by taking this AST node index offset from the containing
609 /// Decl AST node, which points to an `[N:S]T` expression AST node. Next, navigate
610 /// to the len expression.
611 /// The Decl is determined contextually.
612 node_offset_array_type_len: i32,
613 /// The source location points to the sentinel expression of an `[N:S]T`
614 /// expression, found by taking this AST node index offset from the containing
615 /// Decl AST node, which points to an `[N:S]T` expression AST node. Next, navigate
616 /// to the sentinel expression.
617 /// The Decl is determined contextually.
618 node_offset_array_type_sentinel: i32,
619 /// The source location points to the elem expression of an `[N:S]T`
620 /// expression, found by taking this AST node index offset from the containing
621 /// Decl AST node, which points to an `[N:S]T` expression AST node. Next, navigate
622 /// to the elem expression.
623 /// The Decl is determined contextually.
624 node_offset_array_type_elem: i32,
625 /// The source location points to the operand of an unary expression.
626 /// The Decl is determined contextually.
627 node_offset_un_op: i32,
628 /// The source location points to the elem type of a pointer.
629 /// The Decl is determined contextually.
630 node_offset_ptr_elem: i32,
631 /// The source location points to the sentinel of a pointer.
632 /// The Decl is determined contextually.
633 node_offset_ptr_sentinel: i32,
634 /// The source location points to the align expr of a pointer.
635 /// The Decl is determined contextually.
636 node_offset_ptr_align: i32,
637 /// The source location points to the addrspace expr of a pointer.
638 /// The Decl is determined contextually.
639 node_offset_ptr_addrspace: i32,
640 /// The source location points to the bit-offset of a pointer.
641 /// The Decl is determined contextually.
642 node_offset_ptr_bitoffset: i32,
643 /// The source location points to the host size of a pointer.
644 /// The Decl is determined contextually.
645 node_offset_ptr_hostsize: i32,
646 /// The source location points to the tag type of an union or an enum.
647 /// The Decl is determined contextually.
648 node_offset_container_tag: i32,
649 /// The source location points to the default value of a field.
650 /// The Decl is determined contextually.
651 node_offset_field_default: i32,
652 /// The source location points to the type of an array or struct initializer.
653 /// The Decl is determined contextually.
654 node_offset_init_ty: i32,
655 /// The source location points to the LHS of an assignment.
656 /// The Decl is determined contextually.
657 node_offset_store_ptr: i32,
658 /// The source location points to the RHS of an assignment.
659 /// The Decl is determined contextually.
660 node_offset_store_operand: i32,
661 /// The source location points to the operand of a `return` statement, or
662 /// the `return` itself if there is no explicit operand.
663 /// The Decl is determined contextually.
664 node_offset_return_operand: i32,
665 /// The source location points to a for loop input.
666 /// The Decl is determined contextually.
667 for_input: struct {
668 /// Points to the for loop AST node.
669 for_node_offset: i32,
670 /// Picks one of the inputs from the condition.
671 input_index: u32,
672 },
673 /// The source location points to one of the captures of a for loop, found
674 /// by taking this AST node index offset from the containing
675 /// Decl AST node, which points to one of the input nodes of a for loop.
676 /// Next, navigate to the corresponding capture.
677 /// The Decl is determined contextually.
678 for_capture_from_input: i32,
679 /// The source location points to the argument node of a function call.
680 call_arg: struct {
681 decl: DeclIndex,
682 /// Points to the function call AST node.
683 call_node_offset: i32,
684 /// The index of the argument the source location points to.
685 arg_index: u32,
686 },
687 fn_proto_param: struct {
688 decl: DeclIndex,
689 /// Points to the function prototype AST node.
690 fn_proto_node_offset: i32,
691 /// The index of the parameter the source location points to.
692 param_index: u32,
693 },
694 array_cat_lhs: ArrayCat,
695 array_cat_rhs: ArrayCat,
696
697 const ArrayCat = struct {
698 /// Points to the array concat AST node.
699 array_cat_offset: i32,
700 /// The index of the element the source location points to.
701 elem_index: u32,
702 };
703
704 pub const nodeOffset = if (TracedOffset.want_tracing) nodeOffsetDebug else nodeOffsetRelease;
705
706 noinline fn nodeOffsetDebug(node_offset: i32) LazySrcLoc {
707 var result: LazySrcLoc = .{ .node_offset = .{ .x = node_offset } };
708 result.node_offset.trace.addAddr(@returnAddress(), "init");
709 return result;
710 }
711
712 fn nodeOffsetRelease(node_offset: i32) LazySrcLoc {
713 return .{ .node_offset = .{ .x = node_offset } };
714 }
715
716 /// This wraps a simple integer in debug builds so that later on we can find out
717 /// where in semantic analysis the value got set.
718 pub const TracedOffset = struct {
719 x: i32,
720 trace: std.debug.Trace = std.debug.Trace.init,
721
722 const want_tracing = false;
723 };
724};
725
726353const std = @import("std.zig");
727354const tokenizer = @import("zig/tokenizer.zig");
728355const assert = std.debug.assert;
lib/std/zig/Zir.zig-61
......@@ -20,7 +20,6 @@ const BigIntMutable = std.math.big.int.Mutable;
2020const Ast = std.zig.Ast;
2121
2222const Zir = @This();
23const LazySrcLoc = std.zig.LazySrcLoc;
2423
2524instructions: std.MultiArrayList(Inst).Slice,
2625/// In order to store references to strings in fewer bytes, we copy all
......@@ -2221,10 +2220,6 @@ pub const Inst = struct {
22212220 src_node: i32,
22222221 /// The meaning of this operand depends on the corresponding `Tag`.
22232222 operand: Ref,
2224
2225 pub fn src(self: @This()) LazySrcLoc {
2226 return LazySrcLoc.nodeOffset(self.src_node);
2227 }
22282223 },
22292224 /// Used for unary operators, with a token source location.
22302225 un_tok: struct {
......@@ -2232,10 +2227,6 @@ pub const Inst = struct {
22322227 src_tok: Ast.TokenIndex,
22332228 /// The meaning of this operand depends on the corresponding `Tag`.
22342229 operand: Ref,
2235
2236 pub fn src(self: @This()) LazySrcLoc {
2237 return .{ .token_offset = self.src_tok };
2238 }
22392230 },
22402231 pl_node: struct {
22412232 /// Offset from Decl AST node index.
......@@ -2244,10 +2235,6 @@ pub const Inst = struct {
22442235 /// index into extra.
22452236 /// `Tag` determines what lives there.
22462237 payload_index: u32,
2247
2248 pub fn src(self: @This()) LazySrcLoc {
2249 return LazySrcLoc.nodeOffset(self.src_node);
2250 }
22512238 },
22522239 pl_tok: struct {
22532240 /// Offset from Decl AST token index.
......@@ -2255,10 +2242,6 @@ pub const Inst = struct {
22552242 /// index into extra.
22562243 /// `Tag` determines what lives there.
22572244 payload_index: u32,
2258
2259 pub fn src(self: @This()) LazySrcLoc {
2260 return .{ .token_offset = self.src_tok };
2261 }
22622245 },
22632246 bin: Bin,
22642247 /// For strings which may contain null bytes.
......@@ -2281,10 +2264,6 @@ pub const Inst = struct {
22812264 pub fn get(self: @This(), code: Zir) [:0]const u8 {
22822265 return code.nullTerminatedString(self.start);
22832266 }
2284
2285 pub fn src(self: @This()) LazySrcLoc {
2286 return .{ .token_offset = self.src_tok };
2287 }
22882267 },
22892268 /// Offset from Decl AST token index.
22902269 tok: Ast.TokenIndex,
......@@ -2313,19 +2292,11 @@ pub const Inst = struct {
23132292 src_node: i32,
23142293 signedness: std.builtin.Signedness,
23152294 bit_count: u16,
2316
2317 pub fn src(self: @This()) LazySrcLoc {
2318 return LazySrcLoc.nodeOffset(self.src_node);
2319 }
23202295 },
23212296 @"unreachable": struct {
23222297 /// Offset from Decl AST node index.
23232298 /// `Tag` determines which kind of AST node this points to.
23242299 src_node: i32,
2325
2326 pub fn src(self: @This()) LazySrcLoc {
2327 return LazySrcLoc.nodeOffset(self.src_node);
2328 }
23292300 },
23302301 @"break": struct {
23312302 operand: Ref,
......@@ -2339,10 +2310,6 @@ pub const Inst = struct {
23392310 src_node: i32,
23402311 /// The meaning of this operand depends on the corresponding `Tag`.
23412312 inst: Index,
2342
2343 pub fn src(self: @This()) LazySrcLoc {
2344 return LazySrcLoc.nodeOffset(self.src_node);
2345 }
23462313 },
23472314 str_op: struct {
23482315 /// Offset into `string_bytes`. Null-terminated.
......@@ -2375,10 +2342,6 @@ pub const Inst = struct {
23752342 src_node: Ast.Node.Index,
23762343 /// index into extra to a `Declaration` payload.
23772344 payload_index: u32,
2378
2379 pub fn src(self: @This()) LazySrcLoc {
2380 return .{ .node_abs = self.src_node };
2381 }
23822345 },
23832346
23842347 // Make sure we don't accidentally add a field to make this union
......@@ -3032,10 +2995,6 @@ pub const Inst = struct {
30322995 /// This node provides a new absolute baseline node for all instructions within this struct.
30332996 src_node: Ast.Node.Index,
30342997
3035 pub fn src(self: StructDecl) LazySrcLoc {
3036 return .{ .node_abs = self.src_node };
3037 }
3038
30392998 pub const Small = packed struct {
30402999 has_captures_len: bool,
30413000 has_fields_len: bool,
......@@ -3165,10 +3124,6 @@ pub const Inst = struct {
31653124 /// This node provides a new absolute baseline node for all instructions within this struct.
31663125 src_node: Ast.Node.Index,
31673126
3168 pub fn src(self: EnumDecl) LazySrcLoc {
3169 return .{ .node_abs = self.src_node };
3170 }
3171
31723127 pub const Small = packed struct {
31733128 has_tag_type: bool,
31743129 has_captures_len: bool,
......@@ -3214,10 +3169,6 @@ pub const Inst = struct {
32143169 /// This node provides a new absolute baseline node for all instructions within this struct.
32153170 src_node: Ast.Node.Index,
32163171
3217 pub fn src(self: UnionDecl) LazySrcLoc {
3218 return .{ .node_abs = self.src_node };
3219 }
3220
32213172 pub const Small = packed struct {
32223173 has_tag_type: bool,
32233174 has_captures_len: bool,
......@@ -3247,10 +3198,6 @@ pub const Inst = struct {
32473198 /// This node provides a new absolute baseline node for all instructions within this struct.
32483199 src_node: Ast.Node.Index,
32493200
3250 pub fn src(self: OpaqueDecl) LazySrcLoc {
3251 return .{ .node_abs = self.src_node };
3252 }
3253
32543201 pub const Small = packed struct {
32553202 has_captures_len: bool,
32563203 has_decls_len: bool,
......@@ -3367,10 +3314,6 @@ pub const Inst = struct {
33673314 parent_ptr_type: Ref,
33683315 field_name: Ref,
33693316 field_ptr: Ref,
3370
3371 pub fn src(self: FieldParentPtr) LazySrcLoc {
3372 return LazySrcLoc.nodeOffset(self.src_node);
3373 }
33743317 };
33753318
33763319 pub const Shuffle = struct {
......@@ -3520,10 +3463,6 @@ pub const Inst = struct {
35203463 block: Ref,
35213464 /// If `.none`, restore unconditionally.
35223465 operand: Ref,
3523
3524 pub fn src(self: RestoreErrRetIndex) LazySrcLoc {
3525 return LazySrcLoc.nodeOffset(self.src_node);
3526 }
35273466 };
35283467};
35293468
src/InternPool.zig+21-2
......@@ -391,8 +391,27 @@ pub const RuntimeIndex = enum(u32) {
391391
392392pub const ComptimeAllocIndex = enum(u32) { _ };
393393
394pub const DeclIndex = std.zig.DeclIndex;
395pub const OptionalDeclIndex = std.zig.OptionalDeclIndex;
394pub const DeclIndex = enum(u32) {
395 _,
396
397 pub fn toOptional(i: DeclIndex) OptionalDeclIndex {
398 return @enumFromInt(@intFromEnum(i));
399 }
400};
401
402pub const OptionalDeclIndex = enum(u32) {
403 none = std.math.maxInt(u32),
404 _,
405
406 pub fn init(oi: ?DeclIndex) OptionalDeclIndex {
407 return @enumFromInt(@intFromEnum(oi orelse return .none));
408 }
409
410 pub fn unwrap(oi: OptionalDeclIndex) ?DeclIndex {
411 if (oi == .none) return null;
412 return @enumFromInt(@intFromEnum(oi));
413 }
414};
396415
397416pub const NamespaceIndex = enum(u32) {
398417 _,
src/Module.zig+351-1
......@@ -13,7 +13,6 @@ const BigIntConst = std.math.big.int.Const;
1313const BigIntMutable = std.math.big.int.Mutable;
1414const Target = std.Target;
1515const Ast = std.zig.Ast;
16const LazySrcLoc = std.zig.LazySrcLoc;
1716
1817/// Deprecated, use `Zcu`.
1918const Module = Zcu;
......@@ -1905,6 +1904,357 @@ pub const SrcLoc = struct {
19051904 }
19061905};
19071906
1907/// Resolving a source location into a byte offset may require doing work
1908/// that we would rather not do unless the error actually occurs.
1909/// Therefore we need a data structure that contains the information necessary
1910/// to lazily produce a `SrcLoc` as required.
1911/// Most of the offsets in this data structure are relative to the containing Decl.
1912/// This makes the source location resolve properly even when a Decl gets
1913/// shifted up or down in the file, as long as the Decl's contents itself
1914/// do not change.
1915pub const LazySrcLoc = union(enum) {
1916 /// When this tag is set, the code that constructed this `LazySrcLoc` is asserting
1917 /// that all code paths which would need to resolve the source location are
1918 /// unreachable. If you are debugging this tag incorrectly being this value,
1919 /// look into using reverse-continue with a memory watchpoint to see where the
1920 /// value is being set to this tag.
1921 unneeded,
1922 /// Means the source location points to an entire file; not any particular
1923 /// location within the file. `file_scope` union field will be active.
1924 entire_file,
1925 /// The source location points to a byte offset within a source file,
1926 /// offset from 0. The source file is determined contextually.
1927 /// Inside a `SrcLoc`, the `file_scope` union field will be active.
1928 byte_abs: u32,
1929 /// The source location points to a token within a source file,
1930 /// offset from 0. The source file is determined contextually.
1931 /// Inside a `SrcLoc`, the `file_scope` union field will be active.
1932 token_abs: u32,
1933 /// The source location points to an AST node within a source file,
1934 /// offset from 0. The source file is determined contextually.
1935 /// Inside a `SrcLoc`, the `file_scope` union field will be active.
1936 node_abs: u32,
1937 /// The source location points to a byte offset within a source file,
1938 /// offset from the byte offset of the Decl within the file.
1939 /// The Decl is determined contextually.
1940 byte_offset: u32,
1941 /// This data is the offset into the token list from the Decl token.
1942 /// The Decl is determined contextually.
1943 token_offset: u32,
1944 /// The source location points to an AST node, which is this value offset
1945 /// from its containing Decl node AST index.
1946 /// The Decl is determined contextually.
1947 node_offset: TracedOffset,
1948 /// The source location points to the main token of an AST node, found
1949 /// by taking this AST node index offset from the containing Decl AST node.
1950 /// The Decl is determined contextually.
1951 node_offset_main_token: i32,
1952 /// The source location points to the beginning of a struct initializer.
1953 /// The Decl is determined contextually.
1954 node_offset_initializer: i32,
1955 /// The source location points to a variable declaration type expression,
1956 /// found by taking this AST node index offset from the containing
1957 /// Decl AST node, which points to a variable declaration AST node. Next, navigate
1958 /// to the type expression.
1959 /// The Decl is determined contextually.
1960 node_offset_var_decl_ty: i32,
1961 /// The source location points to the alignment expression of a var decl.
1962 /// The Decl is determined contextually.
1963 node_offset_var_decl_align: i32,
1964 /// The source location points to the linksection expression of a var decl.
1965 /// The Decl is determined contextually.
1966 node_offset_var_decl_section: i32,
1967 /// The source location points to the addrspace expression of a var decl.
1968 /// The Decl is determined contextually.
1969 node_offset_var_decl_addrspace: i32,
1970 /// The source location points to the initializer of a var decl.
1971 /// The Decl is determined contextually.
1972 node_offset_var_decl_init: i32,
1973 /// The source location points to the first parameter of a builtin
1974 /// function call, found by taking this AST node index offset from the containing
1975 /// Decl AST node, which points to a builtin call AST node. Next, navigate
1976 /// to the first parameter.
1977 /// The Decl is determined contextually.
1978 node_offset_builtin_call_arg0: i32,
1979 /// Same as `node_offset_builtin_call_arg0` except arg index 1.
1980 node_offset_builtin_call_arg1: i32,
1981 node_offset_builtin_call_arg2: i32,
1982 node_offset_builtin_call_arg3: i32,
1983 node_offset_builtin_call_arg4: i32,
1984 node_offset_builtin_call_arg5: i32,
1985 /// Like `node_offset_builtin_call_arg0` but recurses through arbitrarily many calls
1986 /// to pointer cast builtins.
1987 node_offset_ptrcast_operand: i32,
1988 /// The source location points to the index expression of an array access
1989 /// expression, found by taking this AST node index offset from the containing
1990 /// Decl AST node, which points to an array access AST node. Next, navigate
1991 /// to the index expression.
1992 /// The Decl is determined contextually.
1993 node_offset_array_access_index: i32,
1994 /// The source location points to the LHS of a slice expression
1995 /// expression, found by taking this AST node index offset from the containing
1996 /// Decl AST node, which points to a slice AST node. Next, navigate
1997 /// to the sentinel expression.
1998 /// The Decl is determined contextually.
1999 node_offset_slice_ptr: i32,
2000 /// The source location points to start expression of a slice expression
2001 /// expression, found by taking this AST node index offset from the containing
2002 /// Decl AST node, which points to a slice AST node. Next, navigate
2003 /// to the sentinel expression.
2004 /// The Decl is determined contextually.
2005 node_offset_slice_start: i32,
2006 /// The source location points to the end expression of a slice
2007 /// expression, found by taking this AST node index offset from the containing
2008 /// Decl AST node, which points to a slice AST node. Next, navigate
2009 /// to the sentinel expression.
2010 /// The Decl is determined contextually.
2011 node_offset_slice_end: i32,
2012 /// The source location points to the sentinel expression of a slice
2013 /// expression, found by taking this AST node index offset from the containing
2014 /// Decl AST node, which points to a slice AST node. Next, navigate
2015 /// to the sentinel expression.
2016 /// The Decl is determined contextually.
2017 node_offset_slice_sentinel: i32,
2018 /// The source location points to the callee expression of a function
2019 /// call expression, found by taking this AST node index offset from the containing
2020 /// Decl AST node, which points to a function call AST node. Next, navigate
2021 /// to the callee expression.
2022 /// The Decl is determined contextually.
2023 node_offset_call_func: i32,
2024 /// The payload is offset from the containing Decl AST node.
2025 /// The source location points to the field name of:
2026 /// * a field access expression (`a.b`), or
2027 /// * the callee of a method call (`a.b()`)
2028 /// The Decl is determined contextually.
2029 node_offset_field_name: i32,
2030 /// The payload is offset from the containing Decl AST node.
2031 /// The source location points to the field name of the operand ("b" node)
2032 /// of a field initialization expression (`.a = b`)
2033 /// The Decl is determined contextually.
2034 node_offset_field_name_init: i32,
2035 /// The source location points to the pointer of a pointer deref expression,
2036 /// found by taking this AST node index offset from the containing
2037 /// Decl AST node, which points to a pointer deref AST node. Next, navigate
2038 /// to the pointer expression.
2039 /// The Decl is determined contextually.
2040 node_offset_deref_ptr: i32,
2041 /// The source location points to the assembly source code of an inline assembly
2042 /// expression, found by taking this AST node index offset from the containing
2043 /// Decl AST node, which points to inline assembly AST node. Next, navigate
2044 /// to the asm template source code.
2045 /// The Decl is determined contextually.
2046 node_offset_asm_source: i32,
2047 /// The source location points to the return type of an inline assembly
2048 /// expression, found by taking this AST node index offset from the containing
2049 /// Decl AST node, which points to inline assembly AST node. Next, navigate
2050 /// to the return type expression.
2051 /// The Decl is determined contextually.
2052 node_offset_asm_ret_ty: i32,
2053 /// The source location points to the condition expression of an if
2054 /// expression, found by taking this AST node index offset from the containing
2055 /// Decl AST node, which points to an if expression AST node. Next, navigate
2056 /// to the condition expression.
2057 /// The Decl is determined contextually.
2058 node_offset_if_cond: i32,
2059 /// The source location points to a binary expression, such as `a + b`, found
2060 /// by taking this AST node index offset from the containing Decl AST node.
2061 /// The Decl is determined contextually.
2062 node_offset_bin_op: i32,
2063 /// The source location points to the LHS of a binary expression, found
2064 /// by taking this AST node index offset from the containing Decl AST node,
2065 /// which points to a binary expression AST node. Next, navigate to the LHS.
2066 /// The Decl is determined contextually.
2067 node_offset_bin_lhs: i32,
2068 /// The source location points to the RHS of a binary expression, found
2069 /// by taking this AST node index offset from the containing Decl AST node,
2070 /// which points to a binary expression AST node. Next, navigate to the RHS.
2071 /// The Decl is determined contextually.
2072 node_offset_bin_rhs: i32,
2073 /// The source location points to the operand of a switch expression, found
2074 /// by taking this AST node index offset from the containing Decl AST node,
2075 /// which points to a switch expression AST node. Next, navigate to the operand.
2076 /// The Decl is determined contextually.
2077 node_offset_switch_operand: i32,
2078 /// The source location points to the else/`_` prong of a switch expression, found
2079 /// by taking this AST node index offset from the containing Decl AST node,
2080 /// which points to a switch expression AST node. Next, navigate to the else/`_` prong.
2081 /// The Decl is determined contextually.
2082 node_offset_switch_special_prong: i32,
2083 /// The source location points to all the ranges of a switch expression, found
2084 /// by taking this AST node index offset from the containing Decl AST node,
2085 /// which points to a switch expression AST node. Next, navigate to any of the
2086 /// range nodes. The error applies to all of them.
2087 /// The Decl is determined contextually.
2088 node_offset_switch_range: i32,
2089 /// The source location points to the capture of a switch_prong.
2090 /// The Decl is determined contextually.
2091 node_offset_switch_prong_capture: i32,
2092 /// The source location points to the tag capture of a switch_prong.
2093 /// The Decl is determined contextually.
2094 node_offset_switch_prong_tag_capture: i32,
2095 /// The source location points to the align expr of a function type
2096 /// expression, found by taking this AST node index offset from the containing
2097 /// Decl AST node, which points to a function type AST node. Next, navigate to
2098 /// the calling convention node.
2099 /// The Decl is determined contextually.
2100 node_offset_fn_type_align: i32,
2101 /// The source location points to the addrspace expr of a function type
2102 /// expression, found by taking this AST node index offset from the containing
2103 /// Decl AST node, which points to a function type AST node. Next, navigate to
2104 /// the calling convention node.
2105 /// The Decl is determined contextually.
2106 node_offset_fn_type_addrspace: i32,
2107 /// The source location points to the linksection expr of a function type
2108 /// expression, found by taking this AST node index offset from the containing
2109 /// Decl AST node, which points to a function type AST node. Next, navigate to
2110 /// the calling convention node.
2111 /// The Decl is determined contextually.
2112 node_offset_fn_type_section: i32,
2113 /// The source location points to the calling convention of a function type
2114 /// expression, found by taking this AST node index offset from the containing
2115 /// Decl AST node, which points to a function type AST node. Next, navigate to
2116 /// the calling convention node.
2117 /// The Decl is determined contextually.
2118 node_offset_fn_type_cc: i32,
2119 /// The source location points to the return type of a function type
2120 /// expression, found by taking this AST node index offset from the containing
2121 /// Decl AST node, which points to a function type AST node. Next, navigate to
2122 /// the return type node.
2123 /// The Decl is determined contextually.
2124 node_offset_fn_type_ret_ty: i32,
2125 node_offset_param: i32,
2126 token_offset_param: i32,
2127 /// The source location points to the type expression of an `anyframe->T`
2128 /// expression, found by taking this AST node index offset from the containing
2129 /// Decl AST node, which points to a `anyframe->T` expression AST node. Next, navigate
2130 /// to the type expression.
2131 /// The Decl is determined contextually.
2132 node_offset_anyframe_type: i32,
2133 /// The source location points to the string literal of `extern "foo"`, found
2134 /// by taking this AST node index offset from the containing
2135 /// Decl AST node, which points to a function prototype or variable declaration
2136 /// expression AST node. Next, navigate to the string literal of the `extern "foo"`.
2137 /// The Decl is determined contextually.
2138 node_offset_lib_name: i32,
2139 /// The source location points to the len expression of an `[N:S]T`
2140 /// expression, found by taking this AST node index offset from the containing
2141 /// Decl AST node, which points to an `[N:S]T` expression AST node. Next, navigate
2142 /// to the len expression.
2143 /// The Decl is determined contextually.
2144 node_offset_array_type_len: i32,
2145 /// The source location points to the sentinel expression of an `[N:S]T`
2146 /// expression, found by taking this AST node index offset from the containing
2147 /// Decl AST node, which points to an `[N:S]T` expression AST node. Next, navigate
2148 /// to the sentinel expression.
2149 /// The Decl is determined contextually.
2150 node_offset_array_type_sentinel: i32,
2151 /// The source location points to the elem expression of an `[N:S]T`
2152 /// expression, found by taking this AST node index offset from the containing
2153 /// Decl AST node, which points to an `[N:S]T` expression AST node. Next, navigate
2154 /// to the elem expression.
2155 /// The Decl is determined contextually.
2156 node_offset_array_type_elem: i32,
2157 /// The source location points to the operand of an unary expression.
2158 /// The Decl is determined contextually.
2159 node_offset_un_op: i32,
2160 /// The source location points to the elem type of a pointer.
2161 /// The Decl is determined contextually.
2162 node_offset_ptr_elem: i32,
2163 /// The source location points to the sentinel of a pointer.
2164 /// The Decl is determined contextually.
2165 node_offset_ptr_sentinel: i32,
2166 /// The source location points to the align expr of a pointer.
2167 /// The Decl is determined contextually.
2168 node_offset_ptr_align: i32,
2169 /// The source location points to the addrspace expr of a pointer.
2170 /// The Decl is determined contextually.
2171 node_offset_ptr_addrspace: i32,
2172 /// The source location points to the bit-offset of a pointer.
2173 /// The Decl is determined contextually.
2174 node_offset_ptr_bitoffset: i32,
2175 /// The source location points to the host size of a pointer.
2176 /// The Decl is determined contextually.
2177 node_offset_ptr_hostsize: i32,
2178 /// The source location points to the tag type of an union or an enum.
2179 /// The Decl is determined contextually.
2180 node_offset_container_tag: i32,
2181 /// The source location points to the default value of a field.
2182 /// The Decl is determined contextually.
2183 node_offset_field_default: i32,
2184 /// The source location points to the type of an array or struct initializer.
2185 /// The Decl is determined contextually.
2186 node_offset_init_ty: i32,
2187 /// The source location points to the LHS of an assignment.
2188 /// The Decl is determined contextually.
2189 node_offset_store_ptr: i32,
2190 /// The source location points to the RHS of an assignment.
2191 /// The Decl is determined contextually.
2192 node_offset_store_operand: i32,
2193 /// The source location points to the operand of a `return` statement, or
2194 /// the `return` itself if there is no explicit operand.
2195 /// The Decl is determined contextually.
2196 node_offset_return_operand: i32,
2197 /// The source location points to a for loop input.
2198 /// The Decl is determined contextually.
2199 for_input: struct {
2200 /// Points to the for loop AST node.
2201 for_node_offset: i32,
2202 /// Picks one of the inputs from the condition.
2203 input_index: u32,
2204 },
2205 /// The source location points to one of the captures of a for loop, found
2206 /// by taking this AST node index offset from the containing
2207 /// Decl AST node, which points to one of the input nodes of a for loop.
2208 /// Next, navigate to the corresponding capture.
2209 /// The Decl is determined contextually.
2210 for_capture_from_input: i32,
2211 /// The source location points to the argument node of a function call.
2212 call_arg: struct {
2213 decl: Decl.Index,
2214 /// Points to the function call AST node.
2215 call_node_offset: i32,
2216 /// The index of the argument the source location points to.
2217 arg_index: u32,
2218 },
2219 fn_proto_param: struct {
2220 decl: Decl.Index,
2221 /// Points to the function prototype AST node.
2222 fn_proto_node_offset: i32,
2223 /// The index of the parameter the source location points to.
2224 param_index: u32,
2225 },
2226 array_cat_lhs: ArrayCat,
2227 array_cat_rhs: ArrayCat,
2228
2229 const ArrayCat = struct {
2230 /// Points to the array concat AST node.
2231 array_cat_offset: i32,
2232 /// The index of the element the source location points to.
2233 elem_index: u32,
2234 };
2235
2236 pub const nodeOffset = if (TracedOffset.want_tracing) nodeOffsetDebug else nodeOffsetRelease;
2237
2238 noinline fn nodeOffsetDebug(node_offset: i32) LazySrcLoc {
2239 var result: LazySrcLoc = .{ .node_offset = .{ .x = node_offset } };
2240 result.node_offset.trace.addAddr(@returnAddress(), "init");
2241 return result;
2242 }
2243
2244 fn nodeOffsetRelease(node_offset: i32) LazySrcLoc {
2245 return .{ .node_offset = .{ .x = node_offset } };
2246 }
2247
2248 /// This wraps a simple integer in debug builds so that later on we can find out
2249 /// where in semantic analysis the value got set.
2250 pub const TracedOffset = struct {
2251 x: i32,
2252 trace: std.debug.Trace = std.debug.Trace.init,
2253
2254 const want_tracing = false;
2255 };
2256};
2257
19082258pub const SemaError = error{ OutOfMemory, AnalysisFail };
19092259pub const CompileError = error{
19102260 OutOfMemory,
src/Sema.zig+183-165
......@@ -182,7 +182,7 @@ const Namespace = Module.Namespace;
182182const CompileError = Module.CompileError;
183183const SemaError = Module.SemaError;
184184const Decl = Module.Decl;
185const LazySrcLoc = std.zig.LazySrcLoc;
185const LazySrcLoc = Zcu.LazySrcLoc;
186186const RangeSet = @import("RangeSet.zig");
187187const target_util = @import("target.zig");
188188const Package = @import("Package.zig");
......@@ -395,6 +395,18 @@ pub const Block = struct {
395395 /// `block` in order for codegen to match lexical scoping for debug vars.
396396 need_debug_scope: ?*bool = null,
397397
398 // These functions will be less stupid soon!
399
400 fn nodeOffset(block: Block, node_offset: i32) LazySrcLoc {
401 _ = block;
402 return LazySrcLoc.nodeOffset(node_offset);
403 }
404
405 fn tokenOffset(block: Block, tok_offset: u32) LazySrcLoc {
406 _ = block;
407 return .{ .token_offset = tok_offset };
408 }
409
398410 const ComptimeReason = union(enum) {
399411 c_import: struct {
400412 block: *Block,
......@@ -1449,7 +1461,7 @@ fn analyzeBodyInner(
14491461 .check_comptime_control_flow => {
14501462 if (!block.is_comptime) {
14511463 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1452 const src = inst_data.src();
1464 const src = block.nodeOffset(inst_data.src_node);
14531465 const inline_block = inst_data.operand.toIndex().?;
14541466
14551467 var check_block = block;
......@@ -1482,13 +1494,13 @@ fn analyzeBodyInner(
14821494 },
14831495 .restore_err_ret_index_unconditional => {
14841496 const un_node = datas[@intFromEnum(inst)].un_node;
1485 try sema.restoreErrRetIndex(block, un_node.src(), un_node.operand, .none);
1497 try sema.restoreErrRetIndex(block, block.nodeOffset(un_node.src_node), un_node.operand, .none);
14861498 i += 1;
14871499 continue;
14881500 },
14891501 .restore_err_ret_index_fn_entry => {
14901502 const un_node = datas[@intFromEnum(inst)].un_node;
1491 try sema.restoreErrRetIndex(block, un_node.src(), .none, un_node.operand);
1503 try sema.restoreErrRetIndex(block, block.nodeOffset(un_node.src_node), .none, un_node.operand);
14921504 i += 1;
14931505 continue;
14941506 },
......@@ -1667,7 +1679,7 @@ fn analyzeBodyInner(
16671679 try labeled_block.block.instructions.appendSlice(gpa, block.instructions.items[block_index..]);
16681680 block.instructions.items.len = block_index;
16691681
1670 const block_result = try sema.resolveAnalyzedBlock(block, inst_data.src(), &labeled_block.block, &labeled_block.label.merges, need_debug_scope);
1682 const block_result = try sema.resolveAnalyzedBlock(block, block.nodeOffset(inst_data.src_node), &labeled_block.block, &labeled_block.label.merges, need_debug_scope);
16711683 {
16721684 // Destroy the ad-hoc block entry so that it does not interfere with
16731685 // the next iteration of comptime control flow, if any.
......@@ -1736,7 +1748,7 @@ fn analyzeBodyInner(
17361748 .@"try" => blk: {
17371749 if (!block.is_comptime) break :blk try sema.zirTry(block, inst);
17381750 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
1739 const src = inst_data.src();
1751 const src = block.nodeOffset(inst_data.src_node);
17401752 const operand_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
17411753 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);
17421754 const inline_body = sema.code.bodySlice(extra.end, extra.data.body_len);
......@@ -1762,7 +1774,7 @@ fn analyzeBodyInner(
17621774 .try_ptr => blk: {
17631775 if (!block.is_comptime) break :blk try sema.zirTryPtr(block, inst);
17641776 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
1765 const src = inst_data.src();
1777 const src = block.nodeOffset(inst_data.src_node);
17661778 const operand_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
17671779 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);
17681780 const inline_body = sema.code.bodySlice(extra.end, extra.data.body_len);
......@@ -1929,7 +1941,7 @@ fn resolveDestType(
19291941 const msg = msg: {
19301942 const msg = try sema.errMsg(block, src, "{s} must have a known result type", .{builtin_name});
19311943 errdefer msg.destroy(sema.gpa);
1932 switch (sema.genericPoisonReason(zir_ref)) {
1944 switch (sema.genericPoisonReason(block, zir_ref)) {
19331945 .anytype_param => |call_src| try sema.errNote(block, call_src, msg, "result type is unknown due to anytype parameter", .{}),
19341946 .anyopaque_ptr => |ptr_src| try sema.errNote(block, ptr_src, msg, "result type is unknown due to opaque pointer type", .{}),
19351947 .unknown => {},
......@@ -1963,7 +1975,7 @@ const GenericPoisonReason = union(enum) {
19631975
19641976/// Backtracks through ZIR instructions to determine the reason a generic poison
19651977/// type was created. Used for error reporting.
1966fn genericPoisonReason(sema: *Sema, ref: Zir.Inst.Ref) GenericPoisonReason {
1978fn genericPoisonReason(sema: *Sema, block: *Block, ref: Zir.Inst.Ref) GenericPoisonReason {
19671979 var cur = ref;
19681980 while (true) {
19691981 const inst = cur.toIndex() orelse return .unknown;
......@@ -1999,7 +2011,7 @@ fn genericPoisonReason(sema: *Sema, ref: Zir.Inst.Ref) GenericPoisonReason {
19992011 cur = un_node.operand;
20002012 } else {
20012013 // This must be an anyopaque pointer!
2002 return .{ .anyopaque_ptr = un_node.src() };
2014 return .{ .anyopaque_ptr = block.nodeOffset(un_node.src_node) };
20032015 }
20042016 },
20052017 .call, .field_call => {
......@@ -2007,7 +2019,7 @@ fn genericPoisonReason(sema: *Sema, ref: Zir.Inst.Ref) GenericPoisonReason {
20072019 // evaluating an `anytype` function parameter.
20082020 // TODO: better source location - function decl rather than call
20092021 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
2010 return .{ .anytype_param = pl_node.src() };
2022 return .{ .anytype_param = block.nodeOffset(pl_node.src_node) };
20112023 },
20122024 else => return .unknown,
20132025 }
......@@ -2776,7 +2788,7 @@ fn zirStructDecl(
27762788 const ip = &mod.intern_pool;
27772789 const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small);
27782790 const extra = sema.code.extraData(Zir.Inst.StructDecl, extended.operand);
2779 const src = extra.data.src();
2791 const src: LazySrcLoc = .{ .node_abs = extra.data.src_node };
27802792 var extra_index = extra.end;
27812793
27822794 const captures_len = if (small.has_captures_len) blk: {
......@@ -2991,7 +3003,7 @@ fn zirEnumDecl(
29913003 const extra = sema.code.extraData(Zir.Inst.EnumDecl, extended.operand);
29923004 var extra_index: usize = extra.end;
29933005
2994 const src = extra.data.src();
3006 const src: LazySrcLoc = .{ .node_abs = extra.data.src_node };
29953007
29963008 const tag_type_ref = if (small.has_tag_type) blk: {
29973009 const tag_type_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
......@@ -3282,7 +3294,7 @@ fn zirUnionDecl(
32823294 const extra = sema.code.extraData(Zir.Inst.UnionDecl, extended.operand);
32833295 var extra_index: usize = extra.end;
32843296
3285 const src = extra.data.src();
3297 const src: LazySrcLoc = .{ .node_abs = extra.data.src_node };
32863298
32873299 extra_index += @intFromBool(small.has_tag_type);
32883300 const captures_len = if (small.has_captures_len) blk: {
......@@ -3397,7 +3409,7 @@ fn zirOpaqueDecl(
33973409 const extra = sema.code.extraData(Zir.Inst.OpaqueDecl, extended.operand);
33983410 var extra_index: usize = extra.end;
33993411
3400 const src = extra.data.src();
3412 const src: LazySrcLoc = .{ .node_abs = extra.data.src_node };
34013413
34023414 const captures_len = if (small.has_captures_len) blk: {
34033415 const captures_len = sema.code.extra[extra_index];
......@@ -3528,7 +3540,7 @@ fn zirRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
35283540
35293541 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok;
35303542 const operand = try sema.resolveInst(inst_data.operand);
3531 return sema.analyzeRef(block, inst_data.src(), operand);
3543 return sema.analyzeRef(block, block.tokenOffset(inst_data.src_tok), operand);
35323544}
35333545
35343546fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
......@@ -3537,7 +3549,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile
35373549
35383550 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
35393551 const operand = try sema.resolveInst(inst_data.operand);
3540 const src = inst_data.src();
3552 const src = block.nodeOffset(inst_data.src_node);
35413553
35423554 return sema.ensureResultUsed(block, sema.typeOf(operand), src);
35433555}
......@@ -3581,7 +3593,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
35813593 const mod = sema.mod;
35823594 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
35833595 const operand = try sema.resolveInst(inst_data.operand);
3584 const src = inst_data.src();
3596 const src = block.nodeOffset(inst_data.src_node);
35853597 const operand_ty = sema.typeOf(operand);
35863598 switch (operand_ty.zigTypeTag(mod)) {
35873599 .ErrorSet => return sema.fail(block, src, "error set is discarded", .{}),
......@@ -3604,7 +3616,7 @@ fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index
36043616
36053617 const mod = sema.mod;
36063618 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
3607 const src = inst_data.src();
3619 const src = block.nodeOffset(inst_data.src_node);
36083620 const operand = try sema.resolveInst(inst_data.operand);
36093621 const operand_ty = sema.typeOf(operand);
36103622 const err_union_ty = if (operand_ty.zigTypeTag(mod) == .Pointer)
......@@ -3629,7 +3641,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
36293641 defer tracy.end();
36303642
36313643 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
3632 const src = inst_data.src();
3644 const src = block.nodeOffset(inst_data.src_node);
36333645 const object = try sema.resolveInst(inst_data.operand);
36343646
36353647 return indexablePtrLen(sema, block, src, object);
......@@ -4223,7 +4235,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
42234235 const mod = sema.mod;
42244236 const gpa = sema.gpa;
42254237 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
4226 const src = inst_data.src();
4238 const src = block.nodeOffset(inst_data.src_node);
42274239 const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node };
42284240 const ptr = try sema.resolveInst(inst_data.operand);
42294241 const ptr_inst = ptr.toIndex().?;
......@@ -4364,7 +4376,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
43644376 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
43654377 const extra = sema.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index);
43664378 const args = sema.code.refSlice(extra.end, extra.data.operands_len);
4367 const src = inst_data.src();
4379 const src = block.nodeOffset(inst_data.src_node);
43684380
43694381 var len: Air.Inst.Ref = .none;
43704382 var len_val: ?Value = null;
......@@ -4507,13 +4519,13 @@ fn optEuBasePtrInit(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, src: LazySrcL
45074519fn zirOptEuBasePtrInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
45084520 const un_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
45094521 const ptr = try sema.resolveInst(un_node.operand);
4510 return sema.optEuBasePtrInit(block, ptr, un_node.src());
4522 return sema.optEuBasePtrInit(block, ptr, block.nodeOffset(un_node.src_node));
45114523}
45124524
45134525fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
45144526 const mod = sema.mod;
45154527 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
4516 const src = pl_node.src();
4528 const src = block.nodeOffset(pl_node.src_node);
45174529 const extra = sema.code.extraData(Zir.Inst.Bin, pl_node.payload_index).data;
45184530 const uncoerced_val = try sema.resolveInst(extra.rhs);
45194531 const maybe_wrapped_ptr_ty = sema.resolveType(block, .unneeded, extra.lhs) catch |err| switch (err) {
......@@ -4564,7 +4576,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
45644576fn zirValidateRefTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
45654577 const mod = sema.mod;
45664578 const un_tok = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok;
4567 const src = un_tok.src();
4579 const src = block.tokenOffset(un_tok.src_tok);
45684580 // In case of GenericPoison, we don't actually have a type, so this will be
45694581 // treated as an untyped address-of operator.
45704582 const operand_air_inst = sema.resolveInst(un_tok.operand) catch |err| switch (err) {
......@@ -4593,7 +4605,7 @@ fn zirValidateArrayInitRefTy(
45934605) CompileError!Air.Inst.Ref {
45944606 const mod = sema.mod;
45954607 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
4596 const src = pl_node.src();
4608 const src = block.nodeOffset(pl_node.src_node);
45974609 const extra = sema.code.extraData(Zir.Inst.ArrayInitRefTy, pl_node.payload_index).data;
45984610 const maybe_wrapped_ptr_ty = sema.resolveType(block, .unneeded, extra.ptr_ty) catch |err| switch (err) {
45994611 error.GenericPoison => return .generic_poison_type,
......@@ -4635,7 +4647,7 @@ fn zirValidateArrayInitTy(
46354647) CompileError!void {
46364648 const mod = sema.mod;
46374649 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
4638 const src = inst_data.src();
4650 const src = block.nodeOffset(inst_data.src_node);
46394651 const ty_src: LazySrcLoc = if (is_result_ty) src else .{ .node_offset_init_ty = inst_data.src_node };
46404652 const extra = sema.code.extraData(Zir.Inst.ArrayInit, inst_data.payload_index).data;
46414653 const ty = sema.resolveType(block, ty_src, extra.ty) catch |err| switch (err) {
......@@ -4698,7 +4710,7 @@ fn zirValidateStructInitTy(
46984710) CompileError!void {
46994711 const mod = sema.mod;
47004712 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
4701 const src = inst_data.src();
4713 const src = block.nodeOffset(inst_data.src_node);
47024714 const ty = sema.resolveType(block, src, inst_data.operand) catch |err| switch (err) {
47034715 // It's okay for the type to be unknown: this will result in an anonymous struct init.
47044716 error.GenericPoison => return,
......@@ -4723,7 +4735,7 @@ fn zirValidatePtrStructInit(
47234735
47244736 const mod = sema.mod;
47254737 const validate_inst = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
4726 const init_src = validate_inst.src();
4738 const init_src = block.nodeOffset(validate_inst.src_node);
47274739 const validate_extra = sema.code.extraData(Zir.Inst.Block, validate_inst.payload_index);
47284740 const instrs = sema.code.bodySlice(validate_extra.end, validate_extra.data.body_len);
47294741 const field_ptr_data = sema.code.instructions.items(.data)[@intFromEnum(instrs[0])].pl_node;
......@@ -4898,11 +4910,11 @@ fn validateUnionInit(
48984910 try sema.storePtr2(block, init_src, union_ptr, init_src, union_init, init_src, .store);
48994911 return;
49004912 } else if (try sema.typeRequiresComptime(union_ty)) {
4901 return sema.failWithNeededComptime(block, field_ptr_data.src(), .{
4913 return sema.failWithNeededComptime(block, block.nodeOffset(field_ptr_data.src_node), .{
49024914 .needed_comptime_reason = "initializer of comptime only union must be comptime-known",
49034915 });
49044916 }
4905 if (init_ref) |v| try sema.validateRuntimeValue(block, field_ptr_data.src(), v);
4917 if (init_ref) |v| try sema.validateRuntimeValue(block, block.nodeOffset(field_ptr_data.src_node), v);
49064918
49074919 const new_tag = Air.internedToRef(tag_val.toIntern());
49084920 const set_tag_inst = try block.addBinOp(.set_union_tag, union_ptr, new_tag);
......@@ -5089,7 +5101,7 @@ fn validateStructInit(
50895101 field_values[i] = val.toIntern();
50905102 } else if (require_comptime) {
50915103 const field_ptr_data = sema.code.instructions.items(.data)[@intFromEnum(field_ptr)].pl_node;
5092 return sema.failWithNeededComptime(block, field_ptr_data.src(), .{
5104 return sema.failWithNeededComptime(block, block.nodeOffset(field_ptr_data.src_node), .{
50935105 .needed_comptime_reason = "initializer of comptime only struct must be comptime-known",
50945106 });
50955107 } else {
......@@ -5213,7 +5225,7 @@ fn zirValidatePtrArrayInit(
52135225) CompileError!void {
52145226 const mod = sema.mod;
52155227 const validate_inst = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
5216 const init_src = validate_inst.src();
5228 const init_src = block.nodeOffset(validate_inst.src_node);
52175229 const validate_extra = sema.code.extraData(Zir.Inst.Block, validate_inst.payload_index);
52185230 const instrs = sema.code.bodySlice(validate_extra.end, validate_extra.data.body_len);
52195231 const first_elem_ptr_data = sema.code.instructions.items(.data)[@intFromEnum(instrs[0])].pl_node;
......@@ -5418,7 +5430,7 @@ fn zirValidatePtrArrayInit(
54185430fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
54195431 const mod = sema.mod;
54205432 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
5421 const src = inst_data.src();
5433 const src = block.nodeOffset(inst_data.src_node);
54225434 const operand = try sema.resolveInst(inst_data.operand);
54235435 const operand_ty = sema.typeOf(operand);
54245436
......@@ -5462,7 +5474,7 @@ fn zirValidateDestructure(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
54625474 const mod = sema.mod;
54635475 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
54645476 const extra = sema.code.extraData(Zir.Inst.ValidateDestructure, inst_data.payload_index).data;
5465 const src = inst_data.src();
5477 const src = block.nodeOffset(inst_data.src_node);
54665478 const destructure_src = LazySrcLoc.nodeOffset(extra.destructure_node);
54675479 const operand = try sema.resolveInst(extra.operand);
54685480 const operand_ty = sema.typeOf(operand);
......@@ -5593,7 +5605,7 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi
55935605 defer tracy.end();
55945606
55955607 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
5596 const src = pl_node.src();
5608 const src = block.nodeOffset(pl_node.src_node);
55975609 const bin = sema.code.extraData(Zir.Inst.Bin, pl_node.payload_index).data;
55985610 const ptr = try sema.resolveInst(bin.lhs);
55995611 const operand = try sema.resolveInst(bin.rhs);
......@@ -5675,7 +5687,7 @@ fn storeToInferredAllocComptime(
56755687
56765688fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
56775689 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
5678 const src = inst_data.src();
5690 const src = block.nodeOffset(inst_data.src_node);
56795691 const quota: u32 = @intCast(try sema.resolveInt(block, src, inst_data.operand, Type.u32, .{
56805692 .needed_comptime_reason = "eval branch quota must be comptime-known",
56815693 }));
......@@ -5690,7 +5702,7 @@ fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!v
56905702 const zir_tags = sema.code.instructions.items(.tag);
56915703 const zir_datas = sema.code.instructions.items(.data);
56925704 const inst_data = zir_datas[@intFromEnum(inst)].pl_node;
5693 const src = inst_data.src();
5705 const src = block.nodeOffset(inst_data.src_node);
56945706 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
56955707 const ptr = try sema.resolveInst(extra.lhs);
56965708 const operand = try sema.resolveInst(extra.rhs);
......@@ -5824,7 +5836,7 @@ fn zirCompileError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
58245836 defer tracy.end();
58255837
58265838 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
5827 const src = inst_data.src();
5839 const src = block.nodeOffset(inst_data.src_node);
58285840 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
58295841 const msg = try sema.resolveConstString(block, operand_src, inst_data.operand, .{
58305842 .needed_comptime_reason = "compile error string must be comptime-known",
......@@ -5874,7 +5886,7 @@ fn zirCompileLog(
58745886
58755887fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
58765888 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
5877 const src = inst_data.src();
5889 const src = block.nodeOffset(inst_data.src_node);
58785890 const msg_inst = try sema.resolveInst(inst_data.operand);
58795891
58805892 // `panicWithMsg` would perform this coercion for us, but we can get a better
......@@ -5901,7 +5913,7 @@ fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError
59015913
59025914 const mod = sema.mod;
59035915 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
5904 const src = inst_data.src();
5916 const src = parent_block.nodeOffset(inst_data.src_node);
59055917 const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index);
59065918 const body = sema.code.bodySlice(extra.end, extra.data.body_len);
59075919 const gpa = sema.gpa;
......@@ -5974,7 +5986,7 @@ fn zirCImport(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileEr
59745986 const comp = mod.comp;
59755987 const gpa = sema.gpa;
59765988 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
5977 const src = pl_node.src();
5989 const src = parent_block.nodeOffset(pl_node.src_node);
59785990 const extra = sema.code.extraData(Zir.Inst.Block, pl_node.payload_index);
59795991 const body = sema.code.bodySlice(extra.end, extra.data.body_len);
59805992
......@@ -6076,7 +6088,7 @@ fn zirCImport(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileEr
60766088
60776089fn zirSuspendBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
60786090 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
6079 const src = inst_data.src();
6091 const src = parent_block.nodeOffset(inst_data.src_node);
60806092 return sema.failWithUseOfAsync(parent_block, src);
60816093}
60826094
......@@ -6085,7 +6097,7 @@ fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index, force_compt
60856097 defer tracy.end();
60866098
60876099 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
6088 const src = pl_node.src();
6100 const src = parent_block.nodeOffset(pl_node.src_node);
60896101 const extra = sema.code.extraData(Zir.Inst.Block, pl_node.payload_index);
60906102 const body = sema.code.bodySlice(extra.end, extra.data.body_len);
60916103 const gpa = sema.gpa;
......@@ -6420,7 +6432,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
64206432 const mod = sema.mod;
64216433 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
64226434 const extra = sema.code.extraData(Zir.Inst.Export, inst_data.payload_index).data;
6423 const src = inst_data.src();
6435 const src = block.nodeOffset(inst_data.src_node);
64246436 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
64256437 const options_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
64266438 const decl_name = try mod.intern_pool.getOrPutString(
......@@ -6460,7 +6472,7 @@ fn zirExportValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
64606472 const mod = sema.mod;
64616473 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
64626474 const extra = sema.code.extraData(Zir.Inst.ExportValue, inst_data.payload_index).data;
6463 const src = inst_data.src();
6475 const src = block.nodeOffset(inst_data.src_node);
64646476 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
64656477 const options_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
64666478 const operand = try sema.resolveInstConst(block, operand_src, extra.operand, .{
......@@ -6777,7 +6789,7 @@ fn addDbgVar(
67776789fn zirDeclRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
67786790 const mod = sema.mod;
67796791 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_tok;
6780 const src = inst_data.src();
6792 const src = block.tokenOffset(inst_data.src_tok);
67816793 const decl_name = try mod.intern_pool.getOrPutString(
67826794 sema.gpa,
67836795 inst_data.get(sema.code),
......@@ -6791,7 +6803,7 @@ fn zirDeclRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
67916803fn zirDeclVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
67926804 const mod = sema.mod;
67936805 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_tok;
6794 const src = inst_data.src();
6806 const src = block.tokenOffset(inst_data.src_tok);
67956807 const decl_name = try mod.intern_pool.getOrPutString(
67966808 sema.gpa,
67976809 inst_data.get(sema.code),
......@@ -7059,7 +7071,7 @@ fn zirCall(
70597071 const mod = sema.mod;
70607072 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
70617073 const callee_src: LazySrcLoc = .{ .node_offset_call_func = inst_data.src_node };
7062 const call_src = inst_data.src();
7074 const call_src = block.nodeOffset(inst_data.src_node);
70637075 const ExtraType = switch (kind) {
70647076 .direct => Zir.Inst.Call,
70657077 .field => Zir.Inst.FieldCall,
......@@ -8084,7 +8096,7 @@ fn analyzeInlineCallArg(
80848096 // Evaluate the parameter type expression now that previous ones have
80858097 // been mapped, and coerce the corresponding argument to it.
80868098 const pl_tok = ics.callee().code.instructions.items(.data)[@intFromEnum(inst)].pl_tok;
8087 const param_src = pl_tok.src();
8099 const param_src = param_block.tokenOffset(pl_tok.src_tok);
80888100 const extra = ics.callee().code.extraData(Zir.Inst.Param, pl_tok.payload_index);
80898101 const param_body = ics.callee().code.bodySlice(extra.end, extra.data.body_len);
80908102 const param_ty = param_ty: {
......@@ -8324,7 +8336,11 @@ fn instantiateGenericCall(
83248336 }
83258337
83268338 const param_ty_inst = try child_sema.resolveInlineBody(&child_block, param_ty_body, param_inst);
8327 break :param_ty try child_sema.analyzeAsType(&child_block, param_data.src(), param_ty_inst);
8339 break :param_ty try child_sema.analyzeAsType(
8340 &child_block,
8341 child_block.tokenOffset(param_data.src_tok),
8342 param_ty_inst,
8343 );
83288344 },
83298345 else => unreachable,
83308346 }
......@@ -8358,11 +8374,11 @@ fn instantiateGenericCall(
83588374 const arg_src = args_info.argSrc(block, arg_index);
83598375 const msg = try sema.errMsg(block, arg_src, "runtime-known argument passed to comptime parameter", .{});
83608376 errdefer msg.destroy(sema.gpa);
8361 const param_src = switch (param_tag) {
8362 .param_comptime => fn_zir.instructions.items(.data)[@intFromEnum(param_inst)].pl_tok.src(),
8363 .param_anytype_comptime => fn_zir.instructions.items(.data)[@intFromEnum(param_inst)].str_tok.src(),
8377 const param_src = child_block.tokenOffset(switch (param_tag) {
8378 .param_comptime => fn_zir.instructions.items(.data)[@intFromEnum(param_inst)].pl_tok.src_tok,
8379 .param_anytype_comptime => fn_zir.instructions.items(.data)[@intFromEnum(param_inst)].str_tok.src_tok,
83648380 else => unreachable,
8365 };
8381 });
83668382 try child_sema.errNote(&child_block, param_src, msg, "declared comptime here", .{});
83678383 break :msg msg;
83688384 }),
......@@ -8373,11 +8389,11 @@ fn instantiateGenericCall(
83738389 const arg_src = args_info.argSrc(block, arg_index);
83748390 const msg = try sema.errMsg(block, arg_src, "runtime-known argument passed to parameter of comptime-only type", .{});
83758391 errdefer msg.destroy(sema.gpa);
8376 const param_src = switch (param_tag) {
8377 .param => fn_zir.instructions.items(.data)[@intFromEnum(param_inst)].pl_tok.src(),
8378 .param_anytype => fn_zir.instructions.items(.data)[@intFromEnum(param_inst)].str_tok.src(),
8392 const param_src = child_block.tokenOffset(switch (param_tag) {
8393 .param => fn_zir.instructions.items(.data)[@intFromEnum(param_inst)].pl_tok.src_tok,
8394 .param_anytype => fn_zir.instructions.items(.data)[@intFromEnum(param_inst)].str_tok.src_tok,
83798395 else => unreachable,
8380 };
8396 });
83818397 try child_sema.errNote(&child_block, param_src, msg, "declared here", .{});
83828398 const src_decl = mod.declPtr(block.src_decl);
83838399 try sema.explainWhyTypeIsComptime(msg, src_decl.toSrcLoc(arg_src, mod), arg_ty);
......@@ -8560,7 +8576,7 @@ fn zirElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
85608576fn zirIndexablePtrElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
85618577 const mod = sema.mod;
85628578 const un_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
8563 const src = un_node.src();
8579 const src = block.nodeOffset(un_node.src_node);
85648580 const ptr_ty = sema.resolveType(block, src, un_node.operand) catch |err| switch (err) {
85658581 error.GenericPoison => return .generic_poison_type,
85668582 else => |e| return e,
......@@ -8585,7 +8601,7 @@ fn zirVectorElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
85858601 else => |e| return e,
85868602 };
85878603 if (!vec_ty.isVector(mod)) {
8588 return sema.fail(block, un_node.src(), "expected vector type, found '{}'", .{vec_ty.fmt(mod)});
8604 return sema.fail(block, block.nodeOffset(un_node.src_node), "expected vector type, found '{}'", .{vec_ty.fmt(mod)});
85898605 }
85908606 return Air.internedToRef(vec_ty.childType(mod).toIntern());
85918607}
......@@ -8672,7 +8688,7 @@ fn zirAnyframeType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
86728688
86738689 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
86748690 if (true) {
8675 return sema.failWithUseOfAsync(block, inst_data.src());
8691 return sema.failWithUseOfAsync(block, block.nodeOffset(inst_data.src_node));
86768692 }
86778693 const mod = sema.mod;
86788694 const operand_src: LazySrcLoc = .{ .node_offset_anyframe_type = inst_data.src_node };
......@@ -8888,7 +8904,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
88888904fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
88898905 const mod = sema.mod;
88908906 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
8891 const src = inst_data.src();
8907 const src = block.nodeOffset(inst_data.src_node);
88928908 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
88938909 const operand = try sema.resolveInst(inst_data.operand);
88948910 const operand_ty = sema.typeOf(operand);
......@@ -8946,7 +8962,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
89468962 const mod = sema.mod;
89478963 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
89488964 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
8949 const src = inst_data.src();
8965 const src = block.nodeOffset(inst_data.src_node);
89508966 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
89518967 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@enumFromInt");
89528968 const operand = try sema.resolveInst(extra.rhs);
......@@ -9015,7 +9031,7 @@ fn zirOptionalPayloadPtr(
90159031
90169032 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
90179033 const optional_ptr = try sema.resolveInst(inst_data.operand);
9018 const src = inst_data.src();
9034 const src = block.nodeOffset(inst_data.src_node);
90199035
90209036 return sema.analyzeOptionalPayloadPtr(block, src, optional_ptr, safety_check, false);
90219037}
......@@ -9099,7 +9115,7 @@ fn zirOptionalPayload(
90999115
91009116 const mod = sema.mod;
91019117 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
9102 const src = inst_data.src();
9118 const src = block.nodeOffset(inst_data.src_node);
91039119 const operand = try sema.resolveInst(inst_data.operand);
91049120 const operand_ty = sema.typeOf(operand);
91059121 const result_ty = switch (operand_ty.zigTypeTag(mod)) {
......@@ -9151,7 +9167,7 @@ fn zirErrUnionPayload(
91519167
91529168 const mod = sema.mod;
91539169 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
9154 const src = inst_data.src();
9170 const src = block.nodeOffset(inst_data.src_node);
91559171 const operand = try sema.resolveInst(inst_data.operand);
91569172 const operand_src = src;
91579173 const err_union_ty = sema.typeOf(operand);
......@@ -9204,7 +9220,7 @@ fn zirErrUnionPayloadPtr(
92049220
92059221 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
92069222 const operand = try sema.resolveInst(inst_data.operand);
9207 const src = inst_data.src();
9223 const src = block.nodeOffset(inst_data.src_node);
92089224
92099225 return sema.analyzeErrUnionPayloadPtr(block, src, operand, false, false);
92109226}
......@@ -9288,7 +9304,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
92889304 defer tracy.end();
92899305
92909306 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
9291 const src = inst_data.src();
9307 const src = block.nodeOffset(inst_data.src_node);
92929308 const operand = try sema.resolveInst(inst_data.operand);
92939309 return sema.analyzeErrUnionCode(block, src, operand);
92949310}
......@@ -9321,7 +9337,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
93219337 defer tracy.end();
93229338
93239339 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
9324 const src = inst_data.src();
9340 const src = block.nodeOffset(inst_data.src_node);
93259341 const operand = try sema.resolveInst(inst_data.operand);
93269342 return sema.analyzeErrUnionCodePtr(block, src, operand);
93279343}
......@@ -9997,11 +10013,11 @@ fn finishFunc(
999710013 param_body[0..block.params.len],
999810014 ) |is_comptime, name_nts, param_index| {
999910015 if (!is_comptime) {
10000 const param_src = switch (tags[@intFromEnum(param_index)]) {
10001 .param => data[@intFromEnum(param_index)].pl_tok.src(),
10002 .param_anytype => data[@intFromEnum(param_index)].str_tok.src(),
10016 const param_src = block.tokenOffset(switch (tags[@intFromEnum(param_index)]) {
10017 .param => data[@intFromEnum(param_index)].pl_tok.src_tok,
10018 .param_anytype => data[@intFromEnum(param_index)].str_tok.src_tok,
1000310019 else => unreachable,
10004 };
10020 });
1000510021 const name = sema.code.nullTerminatedString(name_nts);
1000610022 if (name.len != 0) {
1000710023 try sema.errNote(block, param_src, msg, "param '{s}' is required to be comptime", .{name});
......@@ -10084,7 +10100,7 @@ fn zirParam(
1008410100 comptime_syntax: bool,
1008510101) CompileError!void {
1008610102 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_tok;
10087 const src = inst_data.src();
10103 const src = block.tokenOffset(inst_data.src_tok);
1008810104 const extra = sema.code.extraData(Zir.Inst.Param, inst_data.payload_index);
1008910105 const param_name: Zir.NullTerminatedString = extra.data.name;
1009010106 const body = sema.code.bodySlice(extra.end, extra.data.body_len);
......@@ -10194,7 +10210,7 @@ fn zirAsNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1019410210 defer tracy.end();
1019510211
1019610212 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10197 const src = inst_data.src();
10213 const src = block.nodeOffset(inst_data.src_node);
1019810214 const extra = sema.code.extraData(Zir.Inst.As, inst_data.payload_index).data;
1019910215 return sema.analyzeAs(block, src, extra.dest_type, extra.operand, false);
1020010216}
......@@ -10204,7 +10220,7 @@ fn zirAsShiftOperand(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
1020410220 defer tracy.end();
1020510221
1020610222 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10207 const src = inst_data.src();
10223 const src = block.nodeOffset(inst_data.src_node);
1020810224 const extra = sema.code.extraData(Zir.Inst.As, inst_data.payload_index).data;
1020910225 return sema.analyzeAs(block, src, extra.dest_type, extra.operand, true);
1021010226}
......@@ -10301,7 +10317,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
1030110317 .storage = .{ .elems = new_elems },
1030210318 } }));
1030310319 }
10304 try sema.requireRuntimeBlock(block, inst_data.src(), ptr_src);
10320 try sema.requireRuntimeBlock(block, block.nodeOffset(inst_data.src_node), ptr_src);
1030510321 try sema.validateRuntimeValue(block, ptr_src, operand);
1030610322 if (!is_vector) {
1030710323 return block.addUnOp(.int_from_ptr, operand);
......@@ -10323,7 +10339,7 @@ fn zirFieldVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1032310339
1032410340 const mod = sema.mod;
1032510341 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10326 const src = inst_data.src();
10342 const src = block.nodeOffset(inst_data.src_node);
1032710343 const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node };
1032810344 const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data;
1032910345 const field_name = try mod.intern_pool.getOrPutString(
......@@ -10341,7 +10357,7 @@ fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1034110357
1034210358 const mod = sema.mod;
1034310359 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10344 const src = inst_data.src();
10360 const src = block.nodeOffset(inst_data.src_node);
1034510361 const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node };
1034610362 const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data;
1034710363 const field_name = try mod.intern_pool.getOrPutString(
......@@ -10359,7 +10375,7 @@ fn zirStructInitFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi
1035910375
1036010376 const mod = sema.mod;
1036110377 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10362 const src = inst_data.src();
10378 const src = block.nodeOffset(inst_data.src_node);
1036310379 const field_name_src: LazySrcLoc = .{ .node_offset_field_name_init = inst_data.src_node };
1036410380 const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data;
1036510381 const field_name = try mod.intern_pool.getOrPutString(
......@@ -10384,7 +10400,7 @@ fn zirFieldValNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
1038410400 defer tracy.end();
1038510401
1038610402 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10387 const src = inst_data.src();
10403 const src = block.nodeOffset(inst_data.src_node);
1038810404 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
1038910405 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;
1039010406 const object = try sema.resolveInst(extra.lhs);
......@@ -10399,7 +10415,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
1039910415 defer tracy.end();
1040010416
1040110417 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10402 const src = inst_data.src();
10418 const src = block.nodeOffset(inst_data.src_node);
1040310419 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
1040410420 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;
1040510421 const object_ptr = try sema.resolveInst(extra.lhs);
......@@ -10414,14 +10430,14 @@ fn zirIntCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1041410430 defer tracy.end();
1041510431
1041610432 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10417 const src = inst_data.src();
10433 const src = block.nodeOffset(inst_data.src_node);
1041810434 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1041910435 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
1042010436
1042110437 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@intCast");
1042210438 const operand = try sema.resolveInst(extra.rhs);
1042310439
10424 return sema.intCast(block, inst_data.src(), dest_ty, src, operand, operand_src, true);
10440 return sema.intCast(block, block.nodeOffset(inst_data.src_node), dest_ty, src, operand, operand_src, true);
1042510441}
1042610442
1042710443fn intCast(
......@@ -10584,7 +10600,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1058410600
1058510601 const mod = sema.mod;
1058610602 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10587 const src = inst_data.src();
10603 const src = block.nodeOffset(inst_data.src_node);
1058810604 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1058910605 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
1059010606
......@@ -10718,7 +10734,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1071810734 .Vector,
1071910735 => {},
1072010736 }
10721 return sema.bitCast(block, dest_ty, operand, inst_data.src(), operand_src);
10737 return sema.bitCast(block, dest_ty, operand, block.nodeOffset(inst_data.src_node), operand_src);
1072210738}
1072310739
1072410740fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
......@@ -10727,7 +10743,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
1072710743
1072810744 const mod = sema.mod;
1072910745 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10730 const src = inst_data.src();
10746 const src = block.nodeOffset(inst_data.src_node);
1073110747 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1073210748 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
1073310749
......@@ -10781,7 +10797,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
1078110797 if (dest_is_comptime_float) {
1078210798 return sema.fail(block, operand_src, "unable to cast runtime value to 'comptime_float'", .{});
1078310799 }
10784 try sema.requireRuntimeBlock(block, inst_data.src(), operand_src);
10800 try sema.requireRuntimeBlock(block, block.nodeOffset(inst_data.src_node), operand_src);
1078510801
1078610802 const src_bits = operand_scalar_ty.floatBits(target);
1078710803 const dst_bits = dest_scalar_ty.floatBits(target);
......@@ -10806,7 +10822,7 @@ fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1080610822 defer tracy.end();
1080710823
1080810824 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10809 const src = inst_data.src();
10825 const src = block.nodeOffset(inst_data.src_node);
1081010826 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
1081110827 const array = try sema.resolveInst(extra.lhs);
1081210828 const elem_index = try sema.resolveInst(extra.rhs);
......@@ -10818,7 +10834,7 @@ fn zirElemValNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1081810834 defer tracy.end();
1081910835
1082010836 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10821 const src = inst_data.src();
10837 const src = block.nodeOffset(inst_data.src_node);
1082210838 const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node };
1082310839 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
1082410840 const array = try sema.resolveInst(extra.lhs);
......@@ -10844,7 +10860,7 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1084410860
1084510861 const mod = sema.mod;
1084610862 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10847 const src = inst_data.src();
10863 const src = block.nodeOffset(inst_data.src_node);
1084810864 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
1084910865 const array_ptr = try sema.resolveInst(extra.lhs);
1085010866 const elem_index = try sema.resolveInst(extra.rhs);
......@@ -10871,7 +10887,7 @@ fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1087110887 defer tracy.end();
1087210888
1087310889 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10874 const src = inst_data.src();
10890 const src = block.nodeOffset(inst_data.src_node);
1087510891 const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node };
1087610892 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
1087710893 const array_ptr = try sema.resolveInst(extra.lhs);
......@@ -10886,7 +10902,7 @@ fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile
1088610902
1088710903 const mod = sema.mod;
1088810904 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10889 const src = inst_data.src();
10905 const src = block.nodeOffset(inst_data.src_node);
1089010906 const extra = sema.code.extraData(Zir.Inst.ElemPtrImm, inst_data.payload_index).data;
1089110907 const array_ptr = try sema.resolveInst(extra.ptr);
1089210908 const elem_index = try sema.mod.intRef(Type.usize, extra.index);
......@@ -10905,7 +10921,7 @@ fn zirSliceStart(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
1090510921 defer tracy.end();
1090610922
1090710923 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10908 const src = inst_data.src();
10924 const src = block.nodeOffset(inst_data.src_node);
1090910925 const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data;
1091010926 const array_ptr = try sema.resolveInst(extra.lhs);
1091110927 const start = try sema.resolveInst(extra.start);
......@@ -10921,7 +10937,7 @@ fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1092110937 defer tracy.end();
1092210938
1092310939 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10924 const src = inst_data.src();
10940 const src = block.nodeOffset(inst_data.src_node);
1092510941 const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data;
1092610942 const array_ptr = try sema.resolveInst(extra.lhs);
1092710943 const start = try sema.resolveInst(extra.start);
......@@ -10938,7 +10954,7 @@ fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
1093810954 defer tracy.end();
1093910955
1094010956 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10941 const src = inst_data.src();
10957 const src = block.nodeOffset(inst_data.src_node);
1094210958 const sentinel_src: LazySrcLoc = .{ .node_offset_slice_sentinel = inst_data.src_node };
1094310959 const extra = sema.code.extraData(Zir.Inst.SliceSentinel, inst_data.payload_index).data;
1094410960 const array_ptr = try sema.resolveInst(extra.lhs);
......@@ -10957,7 +10973,7 @@ fn zirSliceLength(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1095710973 defer tracy.end();
1095810974
1095910975 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
10960 const src = inst_data.src();
10976 const src = block.nodeOffset(inst_data.src_node);
1096110977 const extra = sema.code.extraData(Zir.Inst.SliceLength, inst_data.payload_index).data;
1096210978 const array_ptr = try sema.resolveInst(extra.lhs);
1096310979 const start = try sema.resolveInst(extra.start);
......@@ -11017,7 +11033,9 @@ const SwitchProngAnalysis = struct {
1101711033 merges: *Block.Merges,
1101811034 ) CompileError!Air.Inst.Ref {
1101911035 const sema = spa.sema;
11020 const src = sema.code.instructions.items(.data)[@intFromEnum(spa.switch_block_inst)].pl_node.src();
11036 const src = spa.parent_block.nodeOffset(
11037 sema.code.instructions.items(.data)[@intFromEnum(spa.switch_block_inst)].pl_node.src_node,
11038 );
1102111039
1102211040 if (has_tag_capture) {
1102311041 const tag_ref = try spa.analyzeTagCapture(child_block, raw_capture_src, inline_case_capture);
......@@ -11566,7 +11584,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
1156611584 const mod = sema.mod;
1156711585 const gpa = sema.gpa;
1156811586 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
11569 const switch_src = inst_data.src();
11587 const switch_src = block.nodeOffset(inst_data.src_node);
1157011588 const switch_src_node_offset = inst_data.src_node;
1157111589 const switch_operand_src: LazySrcLoc = .{ .node_offset_switch_operand = switch_src_node_offset };
1157211590 const else_prong_src: LazySrcLoc = .{ .node_offset_switch_special_prong = switch_src_node_offset };
......@@ -11874,7 +11892,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1187411892 const mod = sema.mod;
1187511893 const gpa = sema.gpa;
1187611894 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
11877 const src = inst_data.src();
11895 const src = block.nodeOffset(inst_data.src_node);
1187811896 const src_node_offset = inst_data.src_node;
1187911897 const operand_src: LazySrcLoc = .{ .node_offset_switch_operand = src_node_offset };
1188011898 const special_prong_src: LazySrcLoc = .{ .node_offset_switch_special_prong = src_node_offset };
......@@ -13396,7 +13414,7 @@ fn validateErrSetSwitch(
1339613414 const ip = &mod.intern_pool;
1339713415
1339813416 const src_node_offset = inst_data.src_node;
13399 const src = inst_data.src();
13417 const src = block.nodeOffset(src_node_offset);
1340013418
1340113419 var extra_index: usize = else_case.end;
1340213420 {
......@@ -13836,7 +13854,7 @@ fn maybeErrorUnwrapComptime(sema: *Sema, block: *Block, body: []const Zir.Inst.I
1383613854 }
1383713855 } else return;
1383813856 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"unreachable";
13839 const src = inst_data.src();
13857 const src = block.nodeOffset(inst_data.src_node);
1384013858
1384113859 if (try sema.resolveDefinedValue(block, src, operand)) |val| {
1384213860 if (val.getErrorName(sema.mod).unwrap()) |name| {
......@@ -13900,7 +13918,7 @@ fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1390013918 const mod = sema.mod;
1390113919 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
1390213920 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
13903 const src = inst_data.src();
13921 const src = block.nodeOffset(inst_data.src_node);
1390413922 const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1390513923 const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
1390613924 const container_type = try sema.resolveType(block, lhs_src, extra.lhs);
......@@ -13932,7 +13950,7 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1393213950
1393313951 const mod = sema.mod;
1393413952 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_tok;
13935 const operand_src = inst_data.src();
13953 const operand_src = block.tokenOffset(inst_data.src_tok);
1393613954 const operand = inst_data.get(sema.code);
1393713955
1393813956 const result = mod.importFile(block.getFileScope(mod), operand) catch |err| switch (err) {
......@@ -14012,7 +14030,7 @@ fn zirShl(
1401214030
1401314031 const mod = sema.mod;
1401414032 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
14015 const src = inst_data.src();
14033 const src = block.nodeOffset(inst_data.src_node);
1401614034 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
1401714035 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
1401814036 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
......@@ -14182,7 +14200,7 @@ fn zirShr(
1418214200
1418314201 const mod = sema.mod;
1418414202 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
14185 const src = inst_data.src();
14203 const src = block.nodeOffset(inst_data.src_node);
1418614204 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
1418714205 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
1418814206 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
......@@ -14371,7 +14389,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1437114389
1437214390 const mod = sema.mod;
1437314391 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
14374 const src = inst_data.src();
14392 const src = block.nodeOffset(inst_data.src_node);
1437514393 const operand_src: LazySrcLoc = .{ .node_offset_un_op = inst_data.src_node };
1437614394
1437714395 const operand = try sema.resolveInst(inst_data.operand);
......@@ -14520,7 +14538,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1452014538 const rhs = try sema.resolveInst(extra.rhs);
1452114539 const lhs_ty = sema.typeOf(lhs);
1452214540 const rhs_ty = sema.typeOf(rhs);
14523 const src = inst_data.src();
14541 const src = block.nodeOffset(inst_data.src_node);
1452414542
1452514543 const lhs_is_tuple = lhs_ty.isTuple(mod);
1452614544 const rhs_is_tuple = rhs_ty.isTuple(mod);
......@@ -14871,7 +14889,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1487114889 const extra = sema.code.extraData(Zir.Inst.ArrayMul, inst_data.payload_index).data;
1487214890 const uncoerced_lhs = try sema.resolveInst(extra.lhs);
1487314891 const uncoerced_lhs_ty = sema.typeOf(uncoerced_lhs);
14874 const src: LazySrcLoc = inst_data.src();
14892 const src: LazySrcLoc = block.nodeOffset(inst_data.src_node);
1487514893 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
1487614894 const operator_src: LazySrcLoc = .{ .node_offset_main_token = inst_data.src_node };
1487714895 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
......@@ -15041,7 +15059,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1504115059fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1504215060 const mod = sema.mod;
1504315061 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
15044 const src = inst_data.src();
15062 const src = block.nodeOffset(inst_data.src_node);
1504515063 const lhs_src = src;
1504615064 const rhs_src: LazySrcLoc = .{ .node_offset_un_op = inst_data.src_node };
1504715065
......@@ -15073,7 +15091,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1507315091fn zirNegateWrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1507415092 const mod = sema.mod;
1507515093 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
15076 const src = inst_data.src();
15094 const src = block.nodeOffset(inst_data.src_node);
1507715095 const lhs_src = src;
1507815096 const rhs_src: LazySrcLoc = .{ .node_offset_un_op = inst_data.src_node };
1507915097
......@@ -16991,7 +17009,7 @@ fn zirLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.In
1699117009 defer tracy.end();
1699217010
1699317011 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
16994 const src = inst_data.src();
17012 const src = block.nodeOffset(inst_data.src_node);
1699517013 const ptr_src = src; // TODO better source location
1699617014 const ptr = try sema.resolveInst(inst_data.operand);
1699717015 return sema.analyzeLoad(block, src, ptr, ptr_src);
......@@ -17181,7 +17199,7 @@ fn zirCmpEq(
1718117199 const mod = sema.mod;
1718217200 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
1718317201 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
17184 const src: LazySrcLoc = inst_data.src();
17202 const src: LazySrcLoc = block.nodeOffset(inst_data.src_node);
1718517203 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
1718617204 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
1718717205 const lhs = try sema.resolveInst(extra.lhs);
......@@ -17297,7 +17315,7 @@ fn zirCmp(
1729717315
1729817316 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
1729917317 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
17300 const src: LazySrcLoc = inst_data.src();
17318 const src: LazySrcLoc = block.nodeOffset(inst_data.src_node);
1730117319 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
1730217320 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
1730317321 const lhs = try sema.resolveInst(extra.lhs);
......@@ -17724,7 +17742,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1772417742 const gpa = sema.gpa;
1772517743 const ip = &mod.intern_pool;
1772617744 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
17727 const src = inst_data.src();
17745 const src = block.nodeOffset(inst_data.src_node);
1772817746 const ty = try sema.resolveType(block, src, inst_data.operand);
1772917747 const type_info_ty = try sema.getBuiltinType("Type");
1773017748 const type_info_tag_ty = type_info_ty.unionTagType(mod).?;
......@@ -18906,7 +18924,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
1890618924
1890718925fn zirTypeofLog2IntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1890818926 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
18909 const src = inst_data.src();
18927 const src = block.nodeOffset(inst_data.src_node);
1891018928 const operand = try sema.resolveInst(inst_data.operand);
1891118929 const operand_ty = sema.typeOf(operand);
1891218930 const res_ty = try sema.log2IntType(block, operand_ty, src);
......@@ -18998,7 +19016,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1899819016
1899919017 const mod = sema.mod;
1900019018 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
19001 const src = inst_data.src();
19019 const src = block.nodeOffset(inst_data.src_node);
1900219020 const operand_src: LazySrcLoc = .{ .node_offset_un_op = inst_data.src_node };
1900319021 const uncasted_operand = try sema.resolveInst(inst_data.operand);
1900419022
......@@ -19155,7 +19173,7 @@ fn zirIsNonNull(
1915519173 defer tracy.end();
1915619174
1915719175 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
19158 const src = inst_data.src();
19176 const src = block.nodeOffset(inst_data.src_node);
1915919177 const operand = try sema.resolveInst(inst_data.operand);
1916019178 try sema.checkNullableType(block, src, sema.typeOf(operand));
1916119179 return sema.analyzeIsNull(block, src, operand, true);
......@@ -19171,7 +19189,7 @@ fn zirIsNonNullPtr(
1917119189
1917219190 const mod = sema.mod;
1917319191 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
19174 const src = inst_data.src();
19192 const src = block.nodeOffset(inst_data.src_node);
1917519193 const ptr = try sema.resolveInst(inst_data.operand);
1917619194 try sema.checkNullableType(block, src, sema.typeOf(ptr).elemType2(mod));
1917719195 if ((try sema.resolveValue(ptr)) == null) {
......@@ -19196,7 +19214,7 @@ fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1919619214 defer tracy.end();
1919719215
1919819216 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
19199 const src = inst_data.src();
19217 const src = block.nodeOffset(inst_data.src_node);
1920019218 const operand = try sema.resolveInst(inst_data.operand);
1920119219 try sema.checkErrorType(block, src, sema.typeOf(operand));
1920219220 return sema.analyzeIsNonErr(block, src, operand);
......@@ -19208,7 +19226,7 @@ fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1920819226
1920919227 const mod = sema.mod;
1921019228 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
19211 const src = inst_data.src();
19229 const src = block.nodeOffset(inst_data.src_node);
1921219230 const ptr = try sema.resolveInst(inst_data.operand);
1921319231 try sema.checkErrorType(block, src, sema.typeOf(ptr).elemType2(mod));
1921419232 const loaded = try sema.analyzeLoad(block, src, ptr, src);
......@@ -19220,7 +19238,7 @@ fn zirRetIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1922019238 defer tracy.end();
1922119239
1922219240 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
19223 const src = inst_data.src();
19241 const src = block.nodeOffset(inst_data.src_node);
1922419242 const operand = try sema.resolveInst(inst_data.operand);
1922519243 return sema.analyzeIsNonErr(block, src, operand);
1922619244}
......@@ -19302,7 +19320,7 @@ fn zirCondbr(
1930219320
1930319321fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1930419322 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
19305 const src = inst_data.src();
19323 const src = parent_block.nodeOffset(inst_data.src_node);
1930619324 const operand_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
1930719325 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);
1930819326 const body = sema.code.bodySlice(extra.end, extra.data.body_len);
......@@ -19349,7 +19367,7 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!
1934919367
1935019368fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1935119369 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
19352 const src = inst_data.src();
19370 const src = parent_block.nodeOffset(inst_data.src_node);
1935319371 const operand_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
1935419372 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);
1935519373 const body = sema.code.bodySlice(extra.end, extra.data.body_len);
......@@ -19474,7 +19492,7 @@ fn addRuntimeBreak(sema: *Sema, child_block: *Block, block_inst: Zir.Inst.Index,
1947419492
1947519493fn zirUnreachable(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
1947619494 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"unreachable";
19477 const src = inst_data.src();
19495 const src = block.nodeOffset(inst_data.src_node);
1947819496
1947919497 if (block.is_comptime) {
1948019498 return sema.fail(block, src, "reached unreachable code", .{});
......@@ -19498,13 +19516,13 @@ fn zirRetErrValue(
1949819516) CompileError!void {
1949919517 const mod = sema.mod;
1950019518 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_tok;
19519 const src = block.tokenOffset(inst_data.src_tok);
1950119520 const err_name = try mod.intern_pool.getOrPutString(
1950219521 sema.gpa,
1950319522 inst_data.get(sema.code),
1950419523 .no_embedded_nulls,
1950519524 );
1950619525 _ = try mod.getErrorValue(err_name);
19507 const src = inst_data.src();
1950819526 // Return the error code from the function.
1950919527 const error_set_type = try mod.singleErrorSetType(err_name);
1951019528 const result_inst = Air.internedToRef((try mod.intern(.{ .err = .{
......@@ -19524,7 +19542,7 @@ fn zirRetImplicit(
1952419542
1952519543 const mod = sema.mod;
1952619544 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok;
19527 const r_brace_src = inst_data.src();
19545 const r_brace_src = block.tokenOffset(inst_data.src_tok);
1952819546 if (block.inlining == null and sema.func_is_naked) {
1952919547 assert(!block.is_comptime);
1953019548 if (block.wantSafety()) {
......@@ -19570,7 +19588,7 @@ fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi
1957019588
1957119589 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
1957219590 const operand = try sema.resolveInst(inst_data.operand);
19573 const src = inst_data.src();
19591 const src = block.nodeOffset(inst_data.src_node);
1957419592
1957519593 return sema.analyzeRet(block, operand, src, .{ .node_offset_return_operand = inst_data.src_node });
1957619594}
......@@ -19580,7 +19598,7 @@ fn zirRetLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi
1958019598 defer tracy.end();
1958119599
1958219600 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
19583 const src = inst_data.src();
19601 const src = block.nodeOffset(inst_data.src_node);
1958419602 const ret_ptr = try sema.resolveInst(inst_data.operand);
1958519603
1958619604 if (block.is_comptime or block.inlining != null or sema.func_is_naked) {
......@@ -19679,7 +19697,7 @@ fn zirSaveErrRetIndex(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
1967919697
1968019698fn zirRestoreErrRetIndex(sema: *Sema, start_block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
1968119699 const extra = sema.code.extraData(Zir.Inst.RestoreErrRetIndex, extended.operand).data;
19682 return sema.restoreErrRetIndex(start_block, extra.src(), extra.block, extra.operand);
19700 return sema.restoreErrRetIndex(start_block, start_block.nodeOffset(extra.src_node), extra.block, extra.operand);
1968319701}
1968419702
1968519703/// If `operand` is non-error (or is `none`), restores the error return trace to
......@@ -20006,7 +20024,7 @@ fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
2000620024 defer tracy.end();
2000720025
2000820026 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
20009 const src = inst_data.src();
20027 const src = block.nodeOffset(inst_data.src_node);
2001020028 const ty_src: LazySrcLoc = .{ .node_offset_init_ty = inst_data.src_node };
2001120029 const obj_ty = try sema.resolveType(block, ty_src, inst_data.operand);
2001220030 const mod = sema.mod;
......@@ -20026,7 +20044,7 @@ fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is
2002620044
2002720045 const mod = sema.mod;
2002820046 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
20029 const src = inst_data.src();
20047 const src = block.nodeOffset(inst_data.src_node);
2003020048 const ty_operand = sema.resolveType(block, src, inst_data.operand) catch |err| switch (err) {
2003120049 // Generic poison means this is an untyped anonymous empty struct init
2003220050 error.GenericPoison => return .empty_struct,
......@@ -20158,7 +20176,7 @@ fn zirStructInit(
2015820176 const zir_datas = sema.code.instructions.items(.data);
2015920177 const inst_data = zir_datas[@intFromEnum(inst)].pl_node;
2016020178 const extra = sema.code.extraData(Zir.Inst.StructInit, inst_data.payload_index);
20161 const src = inst_data.src();
20179 const src = block.nodeOffset(inst_data.src_node);
2016220180
2016320181 const mod = sema.mod;
2016420182 const ip = &mod.intern_pool;
......@@ -20503,7 +20521,7 @@ fn zirStructInitAnon(
2050320521 inst: Zir.Inst.Index,
2050420522) CompileError!Air.Inst.Ref {
2050520523 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
20506 const src = inst_data.src();
20524 const src = block.nodeOffset(inst_data.src_node);
2050720525 const extra = sema.code.extraData(Zir.Inst.StructInitAnon, inst_data.payload_index);
2050820526 return sema.structInitAnon(block, src, .anon_init, extra.data, extra.end, false);
2050920527}
......@@ -20655,7 +20673,7 @@ fn zirArrayInit(
2065520673 const mod = sema.mod;
2065620674 const gpa = sema.gpa;
2065720675 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
20658 const src = inst_data.src();
20676 const src = block.nodeOffset(inst_data.src_node);
2065920677
2066020678 const extra = sema.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index);
2066120679 const args = sema.code.refSlice(extra.end, extra.data.operands_len);
......@@ -20818,7 +20836,7 @@ fn zirArrayInitAnon(
2081820836 inst: Zir.Inst.Index,
2081920837) CompileError!Air.Inst.Ref {
2082020838 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
20821 const src = inst_data.src();
20839 const src = block.nodeOffset(inst_data.src_node);
2082220840 const extra = sema.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index);
2082320841 const operands = sema.code.refSlice(extra.end, extra.data.operands_len);
2082420842 return sema.arrayInitAnon(block, src, operands, false);
......@@ -20931,7 +20949,7 @@ fn zirStructInitFieldType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
2093120949 const ip = &mod.intern_pool;
2093220950 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
2093320951 const extra = sema.code.extraData(Zir.Inst.FieldType, inst_data.payload_index).data;
20934 const ty_src = inst_data.src();
20952 const ty_src = block.nodeOffset(inst_data.src_node);
2093520953 const field_name_src: LazySrcLoc = .{ .node_offset_field_name_init = inst_data.src_node };
2093620954 const wrapped_aggregate_ty = sema.resolveType(block, ty_src, extra.container_type) catch |err| switch (err) {
2093720955 // Since this is a ZIR instruction that returns a type, encountering
......@@ -21054,7 +21072,7 @@ fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
2105421072fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2105521073 const mod = sema.mod;
2105621074 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
21057 const src = inst_data.src();
21075 const src = block.nodeOffset(inst_data.src_node);
2105821076 const operand = try sema.resolveInst(inst_data.operand);
2105921077 const operand_ty = sema.typeOf(operand);
2106021078 const is_vector = operand_ty.zigTypeTag(mod) == .Vector;
......@@ -21216,7 +21234,7 @@ fn zirUnaryMath(
2121621234fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2121721235 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
2121821236 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
21219 const src = inst_data.src();
21237 const src = block.nodeOffset(inst_data.src_node);
2122021238 const operand = try sema.resolveInst(inst_data.operand);
2122121239 const operand_ty = sema.typeOf(operand);
2122221240 const mod = sema.mod;
......@@ -22512,20 +22530,20 @@ fn zirTypeName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
2251222530
2251322531fn zirFrameType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2251422532 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
22515 const src = inst_data.src();
22533 const src = block.nodeOffset(inst_data.src_node);
2251622534 return sema.failWithUseOfAsync(block, src);
2251722535}
2251822536
2251922537fn zirFrameSize(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2252022538 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
22521 const src = inst_data.src();
22539 const src = block.nodeOffset(inst_data.src_node);
2252222540 return sema.failWithUseOfAsync(block, src);
2252322541}
2252422542
2252522543fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2252622544 const mod = sema.mod;
2252722545 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
22528 const src = inst_data.src();
22546 const src = block.nodeOffset(inst_data.src_node);
2252922547 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
2253022548 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2253122549 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@intFromFloat");
......@@ -22550,7 +22568,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
2255022568 });
2255122569 }
2255222570
22553 try sema.requireRuntimeBlock(block, inst_data.src(), operand_src);
22571 try sema.requireRuntimeBlock(block, src, operand_src);
2255422572 if (dest_scalar_ty.intInfo(mod).bits == 0) {
2255522573 if (!is_vector) {
2255622574 if (block.wantSafety()) {
......@@ -22607,7 +22625,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
2260722625fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2260822626 const mod = sema.mod;
2260922627 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
22610 const src = inst_data.src();
22628 const src = block.nodeOffset(inst_data.src_node);
2261122629 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
2261222630 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2261322631 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@floatFromInt");
......@@ -22649,7 +22667,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
2264922667fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2265022668 const mod = sema.mod;
2265122669 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
22652 const src = inst_data.src();
22670 const src = block.nodeOffset(inst_data.src_node);
2265322671
2265422672 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
2265522673
......@@ -22934,7 +22952,7 @@ fn zirPtrCastFull(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDa
2293422952
2293522953fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2293622954 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
22937 const src = inst_data.src();
22955 const src = block.nodeOffset(inst_data.src_node);
2293822956 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2293922957 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
2294022958 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, "@ptrCast");
......@@ -23381,7 +23399,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst
2338123399fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2338223400 const mod = sema.mod;
2338323401 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
23384 const src = inst_data.src();
23402 const src = block.nodeOffset(inst_data.src_node);
2338523403 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2338623404 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
2338723405 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@truncate");
......@@ -23471,7 +23489,7 @@ fn zirBitCount(
2347123489) CompileError!Air.Inst.Ref {
2347223490 const mod = sema.mod;
2347323491 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
23474 const src = inst_data.src();
23492 const src = block.nodeOffset(inst_data.src_node);
2347523493 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2347623494 const operand = try sema.resolveInst(inst_data.operand);
2347723495 const operand_ty = sema.typeOf(operand);
......@@ -23525,7 +23543,7 @@ fn zirBitCount(
2352523543fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2352623544 const mod = sema.mod;
2352723545 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
23528 const src = inst_data.src();
23546 const src = block.nodeOffset(inst_data.src_node);
2352923547 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2353023548 const operand = try sema.resolveInst(inst_data.operand);
2353123549 const operand_ty = sema.typeOf(operand);
......@@ -23581,7 +23599,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
2358123599
2358223600fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2358323601 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
23584 const src = inst_data.src();
23602 const src = block.nodeOffset(inst_data.src_node);
2358523603 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2358623604 const operand = try sema.resolveInst(inst_data.operand);
2358723605 const operand_ty = sema.typeOf(operand);
......@@ -24290,7 +24308,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
2429024308 const mod = sema.mod;
2429124309 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
2429224310 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
24293 const src = inst_data.src();
24311 const src = block.nodeOffset(inst_data.src_node);
2429424312 const scalar_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2429524313 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@splat");
2429624314
......@@ -24312,7 +24330,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
2431224330 return Air.internedToRef((try sema.splat(dest_ty, scalar_val)).toIntern());
2431324331 }
2431424332
24315 try sema.requireRuntimeBlock(block, inst_data.src(), scalar_src);
24333 try sema.requireRuntimeBlock(block, src, scalar_src);
2431624334 return block.addTyOp(.splat, dest_ty, scalar);
2431724335}
2431824336
......@@ -24377,7 +24395,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
2437724395 return Air.internedToRef(accum.toIntern());
2437824396 }
2437924397
24380 try sema.requireRuntimeBlock(block, inst_data.src(), operand_src);
24398 try sema.requireRuntimeBlock(block, block.nodeOffset(inst_data.src_node), operand_src);
2438124399 return block.addInst(.{
2438224400 .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce,
2438324401 .data = .{ .reduce = .{
......@@ -24704,7 +24722,7 @@ fn zirAtomicLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
2470424722 }
2470524723 }
2470624724
24707 try sema.requireRuntimeBlock(block, inst_data.src(), ptr_src);
24725 try sema.requireRuntimeBlock(block, block.nodeOffset(inst_data.src_node), ptr_src);
2470824726 return block.addInst(.{
2470924727 .tag = .atomic_load,
2471024728 .data = .{ .atomic_load = .{
......@@ -24718,7 +24736,7 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2471824736 const mod = sema.mod;
2471924737 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
2472024738 const extra = sema.code.extraData(Zir.Inst.AtomicRmw, inst_data.payload_index).data;
24721 const src = inst_data.src();
24739 const src = block.nodeOffset(inst_data.src_node);
2472224740 // zig fmt: off
2472324741 const elem_ty_src : LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2472424742 const ptr_src : LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
......@@ -24803,7 +24821,7 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2480324821fn zirAtomicStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
2480424822 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
2480524823 const extra = sema.code.extraData(Zir.Inst.AtomicStore, inst_data.payload_index).data;
24806 const src = inst_data.src();
24824 const src = block.nodeOffset(inst_data.src_node);
2480724825 // zig fmt: off
2480824826 const elem_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2480924827 const ptr_src : LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
......@@ -24839,7 +24857,7 @@ fn zirAtomicStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
2483924857fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2484024858 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
2484124859 const extra = sema.code.extraData(Zir.Inst.MulAdd, inst_data.payload_index).data;
24842 const src = inst_data.src();
24860 const src = block.nodeOffset(inst_data.src_node);
2484324861
2484424862 const mulend1_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
2484524863 const mulend2_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node };
......@@ -24909,7 +24927,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
2490924927 const modifier_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2491024928 const func_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
2491124929 const args_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node };
24912 const call_src = inst_data.src();
24930 const call_src = block.nodeOffset(inst_data.src_node);
2491324931
2491424932 const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data;
2491524933 const func = try sema.resolveInst(extra.callee);
......@@ -25003,7 +25021,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins
2500325021 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?;
2500425022 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small)));
2500525023 assert(!flags.ptr_cast);
25006 const inst_src = extra.src();
25024 const inst_src = block.nodeOffset(extra.src_node);
2500725025 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.src_node };
2500825026 const field_ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.src_node };
2500925027
......@@ -25213,7 +25231,7 @@ fn zirMinMax(
2521325231) CompileError!Air.Inst.Ref {
2521425232 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
2521525233 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
25216 const src = inst_data.src();
25234 const src = block.nodeOffset(inst_data.src_node);
2521725235 const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2521825236 const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
2521925237 const lhs = try sema.resolveInst(extra.lhs);
......@@ -25514,7 +25532,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A
2551425532fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
2551525533 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
2551625534 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
25517 const src = inst_data.src();
25535 const src = block.nodeOffset(inst_data.src_node);
2551825536 const dest_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2551925537 const src_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
2552025538 const dest_ptr = try sema.resolveInst(extra.lhs);
......@@ -25734,7 +25752,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
2573425752 const ip = &mod.intern_pool;
2573525753 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
2573625754 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
25737 const src = inst_data.src();
25755 const src = block.nodeOffset(inst_data.src_node);
2573825756 const dest_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
2573925757 const value_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
2574025758 const dest_ptr = try sema.resolveInst(extra.lhs);
......@@ -25819,7 +25837,7 @@ fn zirBuiltinAsyncCall(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.I
2581925837
2582025838fn zirResume(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
2582125839 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
25822 const src = inst_data.src();
25840 const src = block.nodeOffset(inst_data.src_node);
2582325841 return sema.failWithUseOfAsync(block, src);
2582425842}
2582525843
......@@ -25829,7 +25847,7 @@ fn zirAwait(
2582925847 inst: Zir.Inst.Index,
2583025848) CompileError!Air.Inst.Ref {
2583125849 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
25832 const src = inst_data.src();
25850 const src = block.nodeOffset(inst_data.src_node);
2583325851
2583425852 return sema.failWithUseOfAsync(block, src);
2583525853}
src/Sema/comptime_ptr_access.zig+2-1
......@@ -1048,7 +1048,6 @@ fn checkComptimeVarStore(
10481048const std = @import("std");
10491049const assert = std.debug.assert;
10501050const Allocator = std.mem.Allocator;
1051const LazySrcLoc = std.zig.LazySrcLoc;
10521051
10531052const InternPool = @import("../InternPool.zig");
10541053const ComptimeAllocIndex = InternPool.ComptimeAllocIndex;
......@@ -1057,3 +1056,5 @@ const Block = Sema.Block;
10571056const MutableValue = @import("../mutable_value.zig").MutableValue;
10581057const Type = @import("../type.zig").Type;
10591058const Value = @import("../Value.zig");
1059const Zcu = @import("../Module.zig");
1060const LazySrcLoc = Zcu.LazySrcLoc;
src/arch/wasm/CodeGen.zig+1-1
......@@ -16,7 +16,7 @@ const Decl = Module.Decl;
1616const Type = @import("../../type.zig").Type;
1717const Value = @import("../../Value.zig");
1818const Compilation = @import("../../Compilation.zig");
19const LazySrcLoc = std.zig.LazySrcLoc;
19const LazySrcLoc = Module.LazySrcLoc;
2020const link = @import("../../link.zig");
2121const Air = @import("../../Air.zig");
2222const Liveness = @import("../../Liveness.zig");
src/codegen/c.zig+1-1
......@@ -13,7 +13,7 @@ const Type = @import("../type.zig").Type;
1313const C = link.File.C;
1414const Decl = Zcu.Decl;
1515const trace = @import("../tracy.zig").trace;
16const LazySrcLoc = std.zig.LazySrcLoc;
16const LazySrcLoc = Zcu.LazySrcLoc;
1717const Air = @import("../Air.zig");
1818const Liveness = @import("../Liveness.zig");
1919const InternPool = @import("../InternPool.zig");
src/codegen/c/Type.zig+1-1
......@@ -2581,8 +2581,8 @@ pub const AlignAs = packed struct {
25812581const Alignment = @import("../../InternPool.zig").Alignment;
25822582const assert = std.debug.assert;
25832583const CType = @This();
2584const DeclIndex = std.zig.DeclIndex;
25852584const Module = @import("../../Package/Module.zig");
25862585const std = @import("std");
25872586const Type = @import("../../type.zig").Type;
25882587const Zcu = @import("../../Module.zig");
2588const DeclIndex = @import("../../InternPool.zig").DeclIndex;
src/codegen/llvm.zig+1-1
......@@ -22,7 +22,7 @@ const Air = @import("../Air.zig");
2222const Liveness = @import("../Liveness.zig");
2323const Value = @import("../Value.zig");
2424const Type = @import("../type.zig").Type;
25const LazySrcLoc = std.zig.LazySrcLoc;
25const LazySrcLoc = Zcu.LazySrcLoc;
2626const x86_64_abi = @import("../arch/x86_64/abi.zig");
2727const wasm_c_abi = @import("../arch/wasm/abi.zig");
2828const aarch64_c_abi = @import("../arch/aarch64/abi.zig");
src/codegen/spirv.zig+1-1
......@@ -9,7 +9,7 @@ const Module = @import("../Module.zig");
99const Decl = Module.Decl;
1010const Type = @import("../type.zig").Type;
1111const Value = @import("../Value.zig");
12const LazySrcLoc = std.zig.LazySrcLoc;
12const LazySrcLoc = Module.LazySrcLoc;
1313const Air = @import("../Air.zig");
1414const Liveness = @import("../Liveness.zig");
1515const InternPool = @import("../InternPool.zig");
src/print_zir.zig+70-71
......@@ -6,8 +6,9 @@ const Ast = std.zig.Ast;
66const InternPool = @import("InternPool.zig");
77
88const Zir = std.zig.Zir;
9const Module = @import("Module.zig");
10const LazySrcLoc = std.zig.LazySrcLoc;
9const Zcu = @import("Module.zig");
10const Module = Zcu;
11const LazySrcLoc = Zcu.LazySrcLoc;
1112
1213/// Write human-readable, debug formatted ZIR code to a file.
1314pub fn renderAsTextToFile(
......@@ -630,7 +631,7 @@ const Writer = struct {
630631 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
631632 try self.writeInstRef(stream, inst_data.operand);
632633 try stream.writeAll(") ");
633 try self.writeSrc(stream, inst_data.src());
634 try self.writeSrcNode(stream, inst_data.src_node);
634635 }
635636
636637 fn writeUnTok(
......@@ -641,7 +642,7 @@ const Writer = struct {
641642 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].un_tok;
642643 try self.writeInstRef(stream, inst_data.operand);
643644 try stream.writeAll(") ");
644 try self.writeSrc(stream, inst_data.src());
645 try self.writeSrcTok(stream, inst_data.src_tok);
645646 }
646647
647648 fn writeValidateDestructure(
......@@ -655,7 +656,7 @@ const Writer = struct {
655656 try stream.print(", {d}) (destructure=", .{extra.expect_len});
656657 try self.writeSrc(stream, LazySrcLoc.nodeOffset(extra.destructure_node));
657658 try stream.writeAll(") ");
658 try self.writeSrc(stream, inst_data.src());
659 try self.writeSrcNode(stream, inst_data.src_node);
659660 }
660661
661662 fn writeValidateArrayInitTy(
......@@ -667,7 +668,7 @@ const Writer = struct {
667668 const extra = self.code.extraData(Zir.Inst.ArrayInit, inst_data.payload_index).data;
668669 try self.writeInstRef(stream, extra.ty);
669670 try stream.print(", {d}) ", .{extra.init_count});
670 try self.writeSrc(stream, inst_data.src());
671 try self.writeSrcNode(stream, inst_data.src_node);
671672 }
672673
673674 fn writeArrayTypeSentinel(
......@@ -683,7 +684,7 @@ const Writer = struct {
683684 try stream.writeAll(", ");
684685 try self.writeInstRef(stream, extra.elem_type);
685686 try stream.writeAll(") ");
686 try self.writeSrc(stream, inst_data.src());
687 try self.writeSrcNode(stream, inst_data.src_node);
687688 }
688689
689690 fn writePtrType(
......@@ -763,11 +764,10 @@ const Writer = struct {
763764 fn writeFloat128(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
764765 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
765766 const extra = self.code.extraData(Zir.Inst.Float128, inst_data.payload_index).data;
766 const src = inst_data.src();
767767 const number = extra.get();
768768 // TODO improve std.format to be able to print f128 values
769769 try stream.print("{d}) ", .{@as(f64, @floatCast(number))});
770 try self.writeSrc(stream, src);
770 try self.writeSrcNode(stream, inst_data.src_node);
771771 }
772772
773773 fn writeStr(
......@@ -787,7 +787,7 @@ const Writer = struct {
787787 try stream.writeAll(", ");
788788 try self.writeInstRef(stream, extra.start);
789789 try stream.writeAll(") ");
790 try self.writeSrc(stream, inst_data.src());
790 try self.writeSrcNode(stream, inst_data.src_node);
791791 }
792792
793793 fn writeSliceEnd(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -799,7 +799,7 @@ const Writer = struct {
799799 try stream.writeAll(", ");
800800 try self.writeInstRef(stream, extra.end);
801801 try stream.writeAll(") ");
802 try self.writeSrc(stream, inst_data.src());
802 try self.writeSrcNode(stream, inst_data.src_node);
803803 }
804804
805805 fn writeSliceSentinel(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -813,7 +813,7 @@ const Writer = struct {
813813 try stream.writeAll(", ");
814814 try self.writeInstRef(stream, extra.sentinel);
815815 try stream.writeAll(") ");
816 try self.writeSrc(stream, inst_data.src());
816 try self.writeSrcNode(stream, inst_data.src_node);
817817 }
818818
819819 fn writeSliceLength(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -829,7 +829,7 @@ const Writer = struct {
829829 try self.writeInstRef(stream, extra.sentinel);
830830 }
831831 try stream.writeAll(") ");
832 try self.writeSrc(stream, inst_data.src());
832 try self.writeSrcNode(stream, inst_data.src_node);
833833 }
834834
835835 fn writeUnionInit(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -841,7 +841,7 @@ const Writer = struct {
841841 try stream.writeAll(", ");
842842 try self.writeInstRef(stream, extra.init);
843843 try stream.writeAll(") ");
844 try self.writeSrc(stream, inst_data.src());
844 try self.writeSrcNode(stream, inst_data.src_node);
845845 }
846846
847847 fn writeShuffle(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -855,7 +855,7 @@ const Writer = struct {
855855 try stream.writeAll(", ");
856856 try self.writeInstRef(stream, extra.mask);
857857 try stream.writeAll(") ");
858 try self.writeSrc(stream, inst_data.src());
858 try self.writeSrcNode(stream, inst_data.src_node);
859859 }
860860
861861 fn writeSelect(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {
......@@ -880,7 +880,7 @@ const Writer = struct {
880880 try stream.writeAll(", ");
881881 try self.writeInstRef(stream, extra.addend);
882882 try stream.writeAll(") ");
883 try self.writeSrc(stream, inst_data.src());
883 try self.writeSrcNode(stream, inst_data.src_node);
884884 }
885885
886886 fn writeBuiltinCall(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -896,7 +896,7 @@ const Writer = struct {
896896 try stream.writeAll(", ");
897897 try self.writeInstRef(stream, extra.args);
898898 try stream.writeAll(") ");
899 try self.writeSrc(stream, inst_data.src());
899 try self.writeSrcNode(stream, inst_data.src_node);
900900 }
901901
902902 fn writeFieldParentPtr(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {
......@@ -913,7 +913,7 @@ const Writer = struct {
913913 try stream.writeAll(", ");
914914 try self.writeInstRef(stream, extra.field_ptr);
915915 try stream.writeAll(") ");
916 try self.writeSrc(stream, extra.src());
916 try self.writeSrcNode(stream, extra.src_node);
917917 }
918918
919919 fn writeBuiltinAsyncCall(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {
......@@ -944,7 +944,7 @@ const Writer = struct {
944944 }
945945 try self.writeBracedBody(stream, body);
946946 try stream.writeAll(") ");
947 try self.writeSrc(stream, inst_data.src());
947 try self.writeSrcTok(stream, inst_data.src_tok);
948948 }
949949
950950 fn writePlNodeBin(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -954,7 +954,7 @@ const Writer = struct {
954954 try stream.writeAll(", ");
955955 try self.writeInstRef(stream, extra.rhs);
956956 try stream.writeAll(") ");
957 try self.writeSrc(stream, inst_data.src());
957 try self.writeSrcNode(stream, inst_data.src_node);
958958 }
959959
960960 fn writePlNodeMultiOp(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -967,7 +967,7 @@ const Writer = struct {
967967 try self.writeInstRef(stream, arg);
968968 }
969969 try stream.writeAll("}) ");
970 try self.writeSrc(stream, inst_data.src());
970 try self.writeSrcNode(stream, inst_data.src_node);
971971 }
972972
973973 fn writeArrayMul(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -979,7 +979,7 @@ const Writer = struct {
979979 try stream.writeAll(", ");
980980 try self.writeInstRef(stream, extra.rhs);
981981 try stream.writeAll(") ");
982 try self.writeSrc(stream, inst_data.src());
982 try self.writeSrcNode(stream, inst_data.src_node);
983983 }
984984
985985 fn writeElemValImm(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -994,7 +994,7 @@ const Writer = struct {
994994
995995 try self.writeInstRef(stream, extra.ptr);
996996 try stream.print(", {d}) ", .{extra.index});
997 try self.writeSrc(stream, inst_data.src());
997 try self.writeSrcNode(stream, inst_data.src_node);
998998 }
999999
10001000 fn writePlNodeExport(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -1006,7 +1006,7 @@ const Writer = struct {
10061006 try stream.print(", {p}, ", .{std.zig.fmtId(decl_name)});
10071007 try self.writeInstRef(stream, extra.options);
10081008 try stream.writeAll(") ");
1009 try self.writeSrc(stream, inst_data.src());
1009 try self.writeSrcNode(stream, inst_data.src_node);
10101010 }
10111011
10121012 fn writePlNodeExportValue(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -1017,7 +1017,7 @@ const Writer = struct {
10171017 try stream.writeAll(", ");
10181018 try self.writeInstRef(stream, extra.options);
10191019 try stream.writeAll(") ");
1020 try self.writeSrc(stream, inst_data.src());
1020 try self.writeSrcNode(stream, inst_data.src_node);
10211021 }
10221022
10231023 fn writeValidateArrayInitRefTy(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -1027,7 +1027,7 @@ const Writer = struct {
10271027 try self.writeInstRef(stream, extra.ptr_ty);
10281028 try stream.writeAll(", ");
10291029 try stream.print(", {}) ", .{extra.elem_count});
1030 try self.writeSrc(stream, inst_data.src());
1030 try self.writeSrcNode(stream, inst_data.src_node);
10311031 }
10321032
10331033 fn writeStructInit(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -1051,7 +1051,7 @@ const Writer = struct {
10511051 try stream.writeAll("]");
10521052 }
10531053 try stream.writeAll(") ");
1054 try self.writeSrc(stream, inst_data.src());
1054 try self.writeSrcNode(stream, inst_data.src_node);
10551055 }
10561056
10571057 fn writeCmpxchg(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {
......@@ -1110,7 +1110,7 @@ const Writer = struct {
11101110 try stream.writeAll(", ");
11111111 try self.writeInstRef(stream, extra.ordering);
11121112 try stream.writeAll(") ");
1113 try self.writeSrc(stream, inst_data.src());
1113 try self.writeSrcNode(stream, inst_data.src_node);
11141114 }
11151115
11161116 fn writeAtomicStore(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -1123,7 +1123,7 @@ const Writer = struct {
11231123 try stream.writeAll(", ");
11241124 try self.writeInstRef(stream, extra.ordering);
11251125 try stream.writeAll(") ");
1126 try self.writeSrc(stream, inst_data.src());
1126 try self.writeSrcNode(stream, inst_data.src_node);
11271127 }
11281128
11291129 fn writeAtomicRmw(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -1138,7 +1138,7 @@ const Writer = struct {
11381138 try stream.writeAll(", ");
11391139 try self.writeInstRef(stream, extra.ordering);
11401140 try stream.writeAll(") ");
1141 try self.writeSrc(stream, inst_data.src());
1141 try self.writeSrcNode(stream, inst_data.src_node);
11421142 }
11431143
11441144 fn writeStructInitAnon(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -1159,7 +1159,7 @@ const Writer = struct {
11591159 try stream.writeAll("]");
11601160 }
11611161 try stream.writeAll(") ");
1162 try self.writeSrc(stream, inst_data.src());
1162 try self.writeSrcNode(stream, inst_data.src_node);
11631163 }
11641164
11651165 fn writeStructInitFieldType(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -1168,7 +1168,7 @@ const Writer = struct {
11681168 try self.writeInstRef(stream, extra.container_type);
11691169 const field_name = self.code.nullTerminatedString(extra.name_start);
11701170 try stream.print(", {s}) ", .{field_name});
1171 try self.writeSrc(stream, inst_data.src());
1171 try self.writeSrcNode(stream, inst_data.src_node);
11721172 }
11731173
11741174 fn writeFieldTypeRef(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -1178,7 +1178,7 @@ const Writer = struct {
11781178 try stream.writeAll(", ");
11791179 try self.writeInstRef(stream, extra.field_name);
11801180 try stream.writeAll(") ");
1181 try self.writeSrc(stream, inst_data.src());
1181 try self.writeSrcNode(stream, inst_data.src_node);
11821182 }
11831183
11841184 fn writeNodeMultiOp(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {
......@@ -1202,7 +1202,7 @@ const Writer = struct {
12021202 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].inst_node;
12031203 try self.writeInstIndex(stream, inst_data.inst);
12041204 try stream.writeAll(") ");
1205 try self.writeSrc(stream, inst_data.src());
1205 try self.writeSrcNode(stream, inst_data.src_node);
12061206 }
12071207
12081208 fn writeAsm(
......@@ -1347,13 +1347,13 @@ const Writer = struct {
13471347 }
13481348
13491349 try stream.writeAll("]) ");
1350 try self.writeSrc(stream, inst_data.src());
1350 try self.writeSrcNode(stream, inst_data.src_node);
13511351 }
13521352
13531353 fn writeBlock(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
13541354 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
13551355 try self.writePlNodeBlockWithoutSrc(stream, inst);
1356 try self.writeSrc(stream, inst_data.src());
1356 try self.writeSrcNode(stream, inst_data.src_node);
13571357 }
13581358
13591359 fn writePlNodeBlockWithoutSrc(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -1375,7 +1375,7 @@ const Writer = struct {
13751375 try stream.writeAll(", ");
13761376 try self.writeBracedBody(stream, else_body);
13771377 try stream.writeAll(") ");
1378 try self.writeSrc(stream, inst_data.src());
1378 try self.writeSrcNode(stream, inst_data.src_node);
13791379 }
13801380
13811381 fn writeTry(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -1386,7 +1386,7 @@ const Writer = struct {
13861386 try stream.writeAll(", ");
13871387 try self.writeBracedBody(stream, body);
13881388 try stream.writeAll(") ");
1389 try self.writeSrc(stream, inst_data.src());
1389 try self.writeSrcNode(stream, inst_data.src_node);
13901390 }
13911391
13921392 fn writeStructDecl(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {
......@@ -1480,7 +1480,7 @@ const Writer = struct {
14801480 }
14811481
14821482 if (fields_len == 0) {
1483 try stream.writeAll("{}, {})");
1483 try stream.writeAll("{}, {}) ");
14841484 } else {
14851485 const bits_per_field = 4;
14861486 const fields_per_u32 = 32 / bits_per_field;
......@@ -1596,7 +1596,7 @@ const Writer = struct {
15961596
15971597 self.indent -= 2;
15981598 try stream.writeByteNTimes(' ', self.indent);
1599 try stream.writeAll("})");
1599 try stream.writeAll("}) ");
16001600 }
16011601 try self.writeSrcNode(stream, 0);
16021602 }
......@@ -1688,7 +1688,7 @@ const Writer = struct {
16881688 }
16891689
16901690 if (fields_len == 0) {
1691 try stream.writeAll("})");
1691 try stream.writeAll("}) ");
16921692 try self.writeSrcNode(stream, 0);
16931693 return;
16941694 }
......@@ -1762,7 +1762,7 @@ const Writer = struct {
17621762
17631763 self.indent -= 2;
17641764 try stream.writeByteNTimes(' ', self.indent);
1765 try stream.writeAll("})");
1765 try stream.writeAll("}) ");
17661766 try self.writeSrcNode(stream, 0);
17671767 }
17681768
......@@ -1855,7 +1855,7 @@ const Writer = struct {
18551855
18561856 try self.writeBracedDecl(stream, body);
18571857 if (fields_len == 0) {
1858 try stream.writeAll(", {})");
1858 try stream.writeAll(", {}) ");
18591859 } else {
18601860 try stream.writeAll(", {\n");
18611861
......@@ -1896,7 +1896,7 @@ const Writer = struct {
18961896 }
18971897 self.indent -= 2;
18981898 try stream.writeByteNTimes(' ', self.indent);
1899 try stream.writeAll("})");
1899 try stream.writeAll("}) ");
19001900 }
19011901 try self.writeSrcNode(stream, 0);
19021902 }
......@@ -1944,14 +1944,14 @@ const Writer = struct {
19441944 }
19451945
19461946 if (decls_len == 0) {
1947 try stream.writeAll("{})");
1947 try stream.writeAll("{}) ");
19481948 } else {
19491949 try stream.writeAll("{\n");
19501950 self.indent += 2;
19511951 try self.writeBody(stream, self.code.bodySlice(extra_index, decls_len));
19521952 self.indent -= 2;
19531953 try stream.writeByteNTimes(' ', self.indent);
1954 try stream.writeAll("})");
1954 try stream.writeAll("}) ");
19551955 }
19561956 try self.writeSrcNode(stream, 0);
19571957 }
......@@ -1982,7 +1982,7 @@ const Writer = struct {
19821982 try stream.writeByteNTimes(' ', self.indent);
19831983 try stream.writeAll("}) ");
19841984
1985 try self.writeSrc(stream, inst_data.src());
1985 try self.writeSrcNode(stream, inst_data.src_node);
19861986 }
19871987
19881988 fn writeSwitchBlockErrUnion(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -2119,7 +2119,7 @@ const Writer = struct {
21192119 self.indent -= 2;
21202120
21212121 try stream.writeAll(") ");
2122 try self.writeSrc(stream, inst_data.src());
2122 try self.writeSrcNode(stream, inst_data.src_node);
21232123 }
21242124
21252125 fn writeSwitchBlock(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -2249,7 +2249,7 @@ const Writer = struct {
22492249 self.indent -= 2;
22502250
22512251 try stream.writeAll(") ");
2252 try self.writeSrc(stream, inst_data.src());
2252 try self.writeSrcNode(stream, inst_data.src_node);
22532253 }
22542254
22552255 fn writePlNodeField(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -2258,7 +2258,7 @@ const Writer = struct {
22582258 const name = self.code.nullTerminatedString(extra.field_name_start);
22592259 try self.writeInstRef(stream, extra.lhs);
22602260 try stream.print(", \"{}\") ", .{std.zig.fmtEscapes(name)});
2261 try self.writeSrc(stream, inst_data.src());
2261 try self.writeSrcNode(stream, inst_data.src_node);
22622262 }
22632263
22642264 fn writePlNodeFieldNamed(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -2268,7 +2268,7 @@ const Writer = struct {
22682268 try stream.writeAll(", ");
22692269 try self.writeInstRef(stream, extra.field_name);
22702270 try stream.writeAll(") ");
2271 try self.writeSrc(stream, inst_data.src());
2271 try self.writeSrcNode(stream, inst_data.src_node);
22722272 }
22732273
22742274 fn writeAs(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -2278,7 +2278,7 @@ const Writer = struct {
22782278 try stream.writeAll(", ");
22792279 try self.writeInstRef(stream, extra.operand);
22802280 try stream.writeAll(") ");
2281 try self.writeSrc(stream, inst_data.src());
2281 try self.writeSrcNode(stream, inst_data.src_node);
22822282 }
22832283
22842284 fn writeNode(
......@@ -2300,7 +2300,7 @@ const Writer = struct {
23002300 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str_tok;
23012301 const str = inst_data.get(self.code);
23022302 try stream.print("\"{}\") ", .{std.zig.fmtEscapes(str)});
2303 try self.writeSrc(stream, inst_data.src());
2303 try self.writeSrcTok(stream, inst_data.src_tok);
23042304 }
23052305
23062306 fn writeStrOp(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -2317,7 +2317,6 @@ const Writer = struct {
23172317 inferred_error_set: bool,
23182318 ) !void {
23192319 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
2320 const src = inst_data.src();
23212320 const extra = self.code.extraData(Zir.Inst.Func, inst_data.payload_index);
23222321
23232322 var extra_index = extra.end;
......@@ -2364,7 +2363,7 @@ const Writer = struct {
23642363 ret_ty_body,
23652364
23662365 body,
2367 src,
2366 inst_data.src_node,
23682367 src_locs,
23692368 0,
23702369 );
......@@ -2373,7 +2372,6 @@ const Writer = struct {
23732372 fn writeFuncFancy(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
23742373 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
23752374 const extra = self.code.extraData(Zir.Inst.FuncFancy, inst_data.payload_index);
2376 const src = inst_data.src();
23772375
23782376 var extra_index: usize = extra.end;
23792377 var align_ref: Zir.Inst.Ref = .none;
......@@ -2470,7 +2468,7 @@ const Writer = struct {
24702468 ret_ty_ref,
24712469 ret_ty_body,
24722470 body,
2473 src,
2471 inst_data.src_node,
24742472 src_locs,
24752473 noalias_bits,
24762474 );
......@@ -2551,7 +2549,7 @@ const Writer = struct {
25512549 try stream.writeAll(", ");
25522550 try self.writeBracedBody(stream, body);
25532551 try stream.writeAll(") ");
2554 try self.writeSrc(stream, inst_data.src());
2552 try self.writeSrcNode(stream, inst_data.src_node);
25552553 }
25562554
25572555 fn writeIntType(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -2561,7 +2559,7 @@ const Writer = struct {
25612559 .unsigned => 'u',
25622560 };
25632561 try stream.print("{c}{d}) ", .{ prefix, int_type.bit_count });
2564 try self.writeSrc(stream, int_type.src());
2562 try self.writeSrcNode(stream, int_type.src_node);
25652563 }
25662564
25672565 fn writeSaveErrRetIndex(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -2579,7 +2577,7 @@ const Writer = struct {
25792577 try self.writeInstRef(stream, extra.operand);
25802578
25812579 try stream.writeAll(") ");
2582 try self.writeSrc(stream, extra.src());
2580 try self.writeSrcNode(stream, extra.src_node);
25832581 }
25842582
25852583 fn writeBreak(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -2605,7 +2603,7 @@ const Writer = struct {
26052603 try self.writeInstRef(stream, arg);
26062604 }
26072605 try stream.writeAll("}) ");
2608 try self.writeSrc(stream, inst_data.src());
2606 try self.writeSrcNode(stream, inst_data.src_node);
26092607 }
26102608
26112609 fn writeArrayInitAnon(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -2620,7 +2618,7 @@ const Writer = struct {
26202618 try self.writeInstRef(stream, arg);
26212619 }
26222620 try stream.writeAll("}) ");
2623 try self.writeSrc(stream, inst_data.src());
2621 try self.writeSrcNode(stream, inst_data.src_node);
26242622 }
26252623
26262624 fn writeArrayInitSent(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -2640,13 +2638,13 @@ const Writer = struct {
26402638 try self.writeInstRef(stream, elem);
26412639 }
26422640 try stream.writeAll("}) ");
2643 try self.writeSrc(stream, inst_data.src());
2641 try self.writeSrcNode(stream, inst_data.src_node);
26442642 }
26452643
26462644 fn writeUnreachable(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
26472645 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].@"unreachable";
26482646 try stream.writeAll(") ");
2649 try self.writeSrc(stream, inst_data.src());
2647 try self.writeSrcNode(stream, inst_data.src_node);
26502648 }
26512649
26522650 fn writeFuncCommon(
......@@ -2667,7 +2665,7 @@ const Writer = struct {
26672665 ret_ty_ref: Zir.Inst.Ref,
26682666 ret_ty_body: []const Zir.Inst.Index,
26692667 body: []const Zir.Inst.Index,
2670 src: LazySrcLoc,
2668 src_node: i32,
26712669 src_locs: Zir.Inst.Func.SrcLocs,
26722670 noalias_bits: u32,
26732671 ) !void {
......@@ -2694,7 +2692,7 @@ const Writer = struct {
26942692 src_locs.rbrace_line + 1, @as(u16, @truncate(src_locs.columns >> 16)) + 1,
26952693 });
26962694 }
2697 try self.writeSrc(stream, src);
2695 try self.writeSrcNode(stream, src_node);
26982696 }
26992697
27002698 fn writeDbgStmt(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
......@@ -2878,11 +2876,12 @@ const Writer = struct {
28782876 }
28792877 }
28802878
2881 fn writeSrcNode(self: *Writer, stream: anytype, src_node: ?i32) !void {
2882 const node_offset = src_node orelse return;
2883 const src = LazySrcLoc.nodeOffset(node_offset);
2884 try stream.writeAll(" ");
2885 return self.writeSrc(stream, src);
2879 fn writeSrcNode(self: *Writer, stream: anytype, src_node: i32) !void {
2880 return self.writeSrc(stream, LazySrcLoc.nodeOffset(src_node));
2881 }
2882
2883 fn writeSrcTok(self: *Writer, stream: anytype, src_tok: u32) !void {
2884 return self.writeSrc(stream, .{ .token_offset = src_tok });
28862885 }
28872886
28882887 fn writeBracedDecl(self: *Writer, stream: anytype, body: []const Zir.Inst.Index) !void {