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![...@@ -350,379 +350,6 @@ pub fn serializeCpuAlloc(ally: Allocator, cpu: std.Target.Cpu) Allocator.Error![
350 return buffer.toOwnedSlice();350 return buffer.toOwnedSlice();
351}351}
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
726const std = @import("std.zig");353const std = @import("std.zig");
727const tokenizer = @import("zig/tokenizer.zig");354const tokenizer = @import("zig/tokenizer.zig");
728const assert = std.debug.assert;355const assert = std.debug.assert;
lib/std/zig/Zir.zig-61
...@@ -20,7 +20,6 @@ const BigIntMutable = std.math.big.int.Mutable;...@@ -20,7 +20,6 @@ const BigIntMutable = std.math.big.int.Mutable;
20const Ast = std.zig.Ast;20const Ast = std.zig.Ast;
2121
22const Zir = @This();22const Zir = @This();
23const LazySrcLoc = std.zig.LazySrcLoc;
2423
25instructions: std.MultiArrayList(Inst).Slice,24instructions: std.MultiArrayList(Inst).Slice,
26/// In order to store references to strings in fewer bytes, we copy all25/// In order to store references to strings in fewer bytes, we copy all
...@@ -2221,10 +2220,6 @@ pub const Inst = struct {...@@ -2221,10 +2220,6 @@ pub const Inst = struct {
2221 src_node: i32,2220 src_node: i32,
2222 /// The meaning of this operand depends on the corresponding `Tag`.2221 /// The meaning of this operand depends on the corresponding `Tag`.
2223 operand: Ref,2222 operand: Ref,
2224
2225 pub fn src(self: @This()) LazySrcLoc {
2226 return LazySrcLoc.nodeOffset(self.src_node);
2227 }
2228 },2223 },
2229 /// Used for unary operators, with a token source location.2224 /// Used for unary operators, with a token source location.
2230 un_tok: struct {2225 un_tok: struct {
...@@ -2232,10 +2227,6 @@ pub const Inst = struct {...@@ -2232,10 +2227,6 @@ pub const Inst = struct {
2232 src_tok: Ast.TokenIndex,2227 src_tok: Ast.TokenIndex,
2233 /// The meaning of this operand depends on the corresponding `Tag`.2228 /// The meaning of this operand depends on the corresponding `Tag`.
2234 operand: Ref,2229 operand: Ref,
2235
2236 pub fn src(self: @This()) LazySrcLoc {
2237 return .{ .token_offset = self.src_tok };
2238 }
2239 },2230 },
2240 pl_node: struct {2231 pl_node: struct {
2241 /// Offset from Decl AST node index.2232 /// Offset from Decl AST node index.
...@@ -2244,10 +2235,6 @@ pub const Inst = struct {...@@ -2244,10 +2235,6 @@ pub const Inst = struct {
2244 /// index into extra.2235 /// index into extra.
2245 /// `Tag` determines what lives there.2236 /// `Tag` determines what lives there.
2246 payload_index: u32,2237 payload_index: u32,
2247
2248 pub fn src(self: @This()) LazySrcLoc {
2249 return LazySrcLoc.nodeOffset(self.src_node);
2250 }
2251 },2238 },
2252 pl_tok: struct {2239 pl_tok: struct {
2253 /// Offset from Decl AST token index.2240 /// Offset from Decl AST token index.
...@@ -2255,10 +2242,6 @@ pub const Inst = struct {...@@ -2255,10 +2242,6 @@ pub const Inst = struct {
2255 /// index into extra.2242 /// index into extra.
2256 /// `Tag` determines what lives there.2243 /// `Tag` determines what lives there.
2257 payload_index: u32,2244 payload_index: u32,
2258
2259 pub fn src(self: @This()) LazySrcLoc {
2260 return .{ .token_offset = self.src_tok };
2261 }
2262 },2245 },
2263 bin: Bin,2246 bin: Bin,
2264 /// For strings which may contain null bytes.2247 /// For strings which may contain null bytes.
...@@ -2281,10 +2264,6 @@ pub const Inst = struct {...@@ -2281,10 +2264,6 @@ pub const Inst = struct {
2281 pub fn get(self: @This(), code: Zir) [:0]const u8 {2264 pub fn get(self: @This(), code: Zir) [:0]const u8 {
2282 return code.nullTerminatedString(self.start);2265 return code.nullTerminatedString(self.start);
2283 }2266 }
2284
2285 pub fn src(self: @This()) LazySrcLoc {
2286 return .{ .token_offset = self.src_tok };
2287 }
2288 },2267 },
2289 /// Offset from Decl AST token index.2268 /// Offset from Decl AST token index.
2290 tok: Ast.TokenIndex,2269 tok: Ast.TokenIndex,
...@@ -2313,19 +2292,11 @@ pub const Inst = struct {...@@ -2313,19 +2292,11 @@ pub const Inst = struct {
2313 src_node: i32,2292 src_node: i32,
2314 signedness: std.builtin.Signedness,2293 signedness: std.builtin.Signedness,
2315 bit_count: u16,2294 bit_count: u16,
2316
2317 pub fn src(self: @This()) LazySrcLoc {
2318 return LazySrcLoc.nodeOffset(self.src_node);
2319 }
2320 },2295 },
2321 @"unreachable": struct {2296 @"unreachable": struct {
2322 /// Offset from Decl AST node index.2297 /// Offset from Decl AST node index.
2323 /// `Tag` determines which kind of AST node this points to.2298 /// `Tag` determines which kind of AST node this points to.
2324 src_node: i32,2299 src_node: i32,
2325
2326 pub fn src(self: @This()) LazySrcLoc {
2327 return LazySrcLoc.nodeOffset(self.src_node);
2328 }
2329 },2300 },
2330 @"break": struct {2301 @"break": struct {
2331 operand: Ref,2302 operand: Ref,
...@@ -2339,10 +2310,6 @@ pub const Inst = struct {...@@ -2339,10 +2310,6 @@ pub const Inst = struct {
2339 src_node: i32,2310 src_node: i32,
2340 /// The meaning of this operand depends on the corresponding `Tag`.2311 /// The meaning of this operand depends on the corresponding `Tag`.
2341 inst: Index,2312 inst: Index,
2342
2343 pub fn src(self: @This()) LazySrcLoc {
2344 return LazySrcLoc.nodeOffset(self.src_node);
2345 }
2346 },2313 },
2347 str_op: struct {2314 str_op: struct {
2348 /// Offset into `string_bytes`. Null-terminated.2315 /// Offset into `string_bytes`. Null-terminated.
...@@ -2375,10 +2342,6 @@ pub const Inst = struct {...@@ -2375,10 +2342,6 @@ pub const Inst = struct {
2375 src_node: Ast.Node.Index,2342 src_node: Ast.Node.Index,
2376 /// index into extra to a `Declaration` payload.2343 /// index into extra to a `Declaration` payload.
2377 payload_index: u32,2344 payload_index: u32,
2378
2379 pub fn src(self: @This()) LazySrcLoc {
2380 return .{ .node_abs = self.src_node };
2381 }
2382 },2345 },
23832346
2384 // Make sure we don't accidentally add a field to make this union2347 // Make sure we don't accidentally add a field to make this union
...@@ -3032,10 +2995,6 @@ pub const Inst = struct {...@@ -3032,10 +2995,6 @@ pub const Inst = struct {
3032 /// This node provides a new absolute baseline node for all instructions within this struct.2995 /// This node provides a new absolute baseline node for all instructions within this struct.
3033 src_node: Ast.Node.Index,2996 src_node: Ast.Node.Index,
30342997
3035 pub fn src(self: StructDecl) LazySrcLoc {
3036 return .{ .node_abs = self.src_node };
3037 }
3038
3039 pub const Small = packed struct {2998 pub const Small = packed struct {
3040 has_captures_len: bool,2999 has_captures_len: bool,
3041 has_fields_len: bool,3000 has_fields_len: bool,
...@@ -3165,10 +3124,6 @@ pub const Inst = struct {...@@ -3165,10 +3124,6 @@ pub const Inst = struct {
3165 /// This node provides a new absolute baseline node for all instructions within this struct.3124 /// This node provides a new absolute baseline node for all instructions within this struct.
3166 src_node: Ast.Node.Index,3125 src_node: Ast.Node.Index,
31673126
3168 pub fn src(self: EnumDecl) LazySrcLoc {
3169 return .{ .node_abs = self.src_node };
3170 }
3171
3172 pub const Small = packed struct {3127 pub const Small = packed struct {
3173 has_tag_type: bool,3128 has_tag_type: bool,
3174 has_captures_len: bool,3129 has_captures_len: bool,
...@@ -3214,10 +3169,6 @@ pub const Inst = struct {...@@ -3214,10 +3169,6 @@ pub const Inst = struct {
3214 /// This node provides a new absolute baseline node for all instructions within this struct.3169 /// This node provides a new absolute baseline node for all instructions within this struct.
3215 src_node: Ast.Node.Index,3170 src_node: Ast.Node.Index,
32163171
3217 pub fn src(self: UnionDecl) LazySrcLoc {
3218 return .{ .node_abs = self.src_node };
3219 }
3220
3221 pub const Small = packed struct {3172 pub const Small = packed struct {
3222 has_tag_type: bool,3173 has_tag_type: bool,
3223 has_captures_len: bool,3174 has_captures_len: bool,
...@@ -3247,10 +3198,6 @@ pub const Inst = struct {...@@ -3247,10 +3198,6 @@ pub const Inst = struct {
3247 /// This node provides a new absolute baseline node for all instructions within this struct.3198 /// This node provides a new absolute baseline node for all instructions within this struct.
3248 src_node: Ast.Node.Index,3199 src_node: Ast.Node.Index,
32493200
3250 pub fn src(self: OpaqueDecl) LazySrcLoc {
3251 return .{ .node_abs = self.src_node };
3252 }
3253
3254 pub const Small = packed struct {3201 pub const Small = packed struct {
3255 has_captures_len: bool,3202 has_captures_len: bool,
3256 has_decls_len: bool,3203 has_decls_len: bool,
...@@ -3367,10 +3314,6 @@ pub const Inst = struct {...@@ -3367,10 +3314,6 @@ pub const Inst = struct {
3367 parent_ptr_type: Ref,3314 parent_ptr_type: Ref,
3368 field_name: Ref,3315 field_name: Ref,
3369 field_ptr: Ref,3316 field_ptr: Ref,
3370
3371 pub fn src(self: FieldParentPtr) LazySrcLoc {
3372 return LazySrcLoc.nodeOffset(self.src_node);
3373 }
3374 };3317 };
33753318
3376 pub const Shuffle = struct {3319 pub const Shuffle = struct {
...@@ -3520,10 +3463,6 @@ pub const Inst = struct {...@@ -3520,10 +3463,6 @@ pub const Inst = struct {
3520 block: Ref,3463 block: Ref,
3521 /// If `.none`, restore unconditionally.3464 /// If `.none`, restore unconditionally.
3522 operand: Ref,3465 operand: Ref,
3523
3524 pub fn src(self: RestoreErrRetIndex) LazySrcLoc {
3525 return LazySrcLoc.nodeOffset(self.src_node);
3526 }
3527 };3466 };
3528};3467};
35293468
src/InternPool.zig+21-2
...@@ -391,8 +391,27 @@ pub const RuntimeIndex = enum(u32) {...@@ -391,8 +391,27 @@ pub const RuntimeIndex = enum(u32) {
391391
392pub const ComptimeAllocIndex = enum(u32) { _ };392pub const ComptimeAllocIndex = enum(u32) { _ };
393393
394pub const DeclIndex = std.zig.DeclIndex;394pub const DeclIndex = enum(u32) {
395pub const OptionalDeclIndex = std.zig.OptionalDeclIndex;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
397pub const NamespaceIndex = enum(u32) {416pub const NamespaceIndex = enum(u32) {
398 _,417 _,
src/Module.zig+351-1
...@@ -13,7 +13,6 @@ const BigIntConst = std.math.big.int.Const;...@@ -13,7 +13,6 @@ const BigIntConst = std.math.big.int.Const;
13const BigIntMutable = std.math.big.int.Mutable;13const BigIntMutable = std.math.big.int.Mutable;
14const Target = std.Target;14const Target = std.Target;
15const Ast = std.zig.Ast;15const Ast = std.zig.Ast;
16const LazySrcLoc = std.zig.LazySrcLoc;
1716
18/// Deprecated, use `Zcu`.17/// Deprecated, use `Zcu`.
19const Module = Zcu;18const Module = Zcu;
...@@ -1905,6 +1904,357 @@ pub const SrcLoc = struct {...@@ -1905,6 +1904,357 @@ pub const SrcLoc = struct {
1905 }1904 }
1906};1905};
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
1908pub const SemaError = error{ OutOfMemory, AnalysisFail };2258pub const SemaError = error{ OutOfMemory, AnalysisFail };
1909pub const CompileError = error{2259pub const CompileError = error{
1910 OutOfMemory,2260 OutOfMemory,
src/Sema.zig+183-165
...@@ -182,7 +182,7 @@ const Namespace = Module.Namespace;...@@ -182,7 +182,7 @@ const Namespace = Module.Namespace;
182const CompileError = Module.CompileError;182const CompileError = Module.CompileError;
183const SemaError = Module.SemaError;183const SemaError = Module.SemaError;
184const Decl = Module.Decl;184const Decl = Module.Decl;
185const LazySrcLoc = std.zig.LazySrcLoc;185const LazySrcLoc = Zcu.LazySrcLoc;
186const RangeSet = @import("RangeSet.zig");186const RangeSet = @import("RangeSet.zig");
187const target_util = @import("target.zig");187const target_util = @import("target.zig");
188const Package = @import("Package.zig");188const Package = @import("Package.zig");
...@@ -395,6 +395,18 @@ pub const Block = struct {...@@ -395,6 +395,18 @@ pub const Block = struct {
395 /// `block` in order for codegen to match lexical scoping for debug vars.395 /// `block` in order for codegen to match lexical scoping for debug vars.
396 need_debug_scope: ?*bool = null,396 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
398 const ComptimeReason = union(enum) {410 const ComptimeReason = union(enum) {
399 c_import: struct {411 c_import: struct {
400 block: *Block,412 block: *Block,
...@@ -1449,7 +1461,7 @@ fn analyzeBodyInner(...@@ -1449,7 +1461,7 @@ fn analyzeBodyInner(
1449 .check_comptime_control_flow => {1461 .check_comptime_control_flow => {
1450 if (!block.is_comptime) {1462 if (!block.is_comptime) {
1451 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;1463 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);
1453 const inline_block = inst_data.operand.toIndex().?;1465 const inline_block = inst_data.operand.toIndex().?;
14541466
1455 var check_block = block;1467 var check_block = block;
...@@ -1482,13 +1494,13 @@ fn analyzeBodyInner(...@@ -1482,13 +1494,13 @@ fn analyzeBodyInner(
1482 },1494 },
1483 .restore_err_ret_index_unconditional => {1495 .restore_err_ret_index_unconditional => {
1484 const un_node = datas[@intFromEnum(inst)].un_node;1496 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);
1486 i += 1;1498 i += 1;
1487 continue;1499 continue;
1488 },1500 },
1489 .restore_err_ret_index_fn_entry => {1501 .restore_err_ret_index_fn_entry => {
1490 const un_node = datas[@intFromEnum(inst)].un_node;1502 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);
1492 i += 1;1504 i += 1;
1493 continue;1505 continue;
1494 },1506 },
...@@ -1667,7 +1679,7 @@ fn analyzeBodyInner(...@@ -1667,7 +1679,7 @@ fn analyzeBodyInner(
1667 try labeled_block.block.instructions.appendSlice(gpa, block.instructions.items[block_index..]);1679 try labeled_block.block.instructions.appendSlice(gpa, block.instructions.items[block_index..]);
1668 block.instructions.items.len = block_index;1680 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);
1671 {1683 {
1672 // Destroy the ad-hoc block entry so that it does not interfere with1684 // Destroy the ad-hoc block entry so that it does not interfere with
1673 // the next iteration of comptime control flow, if any.1685 // the next iteration of comptime control flow, if any.
...@@ -1736,7 +1748,7 @@ fn analyzeBodyInner(...@@ -1736,7 +1748,7 @@ fn analyzeBodyInner(
1736 .@"try" => blk: {1748 .@"try" => blk: {
1737 if (!block.is_comptime) break :blk try sema.zirTry(block, inst);1749 if (!block.is_comptime) break :blk try sema.zirTry(block, inst);
1738 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;1750 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);
1740 const operand_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };1752 const operand_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
1741 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);1753 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);
1742 const inline_body = sema.code.bodySlice(extra.end, extra.data.body_len);1754 const inline_body = sema.code.bodySlice(extra.end, extra.data.body_len);
...@@ -1762,7 +1774,7 @@ fn analyzeBodyInner(...@@ -1762,7 +1774,7 @@ fn analyzeBodyInner(
1762 .try_ptr => blk: {1774 .try_ptr => blk: {
1763 if (!block.is_comptime) break :blk try sema.zirTryPtr(block, inst);1775 if (!block.is_comptime) break :blk try sema.zirTryPtr(block, inst);
1764 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;1776 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);
1766 const operand_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };1778 const operand_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
1767 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);1779 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);
1768 const inline_body = sema.code.bodySlice(extra.end, extra.data.body_len);1780 const inline_body = sema.code.bodySlice(extra.end, extra.data.body_len);
...@@ -1929,7 +1941,7 @@ fn resolveDestType(...@@ -1929,7 +1941,7 @@ fn resolveDestType(
1929 const msg = msg: {1941 const msg = msg: {
1930 const msg = try sema.errMsg(block, src, "{s} must have a known result type", .{builtin_name});1942 const msg = try sema.errMsg(block, src, "{s} must have a known result type", .{builtin_name});
1931 errdefer msg.destroy(sema.gpa);1943 errdefer msg.destroy(sema.gpa);
1932 switch (sema.genericPoisonReason(zir_ref)) {1944 switch (sema.genericPoisonReason(block, zir_ref)) {
1933 .anytype_param => |call_src| try sema.errNote(block, call_src, msg, "result type is unknown due to anytype parameter", .{}),1945 .anytype_param => |call_src| try sema.errNote(block, call_src, msg, "result type is unknown due to anytype parameter", .{}),
1934 .anyopaque_ptr => |ptr_src| try sema.errNote(block, ptr_src, msg, "result type is unknown due to opaque pointer type", .{}),1946 .anyopaque_ptr => |ptr_src| try sema.errNote(block, ptr_src, msg, "result type is unknown due to opaque pointer type", .{}),
1935 .unknown => {},1947 .unknown => {},
...@@ -1963,7 +1975,7 @@ const GenericPoisonReason = union(enum) {...@@ -1963,7 +1975,7 @@ const GenericPoisonReason = union(enum) {
19631975
1964/// Backtracks through ZIR instructions to determine the reason a generic poison1976/// Backtracks through ZIR instructions to determine the reason a generic poison
1965/// type was created. Used for error reporting.1977/// 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 {
1967 var cur = ref;1979 var cur = ref;
1968 while (true) {1980 while (true) {
1969 const inst = cur.toIndex() orelse return .unknown;1981 const inst = cur.toIndex() orelse return .unknown;
...@@ -1999,7 +2011,7 @@ fn genericPoisonReason(sema: *Sema, ref: Zir.Inst.Ref) GenericPoisonReason {...@@ -1999,7 +2011,7 @@ fn genericPoisonReason(sema: *Sema, ref: Zir.Inst.Ref) GenericPoisonReason {
1999 cur = un_node.operand;2011 cur = un_node.operand;
2000 } else {2012 } else {
2001 // This must be an anyopaque pointer!2013 // This must be an anyopaque pointer!
2002 return .{ .anyopaque_ptr = un_node.src() };2014 return .{ .anyopaque_ptr = block.nodeOffset(un_node.src_node) };
2003 }2015 }
2004 },2016 },
2005 .call, .field_call => {2017 .call, .field_call => {
...@@ -2007,7 +2019,7 @@ fn genericPoisonReason(sema: *Sema, ref: Zir.Inst.Ref) GenericPoisonReason {...@@ -2007,7 +2019,7 @@ fn genericPoisonReason(sema: *Sema, ref: Zir.Inst.Ref) GenericPoisonReason {
2007 // evaluating an `anytype` function parameter.2019 // evaluating an `anytype` function parameter.
2008 // TODO: better source location - function decl rather than call2020 // TODO: better source location - function decl rather than call
2009 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;2021 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) };
2011 },2023 },
2012 else => return .unknown,2024 else => return .unknown,
2013 }2025 }
...@@ -2776,7 +2788,7 @@ fn zirStructDecl(...@@ -2776,7 +2788,7 @@ fn zirStructDecl(
2776 const ip = &mod.intern_pool;2788 const ip = &mod.intern_pool;
2777 const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small);2789 const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small);
2778 const extra = sema.code.extraData(Zir.Inst.StructDecl, extended.operand);2790 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 };
2780 var extra_index = extra.end;2792 var extra_index = extra.end;
27812793
2782 const captures_len = if (small.has_captures_len) blk: {2794 const captures_len = if (small.has_captures_len) blk: {
...@@ -2991,7 +3003,7 @@ fn zirEnumDecl(...@@ -2991,7 +3003,7 @@ fn zirEnumDecl(
2991 const extra = sema.code.extraData(Zir.Inst.EnumDecl, extended.operand);3003 const extra = sema.code.extraData(Zir.Inst.EnumDecl, extended.operand);
2992 var extra_index: usize = extra.end;3004 var extra_index: usize = extra.end;
29933005
2994 const src = extra.data.src();3006 const src: LazySrcLoc = .{ .node_abs = extra.data.src_node };
29953007
2996 const tag_type_ref = if (small.has_tag_type) blk: {3008 const tag_type_ref = if (small.has_tag_type) blk: {
2997 const tag_type_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);3009 const tag_type_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
...@@ -3282,7 +3294,7 @@ fn zirUnionDecl(...@@ -3282,7 +3294,7 @@ fn zirUnionDecl(
3282 const extra = sema.code.extraData(Zir.Inst.UnionDecl, extended.operand);3294 const extra = sema.code.extraData(Zir.Inst.UnionDecl, extended.operand);
3283 var extra_index: usize = extra.end;3295 var extra_index: usize = extra.end;
32843296
3285 const src = extra.data.src();3297 const src: LazySrcLoc = .{ .node_abs = extra.data.src_node };
32863298
3287 extra_index += @intFromBool(small.has_tag_type);3299 extra_index += @intFromBool(small.has_tag_type);
3288 const captures_len = if (small.has_captures_len) blk: {3300 const captures_len = if (small.has_captures_len) blk: {
...@@ -3397,7 +3409,7 @@ fn zirOpaqueDecl(...@@ -3397,7 +3409,7 @@ fn zirOpaqueDecl(
3397 const extra = sema.code.extraData(Zir.Inst.OpaqueDecl, extended.operand);3409 const extra = sema.code.extraData(Zir.Inst.OpaqueDecl, extended.operand);
3398 var extra_index: usize = extra.end;3410 var extra_index: usize = extra.end;
33993411
3400 const src = extra.data.src();3412 const src: LazySrcLoc = .{ .node_abs = extra.data.src_node };
34013413
3402 const captures_len = if (small.has_captures_len) blk: {3414 const captures_len = if (small.has_captures_len) blk: {
3403 const captures_len = sema.code.extra[extra_index];3415 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...@@ -3528,7 +3540,7 @@ fn zirRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
35283540
3529 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok;3541 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok;
3530 const operand = try sema.resolveInst(inst_data.operand);3542 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);
3532}3544}
35333545
3534fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {3546fn 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...@@ -3537,7 +3549,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile
35373549
3538 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;3550 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
3539 const operand = try sema.resolveInst(inst_data.operand);3551 const operand = try sema.resolveInst(inst_data.operand);
3540 const src = inst_data.src();3552 const src = block.nodeOffset(inst_data.src_node);
35413553
3542 return sema.ensureResultUsed(block, sema.typeOf(operand), src);3554 return sema.ensureResultUsed(block, sema.typeOf(operand), src);
3543}3555}
...@@ -3581,7 +3593,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com...@@ -3581,7 +3593,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
3581 const mod = sema.mod;3593 const mod = sema.mod;
3582 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;3594 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
3583 const operand = try sema.resolveInst(inst_data.operand);3595 const operand = try sema.resolveInst(inst_data.operand);
3584 const src = inst_data.src();3596 const src = block.nodeOffset(inst_data.src_node);
3585 const operand_ty = sema.typeOf(operand);3597 const operand_ty = sema.typeOf(operand);
3586 switch (operand_ty.zigTypeTag(mod)) {3598 switch (operand_ty.zigTypeTag(mod)) {
3587 .ErrorSet => return sema.fail(block, src, "error set is discarded", .{}),3599 .ErrorSet => return sema.fail(block, src, "error set is discarded", .{}),
...@@ -3604,7 +3616,7 @@ fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index...@@ -3604,7 +3616,7 @@ fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index
36043616
3605 const mod = sema.mod;3617 const mod = sema.mod;
3606 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;3618 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);
3608 const operand = try sema.resolveInst(inst_data.operand);3620 const operand = try sema.resolveInst(inst_data.operand);
3609 const operand_ty = sema.typeOf(operand);3621 const operand_ty = sema.typeOf(operand);
3610 const err_union_ty = if (operand_ty.zigTypeTag(mod) == .Pointer)3622 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...@@ -3629,7 +3641,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
3629 defer tracy.end();3641 defer tracy.end();
36303642
3631 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;3643 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);
3633 const object = try sema.resolveInst(inst_data.operand);3645 const object = try sema.resolveInst(inst_data.operand);
36343646
3635 return indexablePtrLen(sema, block, src, object);3647 return indexablePtrLen(sema, block, src, object);
...@@ -4223,7 +4235,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com...@@ -4223,7 +4235,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
4223 const mod = sema.mod;4235 const mod = sema.mod;
4224 const gpa = sema.gpa;4236 const gpa = sema.gpa;
4225 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;4237 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);
4227 const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node };4239 const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node };
4228 const ptr = try sema.resolveInst(inst_data.operand);4240 const ptr = try sema.resolveInst(inst_data.operand);
4229 const ptr_inst = ptr.toIndex().?;4241 const ptr_inst = ptr.toIndex().?;
...@@ -4364,7 +4376,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -4364,7 +4376,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
4364 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;4376 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
4365 const extra = sema.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index);4377 const extra = sema.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index);
4366 const args = sema.code.refSlice(extra.end, extra.data.operands_len);4378 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
4369 var len: Air.Inst.Ref = .none;4381 var len: Air.Inst.Ref = .none;
4370 var len_val: ?Value = null;4382 var len_val: ?Value = null;
...@@ -4507,13 +4519,13 @@ fn optEuBasePtrInit(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, src: LazySrcL...@@ -4507,13 +4519,13 @@ fn optEuBasePtrInit(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, src: LazySrcL
4507fn zirOptEuBasePtrInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {4519fn zirOptEuBasePtrInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4508 const un_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;4520 const un_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
4509 const ptr = try sema.resolveInst(un_node.operand);4521 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));
4511}4523}
45124524
4513fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {4525fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4514 const mod = sema.mod;4526 const mod = sema.mod;
4515 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;4527 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);
4517 const extra = sema.code.extraData(Zir.Inst.Bin, pl_node.payload_index).data;4529 const extra = sema.code.extraData(Zir.Inst.Bin, pl_node.payload_index).data;
4518 const uncoerced_val = try sema.resolveInst(extra.rhs);4530 const uncoerced_val = try sema.resolveInst(extra.rhs);
4519 const maybe_wrapped_ptr_ty = sema.resolveType(block, .unneeded, extra.lhs) catch |err| switch (err) {4531 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...@@ -4564,7 +4576,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
4564fn zirValidateRefTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {4576fn zirValidateRefTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
4565 const mod = sema.mod;4577 const mod = sema.mod;
4566 const un_tok = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok;4578 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);
4568 // In case of GenericPoison, we don't actually have a type, so this will be4580 // In case of GenericPoison, we don't actually have a type, so this will be
4569 // treated as an untyped address-of operator.4581 // treated as an untyped address-of operator.
4570 const operand_air_inst = sema.resolveInst(un_tok.operand) catch |err| switch (err) {4582 const operand_air_inst = sema.resolveInst(un_tok.operand) catch |err| switch (err) {
...@@ -4593,7 +4605,7 @@ fn zirValidateArrayInitRefTy(...@@ -4593,7 +4605,7 @@ fn zirValidateArrayInitRefTy(
4593) CompileError!Air.Inst.Ref {4605) CompileError!Air.Inst.Ref {
4594 const mod = sema.mod;4606 const mod = sema.mod;
4595 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;4607 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);
4597 const extra = sema.code.extraData(Zir.Inst.ArrayInitRefTy, pl_node.payload_index).data;4609 const extra = sema.code.extraData(Zir.Inst.ArrayInitRefTy, pl_node.payload_index).data;
4598 const maybe_wrapped_ptr_ty = sema.resolveType(block, .unneeded, extra.ptr_ty) catch |err| switch (err) {4610 const maybe_wrapped_ptr_ty = sema.resolveType(block, .unneeded, extra.ptr_ty) catch |err| switch (err) {
4599 error.GenericPoison => return .generic_poison_type,4611 error.GenericPoison => return .generic_poison_type,
...@@ -4635,7 +4647,7 @@ fn zirValidateArrayInitTy(...@@ -4635,7 +4647,7 @@ fn zirValidateArrayInitTy(
4635) CompileError!void {4647) CompileError!void {
4636 const mod = sema.mod;4648 const mod = sema.mod;
4637 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;4649 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);
4639 const ty_src: LazySrcLoc = if (is_result_ty) src else .{ .node_offset_init_ty = inst_data.src_node };4651 const ty_src: LazySrcLoc = if (is_result_ty) src else .{ .node_offset_init_ty = inst_data.src_node };
4640 const extra = sema.code.extraData(Zir.Inst.ArrayInit, inst_data.payload_index).data;4652 const extra = sema.code.extraData(Zir.Inst.ArrayInit, inst_data.payload_index).data;
4641 const ty = sema.resolveType(block, ty_src, extra.ty) catch |err| switch (err) {4653 const ty = sema.resolveType(block, ty_src, extra.ty) catch |err| switch (err) {
...@@ -4698,7 +4710,7 @@ fn zirValidateStructInitTy(...@@ -4698,7 +4710,7 @@ fn zirValidateStructInitTy(
4698) CompileError!void {4710) CompileError!void {
4699 const mod = sema.mod;4711 const mod = sema.mod;
4700 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;4712 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);
4702 const ty = sema.resolveType(block, src, inst_data.operand) catch |err| switch (err) {4714 const ty = sema.resolveType(block, src, inst_data.operand) catch |err| switch (err) {
4703 // It's okay for the type to be unknown: this will result in an anonymous struct init.4715 // It's okay for the type to be unknown: this will result in an anonymous struct init.
4704 error.GenericPoison => return,4716 error.GenericPoison => return,
...@@ -4723,7 +4735,7 @@ fn zirValidatePtrStructInit(...@@ -4723,7 +4735,7 @@ fn zirValidatePtrStructInit(
47234735
4724 const mod = sema.mod;4736 const mod = sema.mod;
4725 const validate_inst = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;4737 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);
4727 const validate_extra = sema.code.extraData(Zir.Inst.Block, validate_inst.payload_index);4739 const validate_extra = sema.code.extraData(Zir.Inst.Block, validate_inst.payload_index);
4728 const instrs = sema.code.bodySlice(validate_extra.end, validate_extra.data.body_len);4740 const instrs = sema.code.bodySlice(validate_extra.end, validate_extra.data.body_len);
4729 const field_ptr_data = sema.code.instructions.items(.data)[@intFromEnum(instrs[0])].pl_node;4741 const field_ptr_data = sema.code.instructions.items(.data)[@intFromEnum(instrs[0])].pl_node;
...@@ -4898,11 +4910,11 @@ fn validateUnionInit(...@@ -4898,11 +4910,11 @@ fn validateUnionInit(
4898 try sema.storePtr2(block, init_src, union_ptr, init_src, union_init, init_src, .store);4910 try sema.storePtr2(block, init_src, union_ptr, init_src, union_init, init_src, .store);
4899 return;4911 return;
4900 } else if (try sema.typeRequiresComptime(union_ty)) {4912 } 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), .{
4902 .needed_comptime_reason = "initializer of comptime only union must be comptime-known",4914 .needed_comptime_reason = "initializer of comptime only union must be comptime-known",
4903 });4915 });
4904 }4916 }
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
4907 const new_tag = Air.internedToRef(tag_val.toIntern());4919 const new_tag = Air.internedToRef(tag_val.toIntern());
4908 const set_tag_inst = try block.addBinOp(.set_union_tag, union_ptr, new_tag);4920 const set_tag_inst = try block.addBinOp(.set_union_tag, union_ptr, new_tag);
...@@ -5089,7 +5101,7 @@ fn validateStructInit(...@@ -5089,7 +5101,7 @@ fn validateStructInit(
5089 field_values[i] = val.toIntern();5101 field_values[i] = val.toIntern();
5090 } else if (require_comptime) {5102 } else if (require_comptime) {
5091 const field_ptr_data = sema.code.instructions.items(.data)[@intFromEnum(field_ptr)].pl_node;5103 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), .{
5093 .needed_comptime_reason = "initializer of comptime only struct must be comptime-known",5105 .needed_comptime_reason = "initializer of comptime only struct must be comptime-known",
5094 });5106 });
5095 } else {5107 } else {
...@@ -5213,7 +5225,7 @@ fn zirValidatePtrArrayInit(...@@ -5213,7 +5225,7 @@ fn zirValidatePtrArrayInit(
5213) CompileError!void {5225) CompileError!void {
5214 const mod = sema.mod;5226 const mod = sema.mod;
5215 const validate_inst = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;5227 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);
5217 const validate_extra = sema.code.extraData(Zir.Inst.Block, validate_inst.payload_index);5229 const validate_extra = sema.code.extraData(Zir.Inst.Block, validate_inst.payload_index);
5218 const instrs = sema.code.bodySlice(validate_extra.end, validate_extra.data.body_len);5230 const instrs = sema.code.bodySlice(validate_extra.end, validate_extra.data.body_len);
5219 const first_elem_ptr_data = sema.code.instructions.items(.data)[@intFromEnum(instrs[0])].pl_node;5231 const first_elem_ptr_data = sema.code.instructions.items(.data)[@intFromEnum(instrs[0])].pl_node;
...@@ -5418,7 +5430,7 @@ fn zirValidatePtrArrayInit(...@@ -5418,7 +5430,7 @@ fn zirValidatePtrArrayInit(
5418fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {5430fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
5419 const mod = sema.mod;5431 const mod = sema.mod;
5420 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;5432 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);
5422 const operand = try sema.resolveInst(inst_data.operand);5434 const operand = try sema.resolveInst(inst_data.operand);
5423 const operand_ty = sema.typeOf(operand);5435 const operand_ty = sema.typeOf(operand);
54245436
...@@ -5462,7 +5474,7 @@ fn zirValidateDestructure(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp...@@ -5462,7 +5474,7 @@ fn zirValidateDestructure(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
5462 const mod = sema.mod;5474 const mod = sema.mod;
5463 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;5475 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
5464 const extra = sema.code.extraData(Zir.Inst.ValidateDestructure, inst_data.payload_index).data;5476 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);
5466 const destructure_src = LazySrcLoc.nodeOffset(extra.destructure_node);5478 const destructure_src = LazySrcLoc.nodeOffset(extra.destructure_node);
5467 const operand = try sema.resolveInst(extra.operand);5479 const operand = try sema.resolveInst(extra.operand);
5468 const operand_ty = sema.typeOf(operand);5480 const operand_ty = sema.typeOf(operand);
...@@ -5593,7 +5605,7 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi...@@ -5593,7 +5605,7 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi
5593 defer tracy.end();5605 defer tracy.end();
55945606
5595 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;5607 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);
5597 const bin = sema.code.extraData(Zir.Inst.Bin, pl_node.payload_index).data;5609 const bin = sema.code.extraData(Zir.Inst.Bin, pl_node.payload_index).data;
5598 const ptr = try sema.resolveInst(bin.lhs);5610 const ptr = try sema.resolveInst(bin.lhs);
5599 const operand = try sema.resolveInst(bin.rhs);5611 const operand = try sema.resolveInst(bin.rhs);
...@@ -5675,7 +5687,7 @@ fn storeToInferredAllocComptime(...@@ -5675,7 +5687,7 @@ fn storeToInferredAllocComptime(
56755687
5676fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {5688fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
5677 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;5689 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);
5679 const quota: u32 = @intCast(try sema.resolveInt(block, src, inst_data.operand, Type.u32, .{5691 const quota: u32 = @intCast(try sema.resolveInt(block, src, inst_data.operand, Type.u32, .{
5680 .needed_comptime_reason = "eval branch quota must be comptime-known",5692 .needed_comptime_reason = "eval branch quota must be comptime-known",
5681 }));5693 }));
...@@ -5690,7 +5702,7 @@ fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!v...@@ -5690,7 +5702,7 @@ fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!v
5690 const zir_tags = sema.code.instructions.items(.tag);5702 const zir_tags = sema.code.instructions.items(.tag);
5691 const zir_datas = sema.code.instructions.items(.data);5703 const zir_datas = sema.code.instructions.items(.data);
5692 const inst_data = zir_datas[@intFromEnum(inst)].pl_node;5704 const inst_data = zir_datas[@intFromEnum(inst)].pl_node;
5693 const src = inst_data.src();5705 const src = block.nodeOffset(inst_data.src_node);
5694 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;5706 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
5695 const ptr = try sema.resolveInst(extra.lhs);5707 const ptr = try sema.resolveInst(extra.lhs);
5696 const operand = try sema.resolveInst(extra.rhs);5708 const operand = try sema.resolveInst(extra.rhs);
...@@ -5824,7 +5836,7 @@ fn zirCompileError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -5824,7 +5836,7 @@ fn zirCompileError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
5824 defer tracy.end();5836 defer tracy.end();
58255837
5826 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;5838 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);
5828 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };5840 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
5829 const msg = try sema.resolveConstString(block, operand_src, inst_data.operand, .{5841 const msg = try sema.resolveConstString(block, operand_src, inst_data.operand, .{
5830 .needed_comptime_reason = "compile error string must be comptime-known",5842 .needed_comptime_reason = "compile error string must be comptime-known",
...@@ -5874,7 +5886,7 @@ fn zirCompileLog(...@@ -5874,7 +5886,7 @@ fn zirCompileLog(
58745886
5875fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {5887fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
5876 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;5888 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);
5878 const msg_inst = try sema.resolveInst(inst_data.operand);5890 const msg_inst = try sema.resolveInst(inst_data.operand);
58795891
5880 // `panicWithMsg` would perform this coercion for us, but we can get a better5892 // `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...@@ -5901,7 +5913,7 @@ fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError
59015913
5902 const mod = sema.mod;5914 const mod = sema.mod;
5903 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;5915 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);
5905 const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index);5917 const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index);
5906 const body = sema.code.bodySlice(extra.end, extra.data.body_len);5918 const body = sema.code.bodySlice(extra.end, extra.data.body_len);
5907 const gpa = sema.gpa;5919 const gpa = sema.gpa;
...@@ -5974,7 +5986,7 @@ fn zirCImport(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileEr...@@ -5974,7 +5986,7 @@ fn zirCImport(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileEr
5974 const comp = mod.comp;5986 const comp = mod.comp;
5975 const gpa = sema.gpa;5987 const gpa = sema.gpa;
5976 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;5988 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);
5978 const extra = sema.code.extraData(Zir.Inst.Block, pl_node.payload_index);5990 const extra = sema.code.extraData(Zir.Inst.Block, pl_node.payload_index);
5979 const body = sema.code.bodySlice(extra.end, extra.data.body_len);5991 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...@@ -6076,7 +6088,7 @@ fn zirCImport(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileEr
60766088
6077fn zirSuspendBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {6089fn zirSuspendBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6078 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;6090 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);
6080 return sema.failWithUseOfAsync(parent_block, src);6092 return sema.failWithUseOfAsync(parent_block, src);
6081}6093}
60826094
...@@ -6085,7 +6097,7 @@ fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index, force_compt...@@ -6085,7 +6097,7 @@ fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index, force_compt
6085 defer tracy.end();6097 defer tracy.end();
60866098
6087 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;6099 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);
6089 const extra = sema.code.extraData(Zir.Inst.Block, pl_node.payload_index);6101 const extra = sema.code.extraData(Zir.Inst.Block, pl_node.payload_index);
6090 const body = sema.code.bodySlice(extra.end, extra.data.body_len);6102 const body = sema.code.bodySlice(extra.end, extra.data.body_len);
6091 const gpa = sema.gpa;6103 const gpa = sema.gpa;
...@@ -6420,7 +6432,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -6420,7 +6432,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
6420 const mod = sema.mod;6432 const mod = sema.mod;
6421 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;6433 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
6422 const extra = sema.code.extraData(Zir.Inst.Export, inst_data.payload_index).data;6434 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);
6424 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };6436 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
6425 const options_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };6437 const options_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
6426 const decl_name = try mod.intern_pool.getOrPutString(6438 const decl_name = try mod.intern_pool.getOrPutString(
...@@ -6460,7 +6472,7 @@ fn zirExportValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -6460,7 +6472,7 @@ fn zirExportValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
6460 const mod = sema.mod;6472 const mod = sema.mod;
6461 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;6473 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
6462 const extra = sema.code.extraData(Zir.Inst.ExportValue, inst_data.payload_index).data;6474 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);
6464 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };6476 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
6465 const options_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };6477 const options_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
6466 const operand = try sema.resolveInstConst(block, operand_src, extra.operand, .{6478 const operand = try sema.resolveInstConst(block, operand_src, extra.operand, .{
...@@ -6777,7 +6789,7 @@ fn addDbgVar(...@@ -6777,7 +6789,7 @@ fn addDbgVar(
6777fn zirDeclRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {6789fn zirDeclRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6778 const mod = sema.mod;6790 const mod = sema.mod;
6779 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_tok;6791 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);
6781 const decl_name = try mod.intern_pool.getOrPutString(6793 const decl_name = try mod.intern_pool.getOrPutString(
6782 sema.gpa,6794 sema.gpa,
6783 inst_data.get(sema.code),6795 inst_data.get(sema.code),
...@@ -6791,7 +6803,7 @@ fn zirDeclRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -6791,7 +6803,7 @@ fn zirDeclRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
6791fn zirDeclVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {6803fn zirDeclVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
6792 const mod = sema.mod;6804 const mod = sema.mod;
6793 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_tok;6805 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);
6795 const decl_name = try mod.intern_pool.getOrPutString(6807 const decl_name = try mod.intern_pool.getOrPutString(
6796 sema.gpa,6808 sema.gpa,
6797 inst_data.get(sema.code),6809 inst_data.get(sema.code),
...@@ -7059,7 +7071,7 @@ fn zirCall(...@@ -7059,7 +7071,7 @@ fn zirCall(
7059 const mod = sema.mod;7071 const mod = sema.mod;
7060 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;7072 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
7061 const callee_src: LazySrcLoc = .{ .node_offset_call_func = inst_data.src_node };7073 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);
7063 const ExtraType = switch (kind) {7075 const ExtraType = switch (kind) {
7064 .direct => Zir.Inst.Call,7076 .direct => Zir.Inst.Call,
7065 .field => Zir.Inst.FieldCall,7077 .field => Zir.Inst.FieldCall,
...@@ -8084,7 +8096,7 @@ fn analyzeInlineCallArg(...@@ -8084,7 +8096,7 @@ fn analyzeInlineCallArg(
8084 // Evaluate the parameter type expression now that previous ones have8096 // Evaluate the parameter type expression now that previous ones have
8085 // been mapped, and coerce the corresponding argument to it.8097 // been mapped, and coerce the corresponding argument to it.
8086 const pl_tok = ics.callee().code.instructions.items(.data)[@intFromEnum(inst)].pl_tok;8098 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);
8088 const extra = ics.callee().code.extraData(Zir.Inst.Param, pl_tok.payload_index);8100 const extra = ics.callee().code.extraData(Zir.Inst.Param, pl_tok.payload_index);
8089 const param_body = ics.callee().code.bodySlice(extra.end, extra.data.body_len);8101 const param_body = ics.callee().code.bodySlice(extra.end, extra.data.body_len);
8090 const param_ty = param_ty: {8102 const param_ty = param_ty: {
...@@ -8324,7 +8336,11 @@ fn instantiateGenericCall(...@@ -8324,7 +8336,11 @@ fn instantiateGenericCall(
8324 }8336 }
83258337
8326 const param_ty_inst = try child_sema.resolveInlineBody(&child_block, param_ty_body, param_inst);8338 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 );
8328 },8344 },
8329 else => unreachable,8345 else => unreachable,
8330 }8346 }
...@@ -8358,11 +8374,11 @@ fn instantiateGenericCall(...@@ -8358,11 +8374,11 @@ fn instantiateGenericCall(
8358 const arg_src = args_info.argSrc(block, arg_index);8374 const arg_src = args_info.argSrc(block, arg_index);
8359 const msg = try sema.errMsg(block, arg_src, "runtime-known argument passed to comptime parameter", .{});8375 const msg = try sema.errMsg(block, arg_src, "runtime-known argument passed to comptime parameter", .{});
8360 errdefer msg.destroy(sema.gpa);8376 errdefer msg.destroy(sema.gpa);
8361 const param_src = switch (param_tag) {8377 const param_src = child_block.tokenOffset(switch (param_tag) {
8362 .param_comptime => fn_zir.instructions.items(.data)[@intFromEnum(param_inst)].pl_tok.src(),8378 .param_comptime => fn_zir.instructions.items(.data)[@intFromEnum(param_inst)].pl_tok.src_tok,
8363 .param_anytype_comptime => fn_zir.instructions.items(.data)[@intFromEnum(param_inst)].str_tok.src(),8379 .param_anytype_comptime => fn_zir.instructions.items(.data)[@intFromEnum(param_inst)].str_tok.src_tok,
8364 else => unreachable,8380 else => unreachable,
8365 };8381 });
8366 try child_sema.errNote(&child_block, param_src, msg, "declared comptime here", .{});8382 try child_sema.errNote(&child_block, param_src, msg, "declared comptime here", .{});
8367 break :msg msg;8383 break :msg msg;
8368 }),8384 }),
...@@ -8373,11 +8389,11 @@ fn instantiateGenericCall(...@@ -8373,11 +8389,11 @@ fn instantiateGenericCall(
8373 const arg_src = args_info.argSrc(block, arg_index);8389 const arg_src = args_info.argSrc(block, arg_index);
8374 const msg = try sema.errMsg(block, arg_src, "runtime-known argument passed to parameter of comptime-only type", .{});8390 const msg = try sema.errMsg(block, arg_src, "runtime-known argument passed to parameter of comptime-only type", .{});
8375 errdefer msg.destroy(sema.gpa);8391 errdefer msg.destroy(sema.gpa);
8376 const param_src = switch (param_tag) {8392 const param_src = child_block.tokenOffset(switch (param_tag) {
8377 .param => fn_zir.instructions.items(.data)[@intFromEnum(param_inst)].pl_tok.src(),8393 .param => fn_zir.instructions.items(.data)[@intFromEnum(param_inst)].pl_tok.src_tok,
8378 .param_anytype => fn_zir.instructions.items(.data)[@intFromEnum(param_inst)].str_tok.src(),8394 .param_anytype => fn_zir.instructions.items(.data)[@intFromEnum(param_inst)].str_tok.src_tok,
8379 else => unreachable,8395 else => unreachable,
8380 };8396 });
8381 try child_sema.errNote(&child_block, param_src, msg, "declared here", .{});8397 try child_sema.errNote(&child_block, param_src, msg, "declared here", .{});
8382 const src_decl = mod.declPtr(block.src_decl);8398 const src_decl = mod.declPtr(block.src_decl);
8383 try sema.explainWhyTypeIsComptime(msg, src_decl.toSrcLoc(arg_src, mod), arg_ty);8399 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...@@ -8560,7 +8576,7 @@ fn zirElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
8560fn zirIndexablePtrElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {8576fn zirIndexablePtrElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8561 const mod = sema.mod;8577 const mod = sema.mod;
8562 const un_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;8578 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);
8564 const ptr_ty = sema.resolveType(block, src, un_node.operand) catch |err| switch (err) {8580 const ptr_ty = sema.resolveType(block, src, un_node.operand) catch |err| switch (err) {
8565 error.GenericPoison => return .generic_poison_type,8581 error.GenericPoison => return .generic_poison_type,
8566 else => |e| return e,8582 else => |e| return e,
...@@ -8585,7 +8601,7 @@ fn zirVectorElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr...@@ -8585,7 +8601,7 @@ fn zirVectorElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
8585 else => |e| return e,8601 else => |e| return e,
8586 };8602 };
8587 if (!vec_ty.isVector(mod)) {8603 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)});
8589 }8605 }
8590 return Air.internedToRef(vec_ty.childType(mod).toIntern());8606 return Air.internedToRef(vec_ty.childType(mod).toIntern());
8591}8607}
...@@ -8672,7 +8688,7 @@ fn zirAnyframeType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -8672,7 +8688,7 @@ fn zirAnyframeType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
86728688
8673 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;8689 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
8674 if (true) {8690 if (true) {
8675 return sema.failWithUseOfAsync(block, inst_data.src());8691 return sema.failWithUseOfAsync(block, block.nodeOffset(inst_data.src_node));
8676 }8692 }
8677 const mod = sema.mod;8693 const mod = sema.mod;
8678 const operand_src: LazySrcLoc = .{ .node_offset_anyframe_type = inst_data.src_node };8694 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...@@ -8888,7 +8904,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
8888fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {8904fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
8889 const mod = sema.mod;8905 const mod = sema.mod;
8890 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;8906 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);
8892 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };8908 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
8893 const operand = try sema.resolveInst(inst_data.operand);8909 const operand = try sema.resolveInst(inst_data.operand);
8894 const operand_ty = sema.typeOf(operand);8910 const operand_ty = sema.typeOf(operand);
...@@ -8946,7 +8962,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -8946,7 +8962,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
8946 const mod = sema.mod;8962 const mod = sema.mod;
8947 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;8963 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
8948 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;8964 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);
8950 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };8966 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
8951 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@enumFromInt");8967 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@enumFromInt");
8952 const operand = try sema.resolveInst(extra.rhs);8968 const operand = try sema.resolveInst(extra.rhs);
...@@ -9015,7 +9031,7 @@ fn zirOptionalPayloadPtr(...@@ -9015,7 +9031,7 @@ fn zirOptionalPayloadPtr(
90159031
9016 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;9032 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
9017 const optional_ptr = try sema.resolveInst(inst_data.operand);9033 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
9020 return sema.analyzeOptionalPayloadPtr(block, src, optional_ptr, safety_check, false);9036 return sema.analyzeOptionalPayloadPtr(block, src, optional_ptr, safety_check, false);
9021}9037}
...@@ -9099,7 +9115,7 @@ fn zirOptionalPayload(...@@ -9099,7 +9115,7 @@ fn zirOptionalPayload(
90999115
9100 const mod = sema.mod;9116 const mod = sema.mod;
9101 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;9117 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);
9103 const operand = try sema.resolveInst(inst_data.operand);9119 const operand = try sema.resolveInst(inst_data.operand);
9104 const operand_ty = sema.typeOf(operand);9120 const operand_ty = sema.typeOf(operand);
9105 const result_ty = switch (operand_ty.zigTypeTag(mod)) {9121 const result_ty = switch (operand_ty.zigTypeTag(mod)) {
...@@ -9151,7 +9167,7 @@ fn zirErrUnionPayload(...@@ -9151,7 +9167,7 @@ fn zirErrUnionPayload(
91519167
9152 const mod = sema.mod;9168 const mod = sema.mod;
9153 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;9169 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);
9155 const operand = try sema.resolveInst(inst_data.operand);9171 const operand = try sema.resolveInst(inst_data.operand);
9156 const operand_src = src;9172 const operand_src = src;
9157 const err_union_ty = sema.typeOf(operand);9173 const err_union_ty = sema.typeOf(operand);
...@@ -9204,7 +9220,7 @@ fn zirErrUnionPayloadPtr(...@@ -9204,7 +9220,7 @@ fn zirErrUnionPayloadPtr(
92049220
9205 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;9221 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
9206 const operand = try sema.resolveInst(inst_data.operand);9222 const operand = try sema.resolveInst(inst_data.operand);
9207 const src = inst_data.src();9223 const src = block.nodeOffset(inst_data.src_node);
92089224
9209 return sema.analyzeErrUnionPayloadPtr(block, src, operand, false, false);9225 return sema.analyzeErrUnionPayloadPtr(block, src, operand, false, false);
9210}9226}
...@@ -9288,7 +9304,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -9288,7 +9304,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
9288 defer tracy.end();9304 defer tracy.end();
92899305
9290 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;9306 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);
9292 const operand = try sema.resolveInst(inst_data.operand);9308 const operand = try sema.resolveInst(inst_data.operand);
9293 return sema.analyzeErrUnionCode(block, src, operand);9309 return sema.analyzeErrUnionCode(block, src, operand);
9294}9310}
...@@ -9321,7 +9337,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE...@@ -9321,7 +9337,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
9321 defer tracy.end();9337 defer tracy.end();
93229338
9323 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;9339 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);
9325 const operand = try sema.resolveInst(inst_data.operand);9341 const operand = try sema.resolveInst(inst_data.operand);
9326 return sema.analyzeErrUnionCodePtr(block, src, operand);9342 return sema.analyzeErrUnionCodePtr(block, src, operand);
9327}9343}
...@@ -9997,11 +10013,11 @@ fn finishFunc(...@@ -9997,11 +10013,11 @@ fn finishFunc(
9997 param_body[0..block.params.len],10013 param_body[0..block.params.len],
9998 ) |is_comptime, name_nts, param_index| {10014 ) |is_comptime, name_nts, param_index| {
9999 if (!is_comptime) {10015 if (!is_comptime) {
10000 const param_src = switch (tags[@intFromEnum(param_index)]) {10016 const param_src = block.tokenOffset(switch (tags[@intFromEnum(param_index)]) {
10001 .param => data[@intFromEnum(param_index)].pl_tok.src(),10017 .param => data[@intFromEnum(param_index)].pl_tok.src_tok,
10002 .param_anytype => data[@intFromEnum(param_index)].str_tok.src(),10018 .param_anytype => data[@intFromEnum(param_index)].str_tok.src_tok,
10003 else => unreachable,10019 else => unreachable,
10004 };10020 });
10005 const name = sema.code.nullTerminatedString(name_nts);10021 const name = sema.code.nullTerminatedString(name_nts);
10006 if (name.len != 0) {10022 if (name.len != 0) {
10007 try sema.errNote(block, param_src, msg, "param '{s}' is required to be comptime", .{name});10023 try sema.errNote(block, param_src, msg, "param '{s}' is required to be comptime", .{name});
...@@ -10084,7 +10100,7 @@ fn zirParam(...@@ -10084,7 +10100,7 @@ fn zirParam(
10084 comptime_syntax: bool,10100 comptime_syntax: bool,
10085) CompileError!void {10101) CompileError!void {
10086 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_tok;10102 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);
10088 const extra = sema.code.extraData(Zir.Inst.Param, inst_data.payload_index);10104 const extra = sema.code.extraData(Zir.Inst.Param, inst_data.payload_index);
10089 const param_name: Zir.NullTerminatedString = extra.data.name;10105 const param_name: Zir.NullTerminatedString = extra.data.name;
10090 const body = sema.code.bodySlice(extra.end, extra.data.body_len);10106 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....@@ -10194,7 +10210,7 @@ fn zirAsNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
10194 defer tracy.end();10210 defer tracy.end();
1019510211
10196 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10212 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);
10198 const extra = sema.code.extraData(Zir.Inst.As, inst_data.payload_index).data;10214 const extra = sema.code.extraData(Zir.Inst.As, inst_data.payload_index).data;
10199 return sema.analyzeAs(block, src, extra.dest_type, extra.operand, false);10215 return sema.analyzeAs(block, src, extra.dest_type, extra.operand, false);
10200}10216}
...@@ -10204,7 +10220,7 @@ fn zirAsShiftOperand(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr...@@ -10204,7 +10220,7 @@ fn zirAsShiftOperand(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
10204 defer tracy.end();10220 defer tracy.end();
1020510221
10206 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10222 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);
10208 const extra = sema.code.extraData(Zir.Inst.As, inst_data.payload_index).data;10224 const extra = sema.code.extraData(Zir.Inst.As, inst_data.payload_index).data;
10209 return sema.analyzeAs(block, src, extra.dest_type, extra.operand, true);10225 return sema.analyzeAs(block, src, extra.dest_type, extra.operand, true);
10210}10226}
...@@ -10301,7 +10317,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -10301,7 +10317,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
10301 .storage = .{ .elems = new_elems },10317 .storage = .{ .elems = new_elems },
10302 } }));10318 } }));
10303 }10319 }
10304 try sema.requireRuntimeBlock(block, inst_data.src(), ptr_src);10320 try sema.requireRuntimeBlock(block, block.nodeOffset(inst_data.src_node), ptr_src);
10305 try sema.validateRuntimeValue(block, ptr_src, operand);10321 try sema.validateRuntimeValue(block, ptr_src, operand);
10306 if (!is_vector) {10322 if (!is_vector) {
10307 return block.addUnOp(.int_from_ptr, operand);10323 return block.addUnOp(.int_from_ptr, operand);
...@@ -10323,7 +10339,7 @@ fn zirFieldVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -10323,7 +10339,7 @@ fn zirFieldVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1032310339
10324 const mod = sema.mod;10340 const mod = sema.mod;
10325 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10341 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);
10327 const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node };10343 const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node };
10328 const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data;10344 const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data;
10329 const field_name = try mod.intern_pool.getOrPutString(10345 const field_name = try mod.intern_pool.getOrPutString(
...@@ -10341,7 +10357,7 @@ fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -10341,7 +10357,7 @@ fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1034110357
10342 const mod = sema.mod;10358 const mod = sema.mod;
10343 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10359 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);
10345 const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node };10361 const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node };
10346 const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data;10362 const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data;
10347 const field_name = try mod.intern_pool.getOrPutString(10363 const field_name = try mod.intern_pool.getOrPutString(
...@@ -10359,7 +10375,7 @@ fn zirStructInitFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi...@@ -10359,7 +10375,7 @@ fn zirStructInitFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi
1035910375
10360 const mod = sema.mod;10376 const mod = sema.mod;
10361 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10377 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);
10363 const field_name_src: LazySrcLoc = .{ .node_offset_field_name_init = inst_data.src_node };10379 const field_name_src: LazySrcLoc = .{ .node_offset_field_name_init = inst_data.src_node };
10364 const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data;10380 const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data;
10365 const field_name = try mod.intern_pool.getOrPutString(10381 const field_name = try mod.intern_pool.getOrPutString(
...@@ -10384,7 +10400,7 @@ fn zirFieldValNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -10384,7 +10400,7 @@ fn zirFieldValNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
10384 defer tracy.end();10400 defer tracy.end();
1038510401
10386 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10402 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);
10388 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };10404 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
10389 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;10405 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;
10390 const object = try sema.resolveInst(extra.lhs);10406 const object = try sema.resolveInst(extra.lhs);
...@@ -10399,7 +10415,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -10399,7 +10415,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
10399 defer tracy.end();10415 defer tracy.end();
1040010416
10401 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10417 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);
10403 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };10419 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
10404 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;10420 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;
10405 const object_ptr = try sema.resolveInst(extra.lhs);10421 const object_ptr = try sema.resolveInst(extra.lhs);
...@@ -10414,14 +10430,14 @@ fn zirIntCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -10414,14 +10430,14 @@ fn zirIntCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
10414 defer tracy.end();10430 defer tracy.end();
1041510431
10416 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10432 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);
10418 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };10434 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
10419 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;10435 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
1042010436
10421 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@intCast");10437 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@intCast");
10422 const operand = try sema.resolveInst(extra.rhs);10438 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);
10425}10441}
1042610442
10427fn intCast(10443fn intCast(
...@@ -10584,7 +10600,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -10584,7 +10600,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1058410600
10585 const mod = sema.mod;10601 const mod = sema.mod;
10586 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10602 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);
10588 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };10604 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
10589 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;10605 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...@@ -10718,7 +10734,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
10718 .Vector,10734 .Vector,
10719 => {},10735 => {},
10720 }10736 }
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);
10722}10738}
1072310739
10724fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {10740fn 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...@@ -10727,7 +10743,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
1072710743
10728 const mod = sema.mod;10744 const mod = sema.mod;
10729 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10745 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);
10731 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };10747 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
10732 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;10748 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...@@ -10781,7 +10797,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
10781 if (dest_is_comptime_float) {10797 if (dest_is_comptime_float) {
10782 return sema.fail(block, operand_src, "unable to cast runtime value to 'comptime_float'", .{});10798 return sema.fail(block, operand_src, "unable to cast runtime value to 'comptime_float'", .{});
10783 }10799 }
10784 try sema.requireRuntimeBlock(block, inst_data.src(), operand_src);10800 try sema.requireRuntimeBlock(block, block.nodeOffset(inst_data.src_node), operand_src);
1078510801
10786 const src_bits = operand_scalar_ty.floatBits(target);10802 const src_bits = operand_scalar_ty.floatBits(target);
10787 const dst_bits = dest_scalar_ty.floatBits(target);10803 const dst_bits = dest_scalar_ty.floatBits(target);
...@@ -10806,7 +10822,7 @@ fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -10806,7 +10822,7 @@ fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
10806 defer tracy.end();10822 defer tracy.end();
1080710823
10808 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10824 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);
10810 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;10826 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
10811 const array = try sema.resolveInst(extra.lhs);10827 const array = try sema.resolveInst(extra.lhs);
10812 const elem_index = try sema.resolveInst(extra.rhs);10828 const elem_index = try sema.resolveInst(extra.rhs);
...@@ -10818,7 +10834,7 @@ fn zirElemValNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10818,7 +10834,7 @@ fn zirElemValNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10818 defer tracy.end();10834 defer tracy.end();
1081910835
10820 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10836 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);
10822 const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node };10838 const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node };
10823 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;10839 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
10824 const array = try sema.resolveInst(extra.lhs);10840 const array = try sema.resolveInst(extra.lhs);
...@@ -10844,7 +10860,7 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -10844,7 +10860,7 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1084410860
10845 const mod = sema.mod;10861 const mod = sema.mod;
10846 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10862 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);
10848 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;10864 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
10849 const array_ptr = try sema.resolveInst(extra.lhs);10865 const array_ptr = try sema.resolveInst(extra.lhs);
10850 const elem_index = try sema.resolveInst(extra.rhs);10866 const elem_index = try sema.resolveInst(extra.rhs);
...@@ -10871,7 +10887,7 @@ fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10871,7 +10887,7 @@ fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10871 defer tracy.end();10887 defer tracy.end();
1087210888
10873 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10889 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);
10875 const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node };10891 const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node };
10876 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;10892 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
10877 const array_ptr = try sema.resolveInst(extra.lhs);10893 const array_ptr = try sema.resolveInst(extra.lhs);
...@@ -10886,7 +10902,7 @@ fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile...@@ -10886,7 +10902,7 @@ fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile
1088610902
10887 const mod = sema.mod;10903 const mod = sema.mod;
10888 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10904 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);
10890 const extra = sema.code.extraData(Zir.Inst.ElemPtrImm, inst_data.payload_index).data;10906 const extra = sema.code.extraData(Zir.Inst.ElemPtrImm, inst_data.payload_index).data;
10891 const array_ptr = try sema.resolveInst(extra.ptr);10907 const array_ptr = try sema.resolveInst(extra.ptr);
10892 const elem_index = try sema.mod.intRef(Type.usize, extra.index);10908 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!...@@ -10905,7 +10921,7 @@ fn zirSliceStart(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
10905 defer tracy.end();10921 defer tracy.end();
1090610922
10907 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10923 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);
10909 const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data;10925 const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data;
10910 const array_ptr = try sema.resolveInst(extra.lhs);10926 const array_ptr = try sema.resolveInst(extra.lhs);
10911 const start = try sema.resolveInst(extra.start);10927 const start = try sema.resolveInst(extra.start);
...@@ -10921,7 +10937,7 @@ fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -10921,7 +10937,7 @@ fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
10921 defer tracy.end();10937 defer tracy.end();
1092210938
10923 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10939 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);
10925 const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data;10941 const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data;
10926 const array_ptr = try sema.resolveInst(extra.lhs);10942 const array_ptr = try sema.resolveInst(extra.lhs);
10927 const start = try sema.resolveInst(extra.start);10943 const start = try sema.resolveInst(extra.start);
...@@ -10938,7 +10954,7 @@ fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -10938,7 +10954,7 @@ fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
10938 defer tracy.end();10954 defer tracy.end();
1093910955
10940 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10956 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);
10942 const sentinel_src: LazySrcLoc = .{ .node_offset_slice_sentinel = inst_data.src_node };10958 const sentinel_src: LazySrcLoc = .{ .node_offset_slice_sentinel = inst_data.src_node };
10943 const extra = sema.code.extraData(Zir.Inst.SliceSentinel, inst_data.payload_index).data;10959 const extra = sema.code.extraData(Zir.Inst.SliceSentinel, inst_data.payload_index).data;
10944 const array_ptr = try sema.resolveInst(extra.lhs);10960 const array_ptr = try sema.resolveInst(extra.lhs);
...@@ -10957,7 +10973,7 @@ fn zirSliceLength(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10957,7 +10973,7 @@ fn zirSliceLength(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10957 defer tracy.end();10973 defer tracy.end();
1095810974
10959 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;10975 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);
10961 const extra = sema.code.extraData(Zir.Inst.SliceLength, inst_data.payload_index).data;10977 const extra = sema.code.extraData(Zir.Inst.SliceLength, inst_data.payload_index).data;
10962 const array_ptr = try sema.resolveInst(extra.lhs);10978 const array_ptr = try sema.resolveInst(extra.lhs);
10963 const start = try sema.resolveInst(extra.start);10979 const start = try sema.resolveInst(extra.start);
...@@ -11017,7 +11033,9 @@ const SwitchProngAnalysis = struct {...@@ -11017,7 +11033,9 @@ const SwitchProngAnalysis = struct {
11017 merges: *Block.Merges,11033 merges: *Block.Merges,
11018 ) CompileError!Air.Inst.Ref {11034 ) CompileError!Air.Inst.Ref {
11019 const sema = spa.sema;11035 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
11022 if (has_tag_capture) {11040 if (has_tag_capture) {
11023 const tag_ref = try spa.analyzeTagCapture(child_block, raw_capture_src, inline_case_capture);11041 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...@@ -11566,7 +11584,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
11566 const mod = sema.mod;11584 const mod = sema.mod;
11567 const gpa = sema.gpa;11585 const gpa = sema.gpa;
11568 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;11586 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);
11570 const switch_src_node_offset = inst_data.src_node;11588 const switch_src_node_offset = inst_data.src_node;
11571 const switch_operand_src: LazySrcLoc = .{ .node_offset_switch_operand = switch_src_node_offset };11589 const switch_operand_src: LazySrcLoc = .{ .node_offset_switch_operand = switch_src_node_offset };
11572 const else_prong_src: LazySrcLoc = .{ .node_offset_switch_special_prong = switch_src_node_offset };11590 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...@@ -11874,7 +11892,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
11874 const mod = sema.mod;11892 const mod = sema.mod;
11875 const gpa = sema.gpa;11893 const gpa = sema.gpa;
11876 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;11894 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);
11878 const src_node_offset = inst_data.src_node;11896 const src_node_offset = inst_data.src_node;
11879 const operand_src: LazySrcLoc = .{ .node_offset_switch_operand = src_node_offset };11897 const operand_src: LazySrcLoc = .{ .node_offset_switch_operand = src_node_offset };
11880 const special_prong_src: LazySrcLoc = .{ .node_offset_switch_special_prong = src_node_offset };11898 const special_prong_src: LazySrcLoc = .{ .node_offset_switch_special_prong = src_node_offset };
...@@ -13396,7 +13414,7 @@ fn validateErrSetSwitch(...@@ -13396,7 +13414,7 @@ fn validateErrSetSwitch(
13396 const ip = &mod.intern_pool;13414 const ip = &mod.intern_pool;
1339713415
13398 const src_node_offset = inst_data.src_node;13416 const src_node_offset = inst_data.src_node;
13399 const src = inst_data.src();13417 const src = block.nodeOffset(src_node_offset);
1340013418
13401 var extra_index: usize = else_case.end;13419 var extra_index: usize = else_case.end;
13402 {13420 {
...@@ -13836,7 +13854,7 @@ fn maybeErrorUnwrapComptime(sema: *Sema, block: *Block, body: []const Zir.Inst.I...@@ -13836,7 +13854,7 @@ fn maybeErrorUnwrapComptime(sema: *Sema, block: *Block, body: []const Zir.Inst.I
13836 }13854 }
13837 } else return;13855 } else return;
13838 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"unreachable";13856 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
13841 if (try sema.resolveDefinedValue(block, src, operand)) |val| {13859 if (try sema.resolveDefinedValue(block, src, operand)) |val| {
13842 if (val.getErrorName(sema.mod).unwrap()) |name| {13860 if (val.getErrorName(sema.mod).unwrap()) |name| {
...@@ -13900,7 +13918,7 @@ fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -13900,7 +13918,7 @@ fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
13900 const mod = sema.mod;13918 const mod = sema.mod;
13901 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;13919 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
13902 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;13920 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);
13904 const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };13922 const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
13905 const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };13923 const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
13906 const container_type = try sema.resolveType(block, lhs_src, extra.lhs);13924 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....@@ -13932,7 +13950,7 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1393213950
13933 const mod = sema.mod;13951 const mod = sema.mod;
13934 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_tok;13952 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);
13936 const operand = inst_data.get(sema.code);13954 const operand = inst_data.get(sema.code);
1393713955
13938 const result = mod.importFile(block.getFileScope(mod), operand) catch |err| switch (err) {13956 const result = mod.importFile(block.getFileScope(mod), operand) catch |err| switch (err) {
...@@ -14012,7 +14030,7 @@ fn zirShl(...@@ -14012,7 +14030,7 @@ fn zirShl(
1401214030
14013 const mod = sema.mod;14031 const mod = sema.mod;
14014 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;14032 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);
14016 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };14034 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
14017 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };14035 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
14018 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;14036 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
...@@ -14182,7 +14200,7 @@ fn zirShr(...@@ -14182,7 +14200,7 @@ fn zirShr(
1418214200
14183 const mod = sema.mod;14201 const mod = sema.mod;
14184 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;14202 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);
14186 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };14204 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
14187 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };14205 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
14188 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;14206 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....@@ -14371,7 +14389,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1437114389
14372 const mod = sema.mod;14390 const mod = sema.mod;
14373 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;14391 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);
14375 const operand_src: LazySrcLoc = .{ .node_offset_un_op = inst_data.src_node };14393 const operand_src: LazySrcLoc = .{ .node_offset_un_op = inst_data.src_node };
1437614394
14377 const operand = try sema.resolveInst(inst_data.operand);14395 const operand = try sema.resolveInst(inst_data.operand);
...@@ -14520,7 +14538,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -14520,7 +14538,7 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
14520 const rhs = try sema.resolveInst(extra.rhs);14538 const rhs = try sema.resolveInst(extra.rhs);
14521 const lhs_ty = sema.typeOf(lhs);14539 const lhs_ty = sema.typeOf(lhs);
14522 const rhs_ty = sema.typeOf(rhs);14540 const rhs_ty = sema.typeOf(rhs);
14523 const src = inst_data.src();14541 const src = block.nodeOffset(inst_data.src_node);
1452414542
14525 const lhs_is_tuple = lhs_ty.isTuple(mod);14543 const lhs_is_tuple = lhs_ty.isTuple(mod);
14526 const rhs_is_tuple = rhs_ty.isTuple(mod);14544 const rhs_is_tuple = rhs_ty.isTuple(mod);
...@@ -14871,7 +14889,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -14871,7 +14889,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
14871 const extra = sema.code.extraData(Zir.Inst.ArrayMul, inst_data.payload_index).data;14889 const extra = sema.code.extraData(Zir.Inst.ArrayMul, inst_data.payload_index).data;
14872 const uncoerced_lhs = try sema.resolveInst(extra.lhs);14890 const uncoerced_lhs = try sema.resolveInst(extra.lhs);
14873 const uncoerced_lhs_ty = sema.typeOf(uncoerced_lhs);14891 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);
14875 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };14893 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
14876 const operator_src: LazySrcLoc = .{ .node_offset_main_token = inst_data.src_node };14894 const operator_src: LazySrcLoc = .{ .node_offset_main_token = inst_data.src_node };
14877 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };14895 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...@@ -15041,7 +15059,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15041fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {15059fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
15042 const mod = sema.mod;15060 const mod = sema.mod;
15043 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;15061 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);
15045 const lhs_src = src;15063 const lhs_src = src;
15046 const rhs_src: LazySrcLoc = .{ .node_offset_un_op = inst_data.src_node };15064 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....@@ -15073,7 +15091,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
15073fn zirNegateWrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {15091fn zirNegateWrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
15074 const mod = sema.mod;15092 const mod = sema.mod;
15075 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;15093 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);
15077 const lhs_src = src;15095 const lhs_src = src;
15078 const rhs_src: LazySrcLoc = .{ .node_offset_un_op = inst_data.src_node };15096 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...@@ -16991,7 +17009,7 @@ fn zirLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.In
16991 defer tracy.end();17009 defer tracy.end();
1699217010
16993 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;17011 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);
16995 const ptr_src = src; // TODO better source location17013 const ptr_src = src; // TODO better source location
16996 const ptr = try sema.resolveInst(inst_data.operand);17014 const ptr = try sema.resolveInst(inst_data.operand);
16997 return sema.analyzeLoad(block, src, ptr, ptr_src);17015 return sema.analyzeLoad(block, src, ptr, ptr_src);
...@@ -17181,7 +17199,7 @@ fn zirCmpEq(...@@ -17181,7 +17199,7 @@ fn zirCmpEq(
17181 const mod = sema.mod;17199 const mod = sema.mod;
17182 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;17200 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
17183 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;17201 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);
17185 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };17203 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
17186 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };17204 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
17187 const lhs = try sema.resolveInst(extra.lhs);17205 const lhs = try sema.resolveInst(extra.lhs);
...@@ -17297,7 +17315,7 @@ fn zirCmp(...@@ -17297,7 +17315,7 @@ fn zirCmp(
1729717315
17298 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;17316 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
17299 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;17317 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);
17301 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };17319 const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
17302 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };17320 const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node };
17303 const lhs = try sema.resolveInst(extra.lhs);17321 const lhs = try sema.resolveInst(extra.lhs);
...@@ -17724,7 +17742,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17724,7 +17742,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17724 const gpa = sema.gpa;17742 const gpa = sema.gpa;
17725 const ip = &mod.intern_pool;17743 const ip = &mod.intern_pool;
17726 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;17744 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);
17728 const ty = try sema.resolveType(block, src, inst_data.operand);17746 const ty = try sema.resolveType(block, src, inst_data.operand);
17729 const type_info_ty = try sema.getBuiltinType("Type");17747 const type_info_ty = try sema.getBuiltinType("Type");
17730 const type_info_tag_ty = type_info_ty.unionTagType(mod).?;17748 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...@@ -18906,7 +18924,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
1890618924
18907fn zirTypeofLog2IntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {18925fn zirTypeofLog2IntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
18908 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;18926 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);
18910 const operand = try sema.resolveInst(inst_data.operand);18928 const operand = try sema.resolveInst(inst_data.operand);
18911 const operand_ty = sema.typeOf(operand);18929 const operand_ty = sema.typeOf(operand);
18912 const res_ty = try sema.log2IntType(block, operand_ty, src);18930 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...@@ -18998,7 +19016,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1899819016
18999 const mod = sema.mod;19017 const mod = sema.mod;
19000 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;19018 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);
19002 const operand_src: LazySrcLoc = .{ .node_offset_un_op = inst_data.src_node };19020 const operand_src: LazySrcLoc = .{ .node_offset_un_op = inst_data.src_node };
19003 const uncasted_operand = try sema.resolveInst(inst_data.operand);19021 const uncasted_operand = try sema.resolveInst(inst_data.operand);
1900419022
...@@ -19155,7 +19173,7 @@ fn zirIsNonNull(...@@ -19155,7 +19173,7 @@ fn zirIsNonNull(
19155 defer tracy.end();19173 defer tracy.end();
1915619174
19157 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;19175 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);
19159 const operand = try sema.resolveInst(inst_data.operand);19177 const operand = try sema.resolveInst(inst_data.operand);
19160 try sema.checkNullableType(block, src, sema.typeOf(operand));19178 try sema.checkNullableType(block, src, sema.typeOf(operand));
19161 return sema.analyzeIsNull(block, src, operand, true);19179 return sema.analyzeIsNull(block, src, operand, true);
...@@ -19171,7 +19189,7 @@ fn zirIsNonNullPtr(...@@ -19171,7 +19189,7 @@ fn zirIsNonNullPtr(
1917119189
19172 const mod = sema.mod;19190 const mod = sema.mod;
19173 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;19191 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);
19175 const ptr = try sema.resolveInst(inst_data.operand);19193 const ptr = try sema.resolveInst(inst_data.operand);
19176 try sema.checkNullableType(block, src, sema.typeOf(ptr).elemType2(mod));19194 try sema.checkNullableType(block, src, sema.typeOf(ptr).elemType2(mod));
19177 if ((try sema.resolveValue(ptr)) == null) {19195 if ((try sema.resolveValue(ptr)) == null) {
...@@ -19196,7 +19214,7 @@ fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -19196,7 +19214,7 @@ fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
19196 defer tracy.end();19214 defer tracy.end();
1919719215
19198 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;19216 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);
19200 const operand = try sema.resolveInst(inst_data.operand);19218 const operand = try sema.resolveInst(inst_data.operand);
19201 try sema.checkErrorType(block, src, sema.typeOf(operand));19219 try sema.checkErrorType(block, src, sema.typeOf(operand));
19202 return sema.analyzeIsNonErr(block, src, operand);19220 return sema.analyzeIsNonErr(block, src, operand);
...@@ -19208,7 +19226,7 @@ fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -19208,7 +19226,7 @@ fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1920819226
19209 const mod = sema.mod;19227 const mod = sema.mod;
19210 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;19228 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);
19212 const ptr = try sema.resolveInst(inst_data.operand);19230 const ptr = try sema.resolveInst(inst_data.operand);
19213 try sema.checkErrorType(block, src, sema.typeOf(ptr).elemType2(mod));19231 try sema.checkErrorType(block, src, sema.typeOf(ptr).elemType2(mod));
19214 const loaded = try sema.analyzeLoad(block, src, ptr, src);19232 const loaded = try sema.analyzeLoad(block, src, ptr, src);
...@@ -19220,7 +19238,7 @@ fn zirRetIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -19220,7 +19238,7 @@ fn zirRetIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
19220 defer tracy.end();19238 defer tracy.end();
1922119239
19222 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;19240 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);
19224 const operand = try sema.resolveInst(inst_data.operand);19242 const operand = try sema.resolveInst(inst_data.operand);
19225 return sema.analyzeIsNonErr(block, src, operand);19243 return sema.analyzeIsNonErr(block, src, operand);
19226}19244}
...@@ -19302,7 +19320,7 @@ fn zirCondbr(...@@ -19302,7 +19320,7 @@ fn zirCondbr(
1930219320
19303fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {19321fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
19304 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;19322 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);
19306 const operand_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };19324 const operand_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
19307 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);19325 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);
19308 const body = sema.code.bodySlice(extra.end, extra.data.body_len);19326 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!...@@ -19349,7 +19367,7 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!
1934919367
19350fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {19368fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
19351 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;19369 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);
19353 const operand_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };19371 const operand_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node };
19354 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);19372 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);
19355 const body = sema.code.bodySlice(extra.end, extra.data.body_len);19373 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,...@@ -19474,7 +19492,7 @@ fn addRuntimeBreak(sema: *Sema, child_block: *Block, block_inst: Zir.Inst.Index,
1947419492
19475fn zirUnreachable(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {19493fn zirUnreachable(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
19476 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"unreachable";19494 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
19479 if (block.is_comptime) {19497 if (block.is_comptime) {
19480 return sema.fail(block, src, "reached unreachable code", .{});19498 return sema.fail(block, src, "reached unreachable code", .{});
...@@ -19498,13 +19516,13 @@ fn zirRetErrValue(...@@ -19498,13 +19516,13 @@ fn zirRetErrValue(
19498) CompileError!void {19516) CompileError!void {
19499 const mod = sema.mod;19517 const mod = sema.mod;
19500 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_tok;19518 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_tok;
19519 const src = block.tokenOffset(inst_data.src_tok);
19501 const err_name = try mod.intern_pool.getOrPutString(19520 const err_name = try mod.intern_pool.getOrPutString(
19502 sema.gpa,19521 sema.gpa,
19503 inst_data.get(sema.code),19522 inst_data.get(sema.code),
19504 .no_embedded_nulls,19523 .no_embedded_nulls,
19505 );19524 );
19506 _ = try mod.getErrorValue(err_name);19525 _ = try mod.getErrorValue(err_name);
19507 const src = inst_data.src();
19508 // Return the error code from the function.19526 // Return the error code from the function.
19509 const error_set_type = try mod.singleErrorSetType(err_name);19527 const error_set_type = try mod.singleErrorSetType(err_name);
19510 const result_inst = Air.internedToRef((try mod.intern(.{ .err = .{19528 const result_inst = Air.internedToRef((try mod.intern(.{ .err = .{
...@@ -19524,7 +19542,7 @@ fn zirRetImplicit(...@@ -19524,7 +19542,7 @@ fn zirRetImplicit(
1952419542
19525 const mod = sema.mod;19543 const mod = sema.mod;
19526 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok;19544 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);
19528 if (block.inlining == null and sema.func_is_naked) {19546 if (block.inlining == null and sema.func_is_naked) {
19529 assert(!block.is_comptime);19547 assert(!block.is_comptime);
19530 if (block.wantSafety()) {19548 if (block.wantSafety()) {
...@@ -19570,7 +19588,7 @@ fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi...@@ -19570,7 +19588,7 @@ fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi
1957019588
19571 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;19589 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
19572 const operand = try sema.resolveInst(inst_data.operand);19590 const operand = try sema.resolveInst(inst_data.operand);
19573 const src = inst_data.src();19591 const src = block.nodeOffset(inst_data.src_node);
1957419592
19575 return sema.analyzeRet(block, operand, src, .{ .node_offset_return_operand = inst_data.src_node });19593 return sema.analyzeRet(block, operand, src, .{ .node_offset_return_operand = inst_data.src_node });
19576}19594}
...@@ -19580,7 +19598,7 @@ fn zirRetLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi...@@ -19580,7 +19598,7 @@ fn zirRetLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi
19580 defer tracy.end();19598 defer tracy.end();
1958119599
19582 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;19600 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);
19584 const ret_ptr = try sema.resolveInst(inst_data.operand);19602 const ret_ptr = try sema.resolveInst(inst_data.operand);
1958519603
19586 if (block.is_comptime or block.inlining != null or sema.func_is_naked) {19604 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...@@ -19679,7 +19697,7 @@ fn zirSaveErrRetIndex(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
1967919697
19680fn zirRestoreErrRetIndex(sema: *Sema, start_block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {19698fn zirRestoreErrRetIndex(sema: *Sema, start_block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
19681 const extra = sema.code.extraData(Zir.Inst.RestoreErrRetIndex, extended.operand).data;19699 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);
19683}19701}
1968419702
19685/// If `operand` is non-error (or is `none`), restores the error return trace to19703/// 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...@@ -20006,7 +20024,7 @@ fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
20006 defer tracy.end();20024 defer tracy.end();
2000720025
20008 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;20026 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);
20010 const ty_src: LazySrcLoc = .{ .node_offset_init_ty = inst_data.src_node };20028 const ty_src: LazySrcLoc = .{ .node_offset_init_ty = inst_data.src_node };
20011 const obj_ty = try sema.resolveType(block, ty_src, inst_data.operand);20029 const obj_ty = try sema.resolveType(block, ty_src, inst_data.operand);
20012 const mod = sema.mod;20030 const mod = sema.mod;
...@@ -20026,7 +20044,7 @@ fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is...@@ -20026,7 +20044,7 @@ fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is
2002620044
20027 const mod = sema.mod;20045 const mod = sema.mod;
20028 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;20046 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);
20030 const ty_operand = sema.resolveType(block, src, inst_data.operand) catch |err| switch (err) {20048 const ty_operand = sema.resolveType(block, src, inst_data.operand) catch |err| switch (err) {
20031 // Generic poison means this is an untyped anonymous empty struct init20049 // Generic poison means this is an untyped anonymous empty struct init
20032 error.GenericPoison => return .empty_struct,20050 error.GenericPoison => return .empty_struct,
...@@ -20158,7 +20176,7 @@ fn zirStructInit(...@@ -20158,7 +20176,7 @@ fn zirStructInit(
20158 const zir_datas = sema.code.instructions.items(.data);20176 const zir_datas = sema.code.instructions.items(.data);
20159 const inst_data = zir_datas[@intFromEnum(inst)].pl_node;20177 const inst_data = zir_datas[@intFromEnum(inst)].pl_node;
20160 const extra = sema.code.extraData(Zir.Inst.StructInit, inst_data.payload_index);20178 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
20163 const mod = sema.mod;20181 const mod = sema.mod;
20164 const ip = &mod.intern_pool;20182 const ip = &mod.intern_pool;
...@@ -20503,7 +20521,7 @@ fn zirStructInitAnon(...@@ -20503,7 +20521,7 @@ fn zirStructInitAnon(
20503 inst: Zir.Inst.Index,20521 inst: Zir.Inst.Index,
20504) CompileError!Air.Inst.Ref {20522) CompileError!Air.Inst.Ref {
20505 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;20523 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);
20507 const extra = sema.code.extraData(Zir.Inst.StructInitAnon, inst_data.payload_index);20525 const extra = sema.code.extraData(Zir.Inst.StructInitAnon, inst_data.payload_index);
20508 return sema.structInitAnon(block, src, .anon_init, extra.data, extra.end, false);20526 return sema.structInitAnon(block, src, .anon_init, extra.data, extra.end, false);
20509}20527}
...@@ -20655,7 +20673,7 @@ fn zirArrayInit(...@@ -20655,7 +20673,7 @@ fn zirArrayInit(
20655 const mod = sema.mod;20673 const mod = sema.mod;
20656 const gpa = sema.gpa;20674 const gpa = sema.gpa;
20657 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;20675 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
20660 const extra = sema.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index);20678 const extra = sema.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index);
20661 const args = sema.code.refSlice(extra.end, extra.data.operands_len);20679 const args = sema.code.refSlice(extra.end, extra.data.operands_len);
...@@ -20818,7 +20836,7 @@ fn zirArrayInitAnon(...@@ -20818,7 +20836,7 @@ fn zirArrayInitAnon(
20818 inst: Zir.Inst.Index,20836 inst: Zir.Inst.Index,
20819) CompileError!Air.Inst.Ref {20837) CompileError!Air.Inst.Ref {
20820 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;20838 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);
20822 const extra = sema.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index);20840 const extra = sema.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index);
20823 const operands = sema.code.refSlice(extra.end, extra.data.operands_len);20841 const operands = sema.code.refSlice(extra.end, extra.data.operands_len);
20824 return sema.arrayInitAnon(block, src, operands, false);20842 return sema.arrayInitAnon(block, src, operands, false);
...@@ -20931,7 +20949,7 @@ fn zirStructInitFieldType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp...@@ -20931,7 +20949,7 @@ fn zirStructInitFieldType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
20931 const ip = &mod.intern_pool;20949 const ip = &mod.intern_pool;
20932 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;20950 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
20933 const extra = sema.code.extraData(Zir.Inst.FieldType, inst_data.payload_index).data;20951 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);
20935 const field_name_src: LazySrcLoc = .{ .node_offset_field_name_init = inst_data.src_node };20953 const field_name_src: LazySrcLoc = .{ .node_offset_field_name_init = inst_data.src_node };
20936 const wrapped_aggregate_ty = sema.resolveType(block, ty_src, extra.container_type) catch |err| switch (err) {20954 const wrapped_aggregate_ty = sema.resolveType(block, ty_src, extra.container_type) catch |err| switch (err) {
20937 // Since this is a ZIR instruction that returns a type, encountering20955 // 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...@@ -21054,7 +21072,7 @@ fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
21054fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {21072fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
21055 const mod = sema.mod;21073 const mod = sema.mod;
21056 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;21074 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);
21058 const operand = try sema.resolveInst(inst_data.operand);21076 const operand = try sema.resolveInst(inst_data.operand);
21059 const operand_ty = sema.typeOf(operand);21077 const operand_ty = sema.typeOf(operand);
21060 const is_vector = operand_ty.zigTypeTag(mod) == .Vector;21078 const is_vector = operand_ty.zigTypeTag(mod) == .Vector;
...@@ -21216,7 +21234,7 @@ fn zirUnaryMath(...@@ -21216,7 +21234,7 @@ fn zirUnaryMath(
21216fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {21234fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
21217 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;21235 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
21218 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };21236 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);
21220 const operand = try sema.resolveInst(inst_data.operand);21238 const operand = try sema.resolveInst(inst_data.operand);
21221 const operand_ty = sema.typeOf(operand);21239 const operand_ty = sema.typeOf(operand);
21222 const mod = sema.mod;21240 const mod = sema.mod;
...@@ -22512,20 +22530,20 @@ fn zirTypeName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -22512,20 +22530,20 @@ fn zirTypeName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
2251222530
22513fn zirFrameType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {22531fn zirFrameType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
22514 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;22532 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);
22516 return sema.failWithUseOfAsync(block, src);22534 return sema.failWithUseOfAsync(block, src);
22517}22535}
2251822536
22519fn zirFrameSize(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {22537fn zirFrameSize(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
22520 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;22538 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);
22522 return sema.failWithUseOfAsync(block, src);22540 return sema.failWithUseOfAsync(block, src);
22523}22541}
2252422542
22525fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {22543fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
22526 const mod = sema.mod;22544 const mod = sema.mod;
22527 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;22545 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);
22529 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;22547 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
22530 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };22548 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
22531 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@intFromFloat");22549 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...@@ -22550,7 +22568,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
22550 });22568 });
22551 }22569 }
2255222570
22553 try sema.requireRuntimeBlock(block, inst_data.src(), operand_src);22571 try sema.requireRuntimeBlock(block, src, operand_src);
22554 if (dest_scalar_ty.intInfo(mod).bits == 0) {22572 if (dest_scalar_ty.intInfo(mod).bits == 0) {
22555 if (!is_vector) {22573 if (!is_vector) {
22556 if (block.wantSafety()) {22574 if (block.wantSafety()) {
...@@ -22607,7 +22625,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -22607,7 +22625,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
22607fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {22625fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
22608 const mod = sema.mod;22626 const mod = sema.mod;
22609 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;22627 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);
22611 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;22629 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
22612 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };22630 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
22613 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@floatFromInt");22631 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...@@ -22649,7 +22667,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
22649fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {22667fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
22650 const mod = sema.mod;22668 const mod = sema.mod;
22651 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;22669 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
22654 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;22672 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...@@ -22934,7 +22952,7 @@ fn zirPtrCastFull(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDa
2293422952
22935fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {22953fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
22936 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;22954 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);
22938 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };22956 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
22939 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;22957 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
22940 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, "@ptrCast");22958 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...@@ -23381,7 +23399,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst
23381fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {23399fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
23382 const mod = sema.mod;23400 const mod = sema.mod;
23383 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;23401 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);
23385 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };23403 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
23386 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;23404 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
23387 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@truncate");23405 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@truncate");
...@@ -23471,7 +23489,7 @@ fn zirBitCount(...@@ -23471,7 +23489,7 @@ fn zirBitCount(
23471) CompileError!Air.Inst.Ref {23489) CompileError!Air.Inst.Ref {
23472 const mod = sema.mod;23490 const mod = sema.mod;
23473 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;23491 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);
23475 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };23493 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
23476 const operand = try sema.resolveInst(inst_data.operand);23494 const operand = try sema.resolveInst(inst_data.operand);
23477 const operand_ty = sema.typeOf(operand);23495 const operand_ty = sema.typeOf(operand);
...@@ -23525,7 +23543,7 @@ fn zirBitCount(...@@ -23525,7 +23543,7 @@ fn zirBitCount(
23525fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {23543fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
23526 const mod = sema.mod;23544 const mod = sema.mod;
23527 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;23545 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);
23529 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };23547 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
23530 const operand = try sema.resolveInst(inst_data.operand);23548 const operand = try sema.resolveInst(inst_data.operand);
23531 const operand_ty = sema.typeOf(operand);23549 const operand_ty = sema.typeOf(operand);
...@@ -23581,7 +23599,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -23581,7 +23599,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
2358123599
23582fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {23600fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
23583 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;23601 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);
23585 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };23603 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
23586 const operand = try sema.resolveInst(inst_data.operand);23604 const operand = try sema.resolveInst(inst_data.operand);
23587 const operand_ty = sema.typeOf(operand);23605 const operand_ty = sema.typeOf(operand);
...@@ -24290,7 +24308,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I...@@ -24290,7 +24308,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
24290 const mod = sema.mod;24308 const mod = sema.mod;
24291 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;24309 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
24292 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;24310 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);
24294 const scalar_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };24312 const scalar_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
24295 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@splat");24313 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...@@ -24312,7 +24330,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
24312 return Air.internedToRef((try sema.splat(dest_ty, scalar_val)).toIntern());24330 return Air.internedToRef((try sema.splat(dest_ty, scalar_val)).toIntern());
24313 }24331 }
2431424332
24315 try sema.requireRuntimeBlock(block, inst_data.src(), scalar_src);24333 try sema.requireRuntimeBlock(block, src, scalar_src);
24316 return block.addTyOp(.splat, dest_ty, scalar);24334 return block.addTyOp(.splat, dest_ty, scalar);
24317}24335}
2431824336
...@@ -24377,7 +24395,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -24377,7 +24395,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
24377 return Air.internedToRef(accum.toIntern());24395 return Air.internedToRef(accum.toIntern());
24378 }24396 }
2437924397
24380 try sema.requireRuntimeBlock(block, inst_data.src(), operand_src);24398 try sema.requireRuntimeBlock(block, block.nodeOffset(inst_data.src_node), operand_src);
24381 return block.addInst(.{24399 return block.addInst(.{
24382 .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce,24400 .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce,
24383 .data = .{ .reduce = .{24401 .data = .{ .reduce = .{
...@@ -24704,7 +24722,7 @@ fn zirAtomicLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -24704,7 +24722,7 @@ fn zirAtomicLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
24704 }24722 }
24705 }24723 }
2470624724
24707 try sema.requireRuntimeBlock(block, inst_data.src(), ptr_src);24725 try sema.requireRuntimeBlock(block, block.nodeOffset(inst_data.src_node), ptr_src);
24708 return block.addInst(.{24726 return block.addInst(.{
24709 .tag = .atomic_load,24727 .tag = .atomic_load,
24710 .data = .{ .atomic_load = .{24728 .data = .{ .atomic_load = .{
...@@ -24718,7 +24736,7 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -24718,7 +24736,7 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
24718 const mod = sema.mod;24736 const mod = sema.mod;
24719 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;24737 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
24720 const extra = sema.code.extraData(Zir.Inst.AtomicRmw, inst_data.payload_index).data;24738 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);
24722 // zig fmt: off24740 // zig fmt: off
24723 const elem_ty_src : LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };24741 const elem_ty_src : LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
24724 const ptr_src : LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };24742 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...@@ -24803,7 +24821,7 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
24803fn zirAtomicStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {24821fn zirAtomicStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
24804 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;24822 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
24805 const extra = sema.code.extraData(Zir.Inst.AtomicStore, inst_data.payload_index).data;24823 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);
24807 // zig fmt: off24825 // zig fmt: off
24808 const elem_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };24826 const elem_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
24809 const ptr_src : LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };24827 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...@@ -24839,7 +24857,7 @@ fn zirAtomicStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
24839fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {24857fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
24840 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;24858 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
24841 const extra = sema.code.extraData(Zir.Inst.MulAdd, inst_data.payload_index).data;24859 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
24844 const mulend1_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };24862 const mulend1_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
24845 const mulend2_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node };24863 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...@@ -24909,7 +24927,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
24909 const modifier_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };24927 const modifier_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
24910 const func_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };24928 const func_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
24911 const args_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node };24929 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
24914 const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data;24932 const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data;
24915 const func = try sema.resolveInst(extra.callee);24933 const func = try sema.resolveInst(extra.callee);
...@@ -25003,7 +25021,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins...@@ -25003,7 +25021,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins
25003 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?;25021 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?;
25004 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small)));25022 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small)));
25005 assert(!flags.ptr_cast);25023 assert(!flags.ptr_cast);
25006 const inst_src = extra.src();25024 const inst_src = block.nodeOffset(extra.src_node);
25007 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.src_node };25025 const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.src_node };
25008 const field_ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.src_node };25026 const field_ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.src_node };
2500925027
...@@ -25213,7 +25231,7 @@ fn zirMinMax(...@@ -25213,7 +25231,7 @@ fn zirMinMax(
25213) CompileError!Air.Inst.Ref {25231) CompileError!Air.Inst.Ref {
25214 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;25232 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
25215 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;25233 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);
25217 const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };25235 const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
25218 const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };25236 const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
25219 const lhs = try sema.resolveInst(extra.lhs);25237 const lhs = try sema.resolveInst(extra.lhs);
...@@ -25514,7 +25532,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A...@@ -25514,7 +25532,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A
25514fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {25532fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void {
25515 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;25533 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
25516 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;25534 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);
25518 const dest_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };25536 const dest_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
25519 const src_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };25537 const src_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
25520 const dest_ptr = try sema.resolveInst(extra.lhs);25538 const dest_ptr = try sema.resolveInst(extra.lhs);
...@@ -25734,7 +25752,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -25734,7 +25752,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
25734 const ip = &mod.intern_pool;25752 const ip = &mod.intern_pool;
25735 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;25753 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
25736 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;25754 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);
25738 const dest_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };25756 const dest_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
25739 const value_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };25757 const value_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node };
25740 const dest_ptr = try sema.resolveInst(extra.lhs);25758 const dest_ptr = try sema.resolveInst(extra.lhs);
...@@ -25819,7 +25837,7 @@ fn zirBuiltinAsyncCall(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.I...@@ -25819,7 +25837,7 @@ fn zirBuiltinAsyncCall(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.I
2581925837
25820fn zirResume(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {25838fn zirResume(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
25821 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;25839 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);
25823 return sema.failWithUseOfAsync(block, src);25841 return sema.failWithUseOfAsync(block, src);
25824}25842}
2582525843
...@@ -25829,7 +25847,7 @@ fn zirAwait(...@@ -25829,7 +25847,7 @@ fn zirAwait(
25829 inst: Zir.Inst.Index,25847 inst: Zir.Inst.Index,
25830) CompileError!Air.Inst.Ref {25848) CompileError!Air.Inst.Ref {
25831 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;25849 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
25834 return sema.failWithUseOfAsync(block, src);25852 return sema.failWithUseOfAsync(block, src);
25835}25853}
src/Sema/comptime_ptr_access.zig+2-1
...@@ -1048,7 +1048,6 @@ fn checkComptimeVarStore(...@@ -1048,7 +1048,6 @@ fn checkComptimeVarStore(
1048const std = @import("std");1048const std = @import("std");
1049const assert = std.debug.assert;1049const assert = std.debug.assert;
1050const Allocator = std.mem.Allocator;1050const Allocator = std.mem.Allocator;
1051const LazySrcLoc = std.zig.LazySrcLoc;
10521051
1053const InternPool = @import("../InternPool.zig");1052const InternPool = @import("../InternPool.zig");
1054const ComptimeAllocIndex = InternPool.ComptimeAllocIndex;1053const ComptimeAllocIndex = InternPool.ComptimeAllocIndex;
...@@ -1057,3 +1056,5 @@ const Block = Sema.Block;...@@ -1057,3 +1056,5 @@ const Block = Sema.Block;
1057const MutableValue = @import("../mutable_value.zig").MutableValue;1056const MutableValue = @import("../mutable_value.zig").MutableValue;
1058const Type = @import("../type.zig").Type;1057const Type = @import("../type.zig").Type;
1059const Value = @import("../Value.zig");1058const 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;...@@ -16,7 +16,7 @@ const Decl = Module.Decl;
16const Type = @import("../../type.zig").Type;16const Type = @import("../../type.zig").Type;
17const Value = @import("../../Value.zig");17const Value = @import("../../Value.zig");
18const Compilation = @import("../../Compilation.zig");18const Compilation = @import("../../Compilation.zig");
19const LazySrcLoc = std.zig.LazySrcLoc;19const LazySrcLoc = Module.LazySrcLoc;
20const link = @import("../../link.zig");20const link = @import("../../link.zig");
21const Air = @import("../../Air.zig");21const Air = @import("../../Air.zig");
22const Liveness = @import("../../Liveness.zig");22const Liveness = @import("../../Liveness.zig");
src/codegen/c.zig+1-1
...@@ -13,7 +13,7 @@ const Type = @import("../type.zig").Type;...@@ -13,7 +13,7 @@ const Type = @import("../type.zig").Type;
13const C = link.File.C;13const C = link.File.C;
14const Decl = Zcu.Decl;14const Decl = Zcu.Decl;
15const trace = @import("../tracy.zig").trace;15const trace = @import("../tracy.zig").trace;
16const LazySrcLoc = std.zig.LazySrcLoc;16const LazySrcLoc = Zcu.LazySrcLoc;
17const Air = @import("../Air.zig");17const Air = @import("../Air.zig");
18const Liveness = @import("../Liveness.zig");18const Liveness = @import("../Liveness.zig");
19const InternPool = @import("../InternPool.zig");19const InternPool = @import("../InternPool.zig");
src/codegen/c/Type.zig+1-1
...@@ -2581,8 +2581,8 @@ pub const AlignAs = packed struct {...@@ -2581,8 +2581,8 @@ pub const AlignAs = packed struct {
2581const Alignment = @import("../../InternPool.zig").Alignment;2581const Alignment = @import("../../InternPool.zig").Alignment;
2582const assert = std.debug.assert;2582const assert = std.debug.assert;
2583const CType = @This();2583const CType = @This();
2584const DeclIndex = std.zig.DeclIndex;
2585const Module = @import("../../Package/Module.zig");2584const Module = @import("../../Package/Module.zig");
2586const std = @import("std");2585const std = @import("std");
2587const Type = @import("../../type.zig").Type;2586const Type = @import("../../type.zig").Type;
2588const Zcu = @import("../../Module.zig");2587const 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");...@@ -22,7 +22,7 @@ const Air = @import("../Air.zig");
22const Liveness = @import("../Liveness.zig");22const Liveness = @import("../Liveness.zig");
23const Value = @import("../Value.zig");23const Value = @import("../Value.zig");
24const Type = @import("../type.zig").Type;24const Type = @import("../type.zig").Type;
25const LazySrcLoc = std.zig.LazySrcLoc;25const LazySrcLoc = Zcu.LazySrcLoc;
26const x86_64_abi = @import("../arch/x86_64/abi.zig");26const x86_64_abi = @import("../arch/x86_64/abi.zig");
27const wasm_c_abi = @import("../arch/wasm/abi.zig");27const wasm_c_abi = @import("../arch/wasm/abi.zig");
28const aarch64_c_abi = @import("../arch/aarch64/abi.zig");28const aarch64_c_abi = @import("../arch/aarch64/abi.zig");
src/codegen/spirv.zig+1-1
...@@ -9,7 +9,7 @@ const Module = @import("../Module.zig");...@@ -9,7 +9,7 @@ const Module = @import("../Module.zig");
9const Decl = Module.Decl;9const Decl = Module.Decl;
10const Type = @import("../type.zig").Type;10const Type = @import("../type.zig").Type;
11const Value = @import("../Value.zig");11const Value = @import("../Value.zig");
12const LazySrcLoc = std.zig.LazySrcLoc;12const LazySrcLoc = Module.LazySrcLoc;
13const Air = @import("../Air.zig");13const Air = @import("../Air.zig");
14const Liveness = @import("../Liveness.zig");14const Liveness = @import("../Liveness.zig");
15const InternPool = @import("../InternPool.zig");15const InternPool = @import("../InternPool.zig");
src/print_zir.zig+70-71
...@@ -6,8 +6,9 @@ const Ast = std.zig.Ast;...@@ -6,8 +6,9 @@ const Ast = std.zig.Ast;
6const InternPool = @import("InternPool.zig");6const InternPool = @import("InternPool.zig");
77
8const Zir = std.zig.Zir;8const Zir = std.zig.Zir;
9const Module = @import("Module.zig");9const Zcu = @import("Module.zig");
10const LazySrcLoc = std.zig.LazySrcLoc;10const Module = Zcu;
11const LazySrcLoc = Zcu.LazySrcLoc;
1112
12/// Write human-readable, debug formatted ZIR code to a file.13/// Write human-readable, debug formatted ZIR code to a file.
13pub fn renderAsTextToFile(14pub fn renderAsTextToFile(
...@@ -630,7 +631,7 @@ const Writer = struct {...@@ -630,7 +631,7 @@ const Writer = struct {
630 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].un_node;631 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
631 try self.writeInstRef(stream, inst_data.operand);632 try self.writeInstRef(stream, inst_data.operand);
632 try stream.writeAll(") ");633 try stream.writeAll(") ");
633 try self.writeSrc(stream, inst_data.src());634 try self.writeSrcNode(stream, inst_data.src_node);
634 }635 }
635636
636 fn writeUnTok(637 fn writeUnTok(
...@@ -641,7 +642,7 @@ const Writer = struct {...@@ -641,7 +642,7 @@ const Writer = struct {
641 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].un_tok;642 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].un_tok;
642 try self.writeInstRef(stream, inst_data.operand);643 try self.writeInstRef(stream, inst_data.operand);
643 try stream.writeAll(") ");644 try stream.writeAll(") ");
644 try self.writeSrc(stream, inst_data.src());645 try self.writeSrcTok(stream, inst_data.src_tok);
645 }646 }
646647
647 fn writeValidateDestructure(648 fn writeValidateDestructure(
...@@ -655,7 +656,7 @@ const Writer = struct {...@@ -655,7 +656,7 @@ const Writer = struct {
655 try stream.print(", {d}) (destructure=", .{extra.expect_len});656 try stream.print(", {d}) (destructure=", .{extra.expect_len});
656 try self.writeSrc(stream, LazySrcLoc.nodeOffset(extra.destructure_node));657 try self.writeSrc(stream, LazySrcLoc.nodeOffset(extra.destructure_node));
657 try stream.writeAll(") ");658 try stream.writeAll(") ");
658 try self.writeSrc(stream, inst_data.src());659 try self.writeSrcNode(stream, inst_data.src_node);
659 }660 }
660661
661 fn writeValidateArrayInitTy(662 fn writeValidateArrayInitTy(
...@@ -667,7 +668,7 @@ const Writer = struct {...@@ -667,7 +668,7 @@ const Writer = struct {
667 const extra = self.code.extraData(Zir.Inst.ArrayInit, inst_data.payload_index).data;668 const extra = self.code.extraData(Zir.Inst.ArrayInit, inst_data.payload_index).data;
668 try self.writeInstRef(stream, extra.ty);669 try self.writeInstRef(stream, extra.ty);
669 try stream.print(", {d}) ", .{extra.init_count});670 try stream.print(", {d}) ", .{extra.init_count});
670 try self.writeSrc(stream, inst_data.src());671 try self.writeSrcNode(stream, inst_data.src_node);
671 }672 }
672673
673 fn writeArrayTypeSentinel(674 fn writeArrayTypeSentinel(
...@@ -683,7 +684,7 @@ const Writer = struct {...@@ -683,7 +684,7 @@ const Writer = struct {
683 try stream.writeAll(", ");684 try stream.writeAll(", ");
684 try self.writeInstRef(stream, extra.elem_type);685 try self.writeInstRef(stream, extra.elem_type);
685 try stream.writeAll(") ");686 try stream.writeAll(") ");
686 try self.writeSrc(stream, inst_data.src());687 try self.writeSrcNode(stream, inst_data.src_node);
687 }688 }
688689
689 fn writePtrType(690 fn writePtrType(
...@@ -763,11 +764,10 @@ const Writer = struct {...@@ -763,11 +764,10 @@ const Writer = struct {
763 fn writeFloat128(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {764 fn writeFloat128(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
764 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;765 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
765 const extra = self.code.extraData(Zir.Inst.Float128, inst_data.payload_index).data;766 const extra = self.code.extraData(Zir.Inst.Float128, inst_data.payload_index).data;
766 const src = inst_data.src();
767 const number = extra.get();767 const number = extra.get();
768 // TODO improve std.format to be able to print f128 values768 // TODO improve std.format to be able to print f128 values
769 try stream.print("{d}) ", .{@as(f64, @floatCast(number))});769 try stream.print("{d}) ", .{@as(f64, @floatCast(number))});
770 try self.writeSrc(stream, src);770 try self.writeSrcNode(stream, inst_data.src_node);
771 }771 }
772772
773 fn writeStr(773 fn writeStr(
...@@ -787,7 +787,7 @@ const Writer = struct {...@@ -787,7 +787,7 @@ const Writer = struct {
787 try stream.writeAll(", ");787 try stream.writeAll(", ");
788 try self.writeInstRef(stream, extra.start);788 try self.writeInstRef(stream, extra.start);
789 try stream.writeAll(") ");789 try stream.writeAll(") ");
790 try self.writeSrc(stream, inst_data.src());790 try self.writeSrcNode(stream, inst_data.src_node);
791 }791 }
792792
793 fn writeSliceEnd(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {793 fn writeSliceEnd(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -799,7 +799,7 @@ const Writer = struct {...@@ -799,7 +799,7 @@ const Writer = struct {
799 try stream.writeAll(", ");799 try stream.writeAll(", ");
800 try self.writeInstRef(stream, extra.end);800 try self.writeInstRef(stream, extra.end);
801 try stream.writeAll(") ");801 try stream.writeAll(") ");
802 try self.writeSrc(stream, inst_data.src());802 try self.writeSrcNode(stream, inst_data.src_node);
803 }803 }
804804
805 fn writeSliceSentinel(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {805 fn writeSliceSentinel(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -813,7 +813,7 @@ const Writer = struct {...@@ -813,7 +813,7 @@ const Writer = struct {
813 try stream.writeAll(", ");813 try stream.writeAll(", ");
814 try self.writeInstRef(stream, extra.sentinel);814 try self.writeInstRef(stream, extra.sentinel);
815 try stream.writeAll(") ");815 try stream.writeAll(") ");
816 try self.writeSrc(stream, inst_data.src());816 try self.writeSrcNode(stream, inst_data.src_node);
817 }817 }
818818
819 fn writeSliceLength(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {819 fn writeSliceLength(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -829,7 +829,7 @@ const Writer = struct {...@@ -829,7 +829,7 @@ const Writer = struct {
829 try self.writeInstRef(stream, extra.sentinel);829 try self.writeInstRef(stream, extra.sentinel);
830 }830 }
831 try stream.writeAll(") ");831 try stream.writeAll(") ");
832 try self.writeSrc(stream, inst_data.src());832 try self.writeSrcNode(stream, inst_data.src_node);
833 }833 }
834834
835 fn writeUnionInit(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {835 fn writeUnionInit(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -841,7 +841,7 @@ const Writer = struct {...@@ -841,7 +841,7 @@ const Writer = struct {
841 try stream.writeAll(", ");841 try stream.writeAll(", ");
842 try self.writeInstRef(stream, extra.init);842 try self.writeInstRef(stream, extra.init);
843 try stream.writeAll(") ");843 try stream.writeAll(") ");
844 try self.writeSrc(stream, inst_data.src());844 try self.writeSrcNode(stream, inst_data.src_node);
845 }845 }
846846
847 fn writeShuffle(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {847 fn writeShuffle(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -855,7 +855,7 @@ const Writer = struct {...@@ -855,7 +855,7 @@ const Writer = struct {
855 try stream.writeAll(", ");855 try stream.writeAll(", ");
856 try self.writeInstRef(stream, extra.mask);856 try self.writeInstRef(stream, extra.mask);
857 try stream.writeAll(") ");857 try stream.writeAll(") ");
858 try self.writeSrc(stream, inst_data.src());858 try self.writeSrcNode(stream, inst_data.src_node);
859 }859 }
860860
861 fn writeSelect(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {861 fn writeSelect(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {
...@@ -880,7 +880,7 @@ const Writer = struct {...@@ -880,7 +880,7 @@ const Writer = struct {
880 try stream.writeAll(", ");880 try stream.writeAll(", ");
881 try self.writeInstRef(stream, extra.addend);881 try self.writeInstRef(stream, extra.addend);
882 try stream.writeAll(") ");882 try stream.writeAll(") ");
883 try self.writeSrc(stream, inst_data.src());883 try self.writeSrcNode(stream, inst_data.src_node);
884 }884 }
885885
886 fn writeBuiltinCall(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {886 fn writeBuiltinCall(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -896,7 +896,7 @@ const Writer = struct {...@@ -896,7 +896,7 @@ const Writer = struct {
896 try stream.writeAll(", ");896 try stream.writeAll(", ");
897 try self.writeInstRef(stream, extra.args);897 try self.writeInstRef(stream, extra.args);
898 try stream.writeAll(") ");898 try stream.writeAll(") ");
899 try self.writeSrc(stream, inst_data.src());899 try self.writeSrcNode(stream, inst_data.src_node);
900 }900 }
901901
902 fn writeFieldParentPtr(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {902 fn writeFieldParentPtr(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {
...@@ -913,7 +913,7 @@ const Writer = struct {...@@ -913,7 +913,7 @@ const Writer = struct {
913 try stream.writeAll(", ");913 try stream.writeAll(", ");
914 try self.writeInstRef(stream, extra.field_ptr);914 try self.writeInstRef(stream, extra.field_ptr);
915 try stream.writeAll(") ");915 try stream.writeAll(") ");
916 try self.writeSrc(stream, extra.src());916 try self.writeSrcNode(stream, extra.src_node);
917 }917 }
918918
919 fn writeBuiltinAsyncCall(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {919 fn writeBuiltinAsyncCall(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {
...@@ -944,7 +944,7 @@ const Writer = struct {...@@ -944,7 +944,7 @@ const Writer = struct {
944 }944 }
945 try self.writeBracedBody(stream, body);945 try self.writeBracedBody(stream, body);
946 try stream.writeAll(") ");946 try stream.writeAll(") ");
947 try self.writeSrc(stream, inst_data.src());947 try self.writeSrcTok(stream, inst_data.src_tok);
948 }948 }
949949
950 fn writePlNodeBin(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {950 fn writePlNodeBin(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -954,7 +954,7 @@ const Writer = struct {...@@ -954,7 +954,7 @@ const Writer = struct {
954 try stream.writeAll(", ");954 try stream.writeAll(", ");
955 try self.writeInstRef(stream, extra.rhs);955 try self.writeInstRef(stream, extra.rhs);
956 try stream.writeAll(") ");956 try stream.writeAll(") ");
957 try self.writeSrc(stream, inst_data.src());957 try self.writeSrcNode(stream, inst_data.src_node);
958 }958 }
959959
960 fn writePlNodeMultiOp(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {960 fn writePlNodeMultiOp(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -967,7 +967,7 @@ const Writer = struct {...@@ -967,7 +967,7 @@ const Writer = struct {
967 try self.writeInstRef(stream, arg);967 try self.writeInstRef(stream, arg);
968 }968 }
969 try stream.writeAll("}) ");969 try stream.writeAll("}) ");
970 try self.writeSrc(stream, inst_data.src());970 try self.writeSrcNode(stream, inst_data.src_node);
971 }971 }
972972
973 fn writeArrayMul(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {973 fn writeArrayMul(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -979,7 +979,7 @@ const Writer = struct {...@@ -979,7 +979,7 @@ const Writer = struct {
979 try stream.writeAll(", ");979 try stream.writeAll(", ");
980 try self.writeInstRef(stream, extra.rhs);980 try self.writeInstRef(stream, extra.rhs);
981 try stream.writeAll(") ");981 try stream.writeAll(") ");
982 try self.writeSrc(stream, inst_data.src());982 try self.writeSrcNode(stream, inst_data.src_node);
983 }983 }
984984
985 fn writeElemValImm(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {985 fn writeElemValImm(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -994,7 +994,7 @@ const Writer = struct {...@@ -994,7 +994,7 @@ const Writer = struct {
994994
995 try self.writeInstRef(stream, extra.ptr);995 try self.writeInstRef(stream, extra.ptr);
996 try stream.print(", {d}) ", .{extra.index});996 try stream.print(", {d}) ", .{extra.index});
997 try self.writeSrc(stream, inst_data.src());997 try self.writeSrcNode(stream, inst_data.src_node);
998 }998 }
999999
1000 fn writePlNodeExport(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {1000 fn writePlNodeExport(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -1006,7 +1006,7 @@ const Writer = struct {...@@ -1006,7 +1006,7 @@ const Writer = struct {
1006 try stream.print(", {p}, ", .{std.zig.fmtId(decl_name)});1006 try stream.print(", {p}, ", .{std.zig.fmtId(decl_name)});
1007 try self.writeInstRef(stream, extra.options);1007 try self.writeInstRef(stream, extra.options);
1008 try stream.writeAll(") ");1008 try stream.writeAll(") ");
1009 try self.writeSrc(stream, inst_data.src());1009 try self.writeSrcNode(stream, inst_data.src_node);
1010 }1010 }
10111011
1012 fn writePlNodeExportValue(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {1012 fn writePlNodeExportValue(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -1017,7 +1017,7 @@ const Writer = struct {...@@ -1017,7 +1017,7 @@ const Writer = struct {
1017 try stream.writeAll(", ");1017 try stream.writeAll(", ");
1018 try self.writeInstRef(stream, extra.options);1018 try self.writeInstRef(stream, extra.options);
1019 try stream.writeAll(") ");1019 try stream.writeAll(") ");
1020 try self.writeSrc(stream, inst_data.src());1020 try self.writeSrcNode(stream, inst_data.src_node);
1021 }1021 }
10221022
1023 fn writeValidateArrayInitRefTy(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {1023 fn writeValidateArrayInitRefTy(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -1027,7 +1027,7 @@ const Writer = struct {...@@ -1027,7 +1027,7 @@ const Writer = struct {
1027 try self.writeInstRef(stream, extra.ptr_ty);1027 try self.writeInstRef(stream, extra.ptr_ty);
1028 try stream.writeAll(", ");1028 try stream.writeAll(", ");
1029 try stream.print(", {}) ", .{extra.elem_count});1029 try stream.print(", {}) ", .{extra.elem_count});
1030 try self.writeSrc(stream, inst_data.src());1030 try self.writeSrcNode(stream, inst_data.src_node);
1031 }1031 }
10321032
1033 fn writeStructInit(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {1033 fn writeStructInit(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -1051,7 +1051,7 @@ const Writer = struct {...@@ -1051,7 +1051,7 @@ const Writer = struct {
1051 try stream.writeAll("]");1051 try stream.writeAll("]");
1052 }1052 }
1053 try stream.writeAll(") ");1053 try stream.writeAll(") ");
1054 try self.writeSrc(stream, inst_data.src());1054 try self.writeSrcNode(stream, inst_data.src_node);
1055 }1055 }
10561056
1057 fn writeCmpxchg(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {1057 fn writeCmpxchg(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {
...@@ -1110,7 +1110,7 @@ const Writer = struct {...@@ -1110,7 +1110,7 @@ const Writer = struct {
1110 try stream.writeAll(", ");1110 try stream.writeAll(", ");
1111 try self.writeInstRef(stream, extra.ordering);1111 try self.writeInstRef(stream, extra.ordering);
1112 try stream.writeAll(") ");1112 try stream.writeAll(") ");
1113 try self.writeSrc(stream, inst_data.src());1113 try self.writeSrcNode(stream, inst_data.src_node);
1114 }1114 }
11151115
1116 fn writeAtomicStore(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {1116 fn writeAtomicStore(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -1123,7 +1123,7 @@ const Writer = struct {...@@ -1123,7 +1123,7 @@ const Writer = struct {
1123 try stream.writeAll(", ");1123 try stream.writeAll(", ");
1124 try self.writeInstRef(stream, extra.ordering);1124 try self.writeInstRef(stream, extra.ordering);
1125 try stream.writeAll(") ");1125 try stream.writeAll(") ");
1126 try self.writeSrc(stream, inst_data.src());1126 try self.writeSrcNode(stream, inst_data.src_node);
1127 }1127 }
11281128
1129 fn writeAtomicRmw(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {1129 fn writeAtomicRmw(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -1138,7 +1138,7 @@ const Writer = struct {...@@ -1138,7 +1138,7 @@ const Writer = struct {
1138 try stream.writeAll(", ");1138 try stream.writeAll(", ");
1139 try self.writeInstRef(stream, extra.ordering);1139 try self.writeInstRef(stream, extra.ordering);
1140 try stream.writeAll(") ");1140 try stream.writeAll(") ");
1141 try self.writeSrc(stream, inst_data.src());1141 try self.writeSrcNode(stream, inst_data.src_node);
1142 }1142 }
11431143
1144 fn writeStructInitAnon(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {1144 fn writeStructInitAnon(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -1159,7 +1159,7 @@ const Writer = struct {...@@ -1159,7 +1159,7 @@ const Writer = struct {
1159 try stream.writeAll("]");1159 try stream.writeAll("]");
1160 }1160 }
1161 try stream.writeAll(") ");1161 try stream.writeAll(") ");
1162 try self.writeSrc(stream, inst_data.src());1162 try self.writeSrcNode(stream, inst_data.src_node);
1163 }1163 }
11641164
1165 fn writeStructInitFieldType(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {1165 fn writeStructInitFieldType(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -1168,7 +1168,7 @@ const Writer = struct {...@@ -1168,7 +1168,7 @@ const Writer = struct {
1168 try self.writeInstRef(stream, extra.container_type);1168 try self.writeInstRef(stream, extra.container_type);
1169 const field_name = self.code.nullTerminatedString(extra.name_start);1169 const field_name = self.code.nullTerminatedString(extra.name_start);
1170 try stream.print(", {s}) ", .{field_name});1170 try stream.print(", {s}) ", .{field_name});
1171 try self.writeSrc(stream, inst_data.src());1171 try self.writeSrcNode(stream, inst_data.src_node);
1172 }1172 }
11731173
1174 fn writeFieldTypeRef(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {1174 fn writeFieldTypeRef(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -1178,7 +1178,7 @@ const Writer = struct {...@@ -1178,7 +1178,7 @@ const Writer = struct {
1178 try stream.writeAll(", ");1178 try stream.writeAll(", ");
1179 try self.writeInstRef(stream, extra.field_name);1179 try self.writeInstRef(stream, extra.field_name);
1180 try stream.writeAll(") ");1180 try stream.writeAll(") ");
1181 try self.writeSrc(stream, inst_data.src());1181 try self.writeSrcNode(stream, inst_data.src_node);
1182 }1182 }
11831183
1184 fn writeNodeMultiOp(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {1184 fn writeNodeMultiOp(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {
...@@ -1202,7 +1202,7 @@ const Writer = struct {...@@ -1202,7 +1202,7 @@ const Writer = struct {
1202 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].inst_node;1202 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].inst_node;
1203 try self.writeInstIndex(stream, inst_data.inst);1203 try self.writeInstIndex(stream, inst_data.inst);
1204 try stream.writeAll(") ");1204 try stream.writeAll(") ");
1205 try self.writeSrc(stream, inst_data.src());1205 try self.writeSrcNode(stream, inst_data.src_node);
1206 }1206 }
12071207
1208 fn writeAsm(1208 fn writeAsm(
...@@ -1347,13 +1347,13 @@ const Writer = struct {...@@ -1347,13 +1347,13 @@ const Writer = struct {
1347 }1347 }
13481348
1349 try stream.writeAll("]) ");1349 try stream.writeAll("]) ");
1350 try self.writeSrc(stream, inst_data.src());1350 try self.writeSrcNode(stream, inst_data.src_node);
1351 }1351 }
13521352
1353 fn writeBlock(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {1353 fn writeBlock(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
1354 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;1354 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
1355 try self.writePlNodeBlockWithoutSrc(stream, inst);1355 try self.writePlNodeBlockWithoutSrc(stream, inst);
1356 try self.writeSrc(stream, inst_data.src());1356 try self.writeSrcNode(stream, inst_data.src_node);
1357 }1357 }
13581358
1359 fn writePlNodeBlockWithoutSrc(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {1359 fn writePlNodeBlockWithoutSrc(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -1375,7 +1375,7 @@ const Writer = struct {...@@ -1375,7 +1375,7 @@ const Writer = struct {
1375 try stream.writeAll(", ");1375 try stream.writeAll(", ");
1376 try self.writeBracedBody(stream, else_body);1376 try self.writeBracedBody(stream, else_body);
1377 try stream.writeAll(") ");1377 try stream.writeAll(") ");
1378 try self.writeSrc(stream, inst_data.src());1378 try self.writeSrcNode(stream, inst_data.src_node);
1379 }1379 }
13801380
1381 fn writeTry(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {1381 fn writeTry(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -1386,7 +1386,7 @@ const Writer = struct {...@@ -1386,7 +1386,7 @@ const Writer = struct {
1386 try stream.writeAll(", ");1386 try stream.writeAll(", ");
1387 try self.writeBracedBody(stream, body);1387 try self.writeBracedBody(stream, body);
1388 try stream.writeAll(") ");1388 try stream.writeAll(") ");
1389 try self.writeSrc(stream, inst_data.src());1389 try self.writeSrcNode(stream, inst_data.src_node);
1390 }1390 }
13911391
1392 fn writeStructDecl(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {1392 fn writeStructDecl(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {
...@@ -1480,7 +1480,7 @@ const Writer = struct {...@@ -1480,7 +1480,7 @@ const Writer = struct {
1480 }1480 }
14811481
1482 if (fields_len == 0) {1482 if (fields_len == 0) {
1483 try stream.writeAll("{}, {})");1483 try stream.writeAll("{}, {}) ");
1484 } else {1484 } else {
1485 const bits_per_field = 4;1485 const bits_per_field = 4;
1486 const fields_per_u32 = 32 / bits_per_field;1486 const fields_per_u32 = 32 / bits_per_field;
...@@ -1596,7 +1596,7 @@ const Writer = struct {...@@ -1596,7 +1596,7 @@ const Writer = struct {
15961596
1597 self.indent -= 2;1597 self.indent -= 2;
1598 try stream.writeByteNTimes(' ', self.indent);1598 try stream.writeByteNTimes(' ', self.indent);
1599 try stream.writeAll("})");1599 try stream.writeAll("}) ");
1600 }1600 }
1601 try self.writeSrcNode(stream, 0);1601 try self.writeSrcNode(stream, 0);
1602 }1602 }
...@@ -1688,7 +1688,7 @@ const Writer = struct {...@@ -1688,7 +1688,7 @@ const Writer = struct {
1688 }1688 }
16891689
1690 if (fields_len == 0) {1690 if (fields_len == 0) {
1691 try stream.writeAll("})");1691 try stream.writeAll("}) ");
1692 try self.writeSrcNode(stream, 0);1692 try self.writeSrcNode(stream, 0);
1693 return;1693 return;
1694 }1694 }
...@@ -1762,7 +1762,7 @@ const Writer = struct {...@@ -1762,7 +1762,7 @@ const Writer = struct {
17621762
1763 self.indent -= 2;1763 self.indent -= 2;
1764 try stream.writeByteNTimes(' ', self.indent);1764 try stream.writeByteNTimes(' ', self.indent);
1765 try stream.writeAll("})");1765 try stream.writeAll("}) ");
1766 try self.writeSrcNode(stream, 0);1766 try self.writeSrcNode(stream, 0);
1767 }1767 }
17681768
...@@ -1855,7 +1855,7 @@ const Writer = struct {...@@ -1855,7 +1855,7 @@ const Writer = struct {
18551855
1856 try self.writeBracedDecl(stream, body);1856 try self.writeBracedDecl(stream, body);
1857 if (fields_len == 0) {1857 if (fields_len == 0) {
1858 try stream.writeAll(", {})");1858 try stream.writeAll(", {}) ");
1859 } else {1859 } else {
1860 try stream.writeAll(", {\n");1860 try stream.writeAll(", {\n");
18611861
...@@ -1896,7 +1896,7 @@ const Writer = struct {...@@ -1896,7 +1896,7 @@ const Writer = struct {
1896 }1896 }
1897 self.indent -= 2;1897 self.indent -= 2;
1898 try stream.writeByteNTimes(' ', self.indent);1898 try stream.writeByteNTimes(' ', self.indent);
1899 try stream.writeAll("})");1899 try stream.writeAll("}) ");
1900 }1900 }
1901 try self.writeSrcNode(stream, 0);1901 try self.writeSrcNode(stream, 0);
1902 }1902 }
...@@ -1944,14 +1944,14 @@ const Writer = struct {...@@ -1944,14 +1944,14 @@ const Writer = struct {
1944 }1944 }
19451945
1946 if (decls_len == 0) {1946 if (decls_len == 0) {
1947 try stream.writeAll("{})");1947 try stream.writeAll("{}) ");
1948 } else {1948 } else {
1949 try stream.writeAll("{\n");1949 try stream.writeAll("{\n");
1950 self.indent += 2;1950 self.indent += 2;
1951 try self.writeBody(stream, self.code.bodySlice(extra_index, decls_len));1951 try self.writeBody(stream, self.code.bodySlice(extra_index, decls_len));
1952 self.indent -= 2;1952 self.indent -= 2;
1953 try stream.writeByteNTimes(' ', self.indent);1953 try stream.writeByteNTimes(' ', self.indent);
1954 try stream.writeAll("})");1954 try stream.writeAll("}) ");
1955 }1955 }
1956 try self.writeSrcNode(stream, 0);1956 try self.writeSrcNode(stream, 0);
1957 }1957 }
...@@ -1982,7 +1982,7 @@ const Writer = struct {...@@ -1982,7 +1982,7 @@ const Writer = struct {
1982 try stream.writeByteNTimes(' ', self.indent);1982 try stream.writeByteNTimes(' ', self.indent);
1983 try stream.writeAll("}) ");1983 try stream.writeAll("}) ");
19841984
1985 try self.writeSrc(stream, inst_data.src());1985 try self.writeSrcNode(stream, inst_data.src_node);
1986 }1986 }
19871987
1988 fn writeSwitchBlockErrUnion(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {1988 fn writeSwitchBlockErrUnion(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -2119,7 +2119,7 @@ const Writer = struct {...@@ -2119,7 +2119,7 @@ const Writer = struct {
2119 self.indent -= 2;2119 self.indent -= 2;
21202120
2121 try stream.writeAll(") ");2121 try stream.writeAll(") ");
2122 try self.writeSrc(stream, inst_data.src());2122 try self.writeSrcNode(stream, inst_data.src_node);
2123 }2123 }
21242124
2125 fn writeSwitchBlock(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {2125 fn writeSwitchBlock(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -2249,7 +2249,7 @@ const Writer = struct {...@@ -2249,7 +2249,7 @@ const Writer = struct {
2249 self.indent -= 2;2249 self.indent -= 2;
22502250
2251 try stream.writeAll(") ");2251 try stream.writeAll(") ");
2252 try self.writeSrc(stream, inst_data.src());2252 try self.writeSrcNode(stream, inst_data.src_node);
2253 }2253 }
22542254
2255 fn writePlNodeField(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {2255 fn writePlNodeField(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -2258,7 +2258,7 @@ const Writer = struct {...@@ -2258,7 +2258,7 @@ const Writer = struct {
2258 const name = self.code.nullTerminatedString(extra.field_name_start);2258 const name = self.code.nullTerminatedString(extra.field_name_start);
2259 try self.writeInstRef(stream, extra.lhs);2259 try self.writeInstRef(stream, extra.lhs);
2260 try stream.print(", \"{}\") ", .{std.zig.fmtEscapes(name)});2260 try stream.print(", \"{}\") ", .{std.zig.fmtEscapes(name)});
2261 try self.writeSrc(stream, inst_data.src());2261 try self.writeSrcNode(stream, inst_data.src_node);
2262 }2262 }
22632263
2264 fn writePlNodeFieldNamed(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {2264 fn writePlNodeFieldNamed(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -2268,7 +2268,7 @@ const Writer = struct {...@@ -2268,7 +2268,7 @@ const Writer = struct {
2268 try stream.writeAll(", ");2268 try stream.writeAll(", ");
2269 try self.writeInstRef(stream, extra.field_name);2269 try self.writeInstRef(stream, extra.field_name);
2270 try stream.writeAll(") ");2270 try stream.writeAll(") ");
2271 try self.writeSrc(stream, inst_data.src());2271 try self.writeSrcNode(stream, inst_data.src_node);
2272 }2272 }
22732273
2274 fn writeAs(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {2274 fn writeAs(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -2278,7 +2278,7 @@ const Writer = struct {...@@ -2278,7 +2278,7 @@ const Writer = struct {
2278 try stream.writeAll(", ");2278 try stream.writeAll(", ");
2279 try self.writeInstRef(stream, extra.operand);2279 try self.writeInstRef(stream, extra.operand);
2280 try stream.writeAll(") ");2280 try stream.writeAll(") ");
2281 try self.writeSrc(stream, inst_data.src());2281 try self.writeSrcNode(stream, inst_data.src_node);
2282 }2282 }
22832283
2284 fn writeNode(2284 fn writeNode(
...@@ -2300,7 +2300,7 @@ const Writer = struct {...@@ -2300,7 +2300,7 @@ const Writer = struct {
2300 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str_tok;2300 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str_tok;
2301 const str = inst_data.get(self.code);2301 const str = inst_data.get(self.code);
2302 try stream.print("\"{}\") ", .{std.zig.fmtEscapes(str)});2302 try stream.print("\"{}\") ", .{std.zig.fmtEscapes(str)});
2303 try self.writeSrc(stream, inst_data.src());2303 try self.writeSrcTok(stream, inst_data.src_tok);
2304 }2304 }
23052305
2306 fn writeStrOp(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {2306 fn writeStrOp(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -2317,7 +2317,6 @@ const Writer = struct {...@@ -2317,7 +2317,6 @@ const Writer = struct {
2317 inferred_error_set: bool,2317 inferred_error_set: bool,
2318 ) !void {2318 ) !void {
2319 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;2319 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
2320 const src = inst_data.src();
2321 const extra = self.code.extraData(Zir.Inst.Func, inst_data.payload_index);2320 const extra = self.code.extraData(Zir.Inst.Func, inst_data.payload_index);
23222321
2323 var extra_index = extra.end;2322 var extra_index = extra.end;
...@@ -2364,7 +2363,7 @@ const Writer = struct {...@@ -2364,7 +2363,7 @@ const Writer = struct {
2364 ret_ty_body,2363 ret_ty_body,
23652364
2366 body,2365 body,
2367 src,2366 inst_data.src_node,
2368 src_locs,2367 src_locs,
2369 0,2368 0,
2370 );2369 );
...@@ -2373,7 +2372,6 @@ const Writer = struct {...@@ -2373,7 +2372,6 @@ const Writer = struct {
2373 fn writeFuncFancy(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {2372 fn writeFuncFancy(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
2374 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;2373 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
2375 const extra = self.code.extraData(Zir.Inst.FuncFancy, inst_data.payload_index);2374 const extra = self.code.extraData(Zir.Inst.FuncFancy, inst_data.payload_index);
2376 const src = inst_data.src();
23772375
2378 var extra_index: usize = extra.end;2376 var extra_index: usize = extra.end;
2379 var align_ref: Zir.Inst.Ref = .none;2377 var align_ref: Zir.Inst.Ref = .none;
...@@ -2470,7 +2468,7 @@ const Writer = struct {...@@ -2470,7 +2468,7 @@ const Writer = struct {
2470 ret_ty_ref,2468 ret_ty_ref,
2471 ret_ty_body,2469 ret_ty_body,
2472 body,2470 body,
2473 src,2471 inst_data.src_node,
2474 src_locs,2472 src_locs,
2475 noalias_bits,2473 noalias_bits,
2476 );2474 );
...@@ -2551,7 +2549,7 @@ const Writer = struct {...@@ -2551,7 +2549,7 @@ const Writer = struct {
2551 try stream.writeAll(", ");2549 try stream.writeAll(", ");
2552 try self.writeBracedBody(stream, body);2550 try self.writeBracedBody(stream, body);
2553 try stream.writeAll(") ");2551 try stream.writeAll(") ");
2554 try self.writeSrc(stream, inst_data.src());2552 try self.writeSrcNode(stream, inst_data.src_node);
2555 }2553 }
25562554
2557 fn writeIntType(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {2555 fn writeIntType(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -2561,7 +2559,7 @@ const Writer = struct {...@@ -2561,7 +2559,7 @@ const Writer = struct {
2561 .unsigned => 'u',2559 .unsigned => 'u',
2562 };2560 };
2563 try stream.print("{c}{d}) ", .{ prefix, int_type.bit_count });2561 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);
2565 }2563 }
25662564
2567 fn writeSaveErrRetIndex(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {2565 fn writeSaveErrRetIndex(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -2579,7 +2577,7 @@ const Writer = struct {...@@ -2579,7 +2577,7 @@ const Writer = struct {
2579 try self.writeInstRef(stream, extra.operand);2577 try self.writeInstRef(stream, extra.operand);
25802578
2581 try stream.writeAll(") ");2579 try stream.writeAll(") ");
2582 try self.writeSrc(stream, extra.src());2580 try self.writeSrcNode(stream, extra.src_node);
2583 }2581 }
25842582
2585 fn writeBreak(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {2583 fn writeBreak(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -2605,7 +2603,7 @@ const Writer = struct {...@@ -2605,7 +2603,7 @@ const Writer = struct {
2605 try self.writeInstRef(stream, arg);2603 try self.writeInstRef(stream, arg);
2606 }2604 }
2607 try stream.writeAll("}) ");2605 try stream.writeAll("}) ");
2608 try self.writeSrc(stream, inst_data.src());2606 try self.writeSrcNode(stream, inst_data.src_node);
2609 }2607 }
26102608
2611 fn writeArrayInitAnon(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {2609 fn writeArrayInitAnon(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -2620,7 +2618,7 @@ const Writer = struct {...@@ -2620,7 +2618,7 @@ const Writer = struct {
2620 try self.writeInstRef(stream, arg);2618 try self.writeInstRef(stream, arg);
2621 }2619 }
2622 try stream.writeAll("}) ");2620 try stream.writeAll("}) ");
2623 try self.writeSrc(stream, inst_data.src());2621 try self.writeSrcNode(stream, inst_data.src_node);
2624 }2622 }
26252623
2626 fn writeArrayInitSent(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {2624 fn writeArrayInitSent(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -2640,13 +2638,13 @@ const Writer = struct {...@@ -2640,13 +2638,13 @@ const Writer = struct {
2640 try self.writeInstRef(stream, elem);2638 try self.writeInstRef(stream, elem);
2641 }2639 }
2642 try stream.writeAll("}) ");2640 try stream.writeAll("}) ");
2643 try self.writeSrc(stream, inst_data.src());2641 try self.writeSrcNode(stream, inst_data.src_node);
2644 }2642 }
26452643
2646 fn writeUnreachable(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {2644 fn writeUnreachable(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
2647 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].@"unreachable";2645 const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].@"unreachable";
2648 try stream.writeAll(") ");2646 try stream.writeAll(") ");
2649 try self.writeSrc(stream, inst_data.src());2647 try self.writeSrcNode(stream, inst_data.src_node);
2650 }2648 }
26512649
2652 fn writeFuncCommon(2650 fn writeFuncCommon(
...@@ -2667,7 +2665,7 @@ const Writer = struct {...@@ -2667,7 +2665,7 @@ const Writer = struct {
2667 ret_ty_ref: Zir.Inst.Ref,2665 ret_ty_ref: Zir.Inst.Ref,
2668 ret_ty_body: []const Zir.Inst.Index,2666 ret_ty_body: []const Zir.Inst.Index,
2669 body: []const Zir.Inst.Index,2667 body: []const Zir.Inst.Index,
2670 src: LazySrcLoc,2668 src_node: i32,
2671 src_locs: Zir.Inst.Func.SrcLocs,2669 src_locs: Zir.Inst.Func.SrcLocs,
2672 noalias_bits: u32,2670 noalias_bits: u32,
2673 ) !void {2671 ) !void {
...@@ -2694,7 +2692,7 @@ const Writer = struct {...@@ -2694,7 +2692,7 @@ const Writer = struct {
2694 src_locs.rbrace_line + 1, @as(u16, @truncate(src_locs.columns >> 16)) + 1,2692 src_locs.rbrace_line + 1, @as(u16, @truncate(src_locs.columns >> 16)) + 1,
2695 });2693 });
2696 }2694 }
2697 try self.writeSrc(stream, src);2695 try self.writeSrcNode(stream, src_node);
2698 }2696 }
26992697
2700 fn writeDbgStmt(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {2698 fn writeDbgStmt(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
...@@ -2878,11 +2876,12 @@ const Writer = struct {...@@ -2878,11 +2876,12 @@ const Writer = struct {
2878 }2876 }
2879 }2877 }
28802878
2881 fn writeSrcNode(self: *Writer, stream: anytype, src_node: ?i32) !void {2879 fn writeSrcNode(self: *Writer, stream: anytype, src_node: i32) !void {
2882 const node_offset = src_node orelse return;2880 return self.writeSrc(stream, LazySrcLoc.nodeOffset(src_node));
2883 const src = LazySrcLoc.nodeOffset(node_offset);2881 }
2884 try stream.writeAll(" ");2882
2885 return self.writeSrc(stream, src);2883 fn writeSrcTok(self: *Writer, stream: anytype, src_tok: u32) !void {
2884 return self.writeSrc(stream, .{ .token_offset = src_tok });
2886 }2885 }
28872886
2888 fn writeBracedDecl(self: *Writer, stream: anytype, body: []const Zir.Inst.Index) !void {2887 fn writeBracedDecl(self: *Writer, stream: anytype, body: []const Zir.Inst.Index) !void {