| author | |
| committer | |
| log | f3ad12b5f1e2d76d157928d9bd4b5926b1bd015f |
| tree | 46eb869a94d4ad020189ebdf9346d28bb55896d5 |
| parent | c5a61e8998742ee0627afd80f35008b5d2703e61 |
| parent | ee13aaeb8ddb8d00d4186c300b616b21da121963 |
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/3551612 files changed, 424 insertions(+), 580 deletions(-)
build.zig+25-26| ... | @@ -181,10 +181,10 @@ pub fn build(b: *std.Build) !void { | ... | @@ -181,10 +181,10 @@ pub fn build(b: *std.Build) !void { |
| 181 | return; | 181 | return; |
| 182 | 182 | ||
| 183 | const entitlements = b.option([]const u8, "entitlements", "Path to entitlements file for hot-code swapping without sudo on macOS"); | 183 | const entitlements = b.option([]const u8, "entitlements", "Path to entitlements file for hot-code swapping without sudo on macOS"); |
| 184 | const tracy = b.option([]const u8, "tracy", "Enable Tracy integration. Supply path to Tracy source"); | 184 | const tracy = b.option(std.Build.LazyPath, "tracy", "Enable Tracy integration. Supply path to Tracy source"); |
| 185 | const tracy_callstack = b.option(bool, "tracy-callstack", "Include callstack information with Tracy data. Does nothing if -Dtracy is not provided") orelse (tracy != null); | 185 | const tracy_callstack = b.option(bool, "tracy-callstack", "Include callstack information with Tracy data. Does nothing if -Dtracy is not provided. Has a significant performance impact in some cases. Default: false") orelse false; |
| 186 | const tracy_allocation = b.option(bool, "tracy-allocation", "Include allocation information with Tracy data. Does nothing if -Dtracy is not provided") orelse (tracy != null); | 186 | const tracy_allocation = b.option(bool, "tracy-allocation", "Include allocation information with Tracy data. Does nothing if -Dtracy is not provided. Default: true") orelse (tracy != null); |
| 187 | const tracy_callstack_depth: u32 = b.option(u32, "tracy-callstack-depth", "Declare callstack depth for Tracy data. Does nothing if -Dtracy_callstack is not provided") orelse 10; | 187 | const tracy_callstack_depth: u32 = b.option(u32, "tracy-callstack-depth", "Declare callstack depth for Tracy data. Does nothing if -Dtracy-callstack is not provided") orelse 6; |
| 188 | const debug_gpa = b.option(bool, "debug-allocator", "Force the compiler to use SafeAllocator") orelse false; | 188 | const debug_gpa = b.option(bool, "debug-allocator", "Force the compiler to use SafeAllocator") orelse false; |
| 189 | const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse (enable_llvm or only_c); | 189 | const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse (enable_llvm or only_c); |
| 190 | const sanitize_thread = b.option(bool, "sanitize-thread", "Enable thread-sanitization") orelse false; | 190 | const sanitize_thread = b.option(bool, "sanitize-thread", "Enable thread-sanitization") orelse false; |
| ... | @@ -373,32 +373,31 @@ pub fn build(b: *std.Build) !void { | ... | @@ -373,32 +373,31 @@ pub fn build(b: *std.Build) !void { |
| 373 | exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation); | 373 | exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation); |
| 374 | exe_options.addOption(u32, "tracy_callstack_depth", tracy_callstack_depth); | 374 | exe_options.addOption(u32, "tracy_callstack_depth", tracy_callstack_depth); |
| 375 | exe_options.addOption(bool, "value_tracing", value_tracing); | 375 | exe_options.addOption(bool, "value_tracing", value_tracing); |
| 376 | if (tracy) |tracy_path| { | 376 | if (tracy) |tracy_dir| { |
| 377 | const client_cpp = b.pathJoin( | 377 | const tracy_mod = b.createModule(.{ |
| 378 | &[_][]const u8{ tracy_path, "public", "TracyClient.cpp" }, | 378 | .target = target, |
| 379 | ); | 379 | // Always build Tracy in ReleaseFast so that it doesn't make Debug compiler builds unusable. |
| 380 | 380 | .optimize = .ReleaseFast, | |
| 381 | const tracy_c_flags: []const []const u8 = &.{ | 381 | .root_source_file = null, |
| 382 | "-DTRACY_ENABLE=1", | 382 | .link_libc = true, |
| 383 | "-fno-sanitize=undefined", | 383 | .link_libcpp = true, |
| 384 | "-DTRACY_FIBERS", | ||
| 385 | }; | ||
| 386 | |||
| 387 | exe.root_module.addIncludePath(.{ .cwd_relative = tracy_path }); | ||
| 388 | exe.root_module.addCSourceFile(.{ | ||
| 389 | .file = .{ .cwd_relative = client_cpp }, | ||
| 390 | .flags = tracy_c_flags[0..switch (io_mode) { | ||
| 391 | .threaded => 2, | ||
| 392 | .evented => 3, | ||
| 393 | }], | ||
| 394 | }); | 384 | }); |
| 395 | exe.root_module.link_libc = true; | 385 | |
| 396 | exe.root_module.link_libcpp = true; | 386 | tracy_mod.addCMacro("TRACY_ENABLE", "1"); |
| 387 | |||
| 388 | if (!tracy_callstack) { | ||
| 389 | tracy_mod.addCMacro("TRACY_NO_CALLSTACK", "1"); | ||
| 390 | } | ||
| 391 | |||
| 392 | tracy_mod.addIncludePath(tracy_dir); | ||
| 393 | tracy_mod.addCSourceFile(.{ .file = tracy_dir.path(b, "public/TracyClient.cpp") }); | ||
| 397 | 394 | ||
| 398 | if (target.result.os.tag == .windows) { | 395 | if (target.result.os.tag == .windows) { |
| 399 | exe.root_module.linkSystemLibrary("dbghelp", .{}); | 396 | tracy_mod.linkSystemLibrary("dbghelp", .{}); |
| 400 | exe.root_module.linkSystemLibrary("ws2_32", .{}); | 397 | tracy_mod.linkSystemLibrary("ws2_32", .{}); |
| 401 | } | 398 | } |
| 399 | |||
| 400 | exe.root_module.addImport("tracy", tracy_mod); | ||
| 402 | } | 401 | } |
| 403 | 402 | ||
| 404 | const test_filters = b.option([]const []const u8, "test-filter", "Skip tests that do not match any filter") orelse &[0][]const u8{}; | 403 | const test_filters = b.option([]const []const u8, "test-filter", "Skip tests that do not match any filter") orelse &[0][]const u8{}; |
src/Air/Liveness.zig+2-2| ... | @@ -13,7 +13,7 @@ const Log2Int = std.math.Log2Int; | ... | @@ -13,7 +13,7 @@ const Log2Int = std.math.Log2Int; |
| 13 | const Writer = std.Io.Writer; | 13 | const Writer = std.Io.Writer; |
| 14 | 14 | ||
| 15 | const Liveness = @This(); | 15 | const Liveness = @This(); |
| 16 | const trace = @import("../tracy.zig").trace; | 16 | const traceNamed = @import("../tracy.zig").traceNamed; |
| 17 | const Air = @import("../Air.zig"); | 17 | const Air = @import("../Air.zig"); |
| 18 | const InternPool = @import("../InternPool.zig"); | 18 | const InternPool = @import("../InternPool.zig"); |
| 19 | const Zcu = @import("../Zcu.zig"); | 19 | const Zcu = @import("../Zcu.zig"); |
| ... | @@ -140,7 +140,7 @@ fn LivenessPassData(comptime pass: LivenessPass) type { | ... | @@ -140,7 +140,7 @@ fn LivenessPassData(comptime pass: LivenessPass) type { |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | pub fn analyze(zcu: *Zcu, air: Air, intern_pool: *InternPool) Allocator.Error!Liveness { | 142 | pub fn analyze(zcu: *Zcu, air: Air, intern_pool: *InternPool) Allocator.Error!Liveness { |
| 143 | const tracy = trace(@src()); | 143 | const tracy = traceNamed(@src(), "analyze_liveness"); |
| 144 | defer tracy.end(); | 144 | defer tracy.end(); |
| 145 | 145 | ||
| 146 | const gpa = zcu.gpa; | 146 | const gpa = zcu.gpa; |
src/Compilation.zig+18-6| ... | @@ -2870,8 +2870,8 @@ pub const UpdateError = error{ | ... | @@ -2870,8 +2870,8 @@ pub const UpdateError = error{ |
| 2870 | 2870 | ||
| 2871 | /// Detect changes to source files, perform semantic analysis, and update the output files. | 2871 | /// Detect changes to source files, perform semantic analysis, and update the output files. |
| 2872 | pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateError!void { | 2872 | pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateError!void { |
| 2873 | const tracy_trace = trace(@src()); | 2873 | const tracy_frame = tracy.namedFrame(comp.root_name); |
| 2874 | defer tracy_trace.end(); | 2874 | defer tracy_frame.end(); |
| 2875 | 2875 | ||
| 2876 | const gpa = comp.gpa; | 2876 | const gpa = comp.gpa; |
| 2877 | const io = comp.io; | 2877 | const io = comp.io; |
| ... | @@ -3008,10 +3008,19 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE | ... | @@ -3008,10 +3008,19 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE |
| 3008 | 3008 | ||
| 3009 | // For compiling C objects, we rely on the cache hash system to avoid duplicating work. | 3009 | // For compiling C objects, we rely on the cache hash system to avoid duplicating work. |
| 3010 | // Add a Job for each C object. | 3010 | // Add a Job for each C object. |
| 3011 | try comp.c_object_work_queue.ensureUnusedCapacity(gpa, comp.c_object_table.count()); | 3011 | if (comp.bin_file != null and comp.bin_file.?.post_prelink) { |
| 3012 | for (comp.c_object_table.keys()) |c_object| { | 3012 | assert(comp.config.incremental); |
| 3013 | comp.c_object_work_queue.pushBackAssumeCapacity(c_object); | 3013 | // TODO: this indicates that we are using incremental compilation and this is not the first |
| 3014 | try comp.appendFileSystemInput(try .fromUnresolved(arena, comp.dirs, &.{c_object.src.src_path})); | 3014 | // incremental update. The incremental linkers do not (currently?) support updating C inputs |
| 3015 | // incrementally. The frontend needs to learn to trigger a full rebuild if a C link input | ||
| 3016 | // changes. For now, to avoid crashing the linker in this case, don't kick off C object | ||
| 3017 | // updates if we've done prelink already. https://codeberg.org/ziglang/zig/issues/32081 | ||
| 3018 | } else { | ||
| 3019 | try comp.c_object_work_queue.ensureUnusedCapacity(gpa, comp.c_object_table.count()); | ||
| 3020 | for (comp.c_object_table.keys()) |c_object| { | ||
| 3021 | comp.c_object_work_queue.pushBackAssumeCapacity(c_object); | ||
| 3022 | try comp.appendFileSystemInput(try .fromUnresolved(arena, comp.dirs, &.{c_object.src.src_path})); | ||
| 3023 | } | ||
| 3015 | } | 3024 | } |
| 3016 | 3025 | ||
| 3017 | for (comp.link_inputs) |input| if (input.path()) |path| { | 3026 | for (comp.link_inputs) |input| if (input.path()) |path| { |
| ... | @@ -7595,6 +7604,9 @@ pub fn queuePrelinkTaskMode(comp: *Compilation, path: Cache.Path, must_link: boo | ... | @@ -7595,6 +7604,9 @@ pub fn queuePrelinkTaskMode(comp: *Compilation, path: Cache.Path, must_link: boo |
| 7595 | 7604 | ||
| 7596 | /// Only valid to call during `update`. | 7605 | /// Only valid to call during `update`. |
| 7597 | pub fn queuePrelinkTasks(comp: *Compilation, tasks: []const link.PrelinkTask) Io.Cancelable!void { | 7606 | pub fn queuePrelinkTasks(comp: *Compilation, tasks: []const link.PrelinkTask) Io.Cancelable!void { |
| 7607 | if (tasks.len > 0) { | ||
| 7608 | if (comp.bin_file) |lf| assert(!lf.post_prelink); | ||
| 7609 | } | ||
| 7598 | comp.link_prog_node.increaseEstimatedTotalItems(tasks.len); | 7610 | comp.link_prog_node.increaseEstimatedTotalItems(tasks.len); |
| 7599 | try comp.link_queue.enqueuePrelink(comp, tasks); | 7611 | try comp.link_queue.enqueuePrelink(comp, tasks); |
| 7600 | } | 7612 | } |
src/Sema.zig-287| ... | @@ -19,7 +19,6 @@ const Type = @import("Type.zig"); | ... | @@ -19,7 +19,6 @@ const Type = @import("Type.zig"); |
| 19 | const Air = @import("Air.zig"); | 19 | const Air = @import("Air.zig"); |
| 20 | const Zir = std.zig.Zir; | 20 | const Zir = std.zig.Zir; |
| 21 | const Zcu = @import("Zcu.zig"); | 21 | const Zcu = @import("Zcu.zig"); |
| 22 | const trace = @import("tracy.zig").trace; | ||
| 23 | const Namespace = Zcu.Namespace; | 22 | const Namespace = Zcu.Namespace; |
| 24 | const CompileError = Zcu.CompileError; | 23 | const CompileError = Zcu.CompileError; |
| 25 | const SemaError = Zcu.SemaError; | 24 | const SemaError = Zcu.SemaError; |
| ... | @@ -1127,8 +1126,6 @@ fn analyzeBodyInner( | ... | @@ -1127,8 +1126,6 @@ fn analyzeBodyInner( |
| 1127 | block: *Block, | 1126 | block: *Block, |
| 1128 | body: []const Zir.Inst.Index, | 1127 | body: []const Zir.Inst.Index, |
| 1129 | ) CompileError!void { | 1128 | ) CompileError!void { |
| 1130 | // No tracy calls here, to avoid interfering with the tail call mechanism. | ||
| 1131 | |||
| 1132 | try sema.inst_map.ensureSpaceForInstructions(sema.gpa, body); | 1129 | try sema.inst_map.ensureSpaceForInstructions(sema.gpa, body); |
| 1133 | 1130 | ||
| 1134 | const pt = sema.pt; | 1131 | const pt = sema.pt; |
| ... | @@ -3002,9 +2999,6 @@ fn zirErrorSetDecl( | ... | @@ -3002,9 +2999,6 @@ fn zirErrorSetDecl( |
| 3002 | sema: *Sema, | 2999 | sema: *Sema, |
| 3003 | inst: Zir.Inst.Index, | 3000 | inst: Zir.Inst.Index, |
| 3004 | ) CompileError!Air.Inst.Ref { | 3001 | ) CompileError!Air.Inst.Ref { |
| 3005 | const tracy = trace(@src()); | ||
| 3006 | defer tracy.end(); | ||
| 3007 | |||
| 3008 | const pt = sema.pt; | 3002 | const pt = sema.pt; |
| 3009 | const zcu = pt.zcu; | 3003 | const zcu = pt.zcu; |
| 3010 | const comp = zcu.comp; | 3004 | const comp = zcu.comp; |
| ... | @@ -3032,9 +3026,6 @@ fn zirErrorSetDecl( | ... | @@ -3032,9 +3026,6 @@ fn zirErrorSetDecl( |
| 3032 | } | 3026 | } |
| 3033 | 3027 | ||
| 3034 | fn zirRetPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 3028 | fn zirRetPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3035 | const tracy = trace(@src()); | ||
| 3036 | defer tracy.end(); | ||
| 3037 | |||
| 3038 | const pt = sema.pt; | 3029 | const pt = sema.pt; |
| 3039 | const zcu = pt.zcu; | 3030 | const zcu = pt.zcu; |
| 3040 | 3031 | ||
| ... | @@ -3061,18 +3052,12 @@ fn zirRetPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -3061,18 +3052,12 @@ fn zirRetPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 3061 | } | 3052 | } |
| 3062 | 3053 | ||
| 3063 | fn zirRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 3054 | fn zirRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3064 | const tracy = trace(@src()); | ||
| 3065 | defer tracy.end(); | ||
| 3066 | |||
| 3067 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok; | 3055 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok; |
| 3068 | const operand = sema.resolveInst(inst_data.operand); | 3056 | const operand = sema.resolveInst(inst_data.operand); |
| 3069 | return sema.analyzeRef(block, block.tokenOffset(inst_data.src_tok), operand, .none); | 3057 | return sema.analyzeRef(block, block.tokenOffset(inst_data.src_tok), operand, .none); |
| 3070 | } | 3058 | } |
| 3071 | 3059 | ||
| 3072 | fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 3060 | fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 3073 | const tracy = trace(@src()); | ||
| 3074 | defer tracy.end(); | ||
| 3075 | |||
| 3076 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 3061 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 3077 | const operand = sema.resolveInst(inst_data.operand); | 3062 | const operand = sema.resolveInst(inst_data.operand); |
| 3078 | const src = block.nodeOffset(inst_data.src_node); | 3063 | const src = block.nodeOffset(inst_data.src_node); |
| ... | @@ -3114,9 +3099,6 @@ fn ensureResultUsed( | ... | @@ -3114,9 +3099,6 @@ fn ensureResultUsed( |
| 3114 | } | 3099 | } |
| 3115 | 3100 | ||
| 3116 | fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 3101 | fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 3117 | const tracy = trace(@src()); | ||
| 3118 | defer tracy.end(); | ||
| 3119 | |||
| 3120 | const pt = sema.pt; | 3102 | const pt = sema.pt; |
| 3121 | const zcu = pt.zcu; | 3103 | const zcu = pt.zcu; |
| 3122 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 3104 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | @@ -3139,9 +3121,6 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -3139,9 +3121,6 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 3139 | } | 3121 | } |
| 3140 | 3122 | ||
| 3141 | fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 3123 | fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 3142 | const tracy = trace(@src()); | ||
| 3143 | defer tracy.end(); | ||
| 3144 | |||
| 3145 | const pt = sema.pt; | 3124 | const pt = sema.pt; |
| 3146 | const zcu = pt.zcu; | 3125 | const zcu = pt.zcu; |
| 3147 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 3126 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | @@ -3166,9 +3145,6 @@ fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index | ... | @@ -3166,9 +3145,6 @@ fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index |
| 3166 | } | 3145 | } |
| 3167 | 3146 | ||
| 3168 | fn zirIndexablePtrLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 3147 | fn zirIndexablePtrLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3169 | const tracy = trace(@src()); | ||
| 3170 | defer tracy.end(); | ||
| 3171 | |||
| 3172 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 3148 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 3173 | const src = block.nodeOffset(inst_data.src_node); | 3149 | const src = block.nodeOffset(inst_data.src_node); |
| 3174 | const object = sema.resolveInst(inst_data.operand); | 3150 | const object = sema.resolveInst(inst_data.operand); |
| ... | @@ -3302,9 +3278,6 @@ fn zirAllocExtended( | ... | @@ -3302,9 +3278,6 @@ fn zirAllocExtended( |
| 3302 | } | 3278 | } |
| 3303 | 3279 | ||
| 3304 | fn zirAllocComptime(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 3280 | fn zirAllocComptime(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3305 | const tracy = trace(@src()); | ||
| 3306 | defer tracy.end(); | ||
| 3307 | |||
| 3308 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 3281 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 3309 | const ty_src = block.src(.{ .node_offset_var_decl_ty = inst_data.src_node }); | 3282 | const ty_src = block.src(.{ .node_offset_var_decl_ty = inst_data.src_node }); |
| 3310 | const var_src = block.nodeOffset(inst_data.src_node); | 3283 | const var_src = block.nodeOffset(inst_data.src_node); |
| ... | @@ -3732,9 +3705,6 @@ fn zirAllocInferredComptime( | ... | @@ -3732,9 +3705,6 @@ fn zirAllocInferredComptime( |
| 3732 | } | 3705 | } |
| 3733 | 3706 | ||
| 3734 | fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 3707 | fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3735 | const tracy = trace(@src()); | ||
| 3736 | defer tracy.end(); | ||
| 3737 | |||
| 3738 | const pt = sema.pt; | 3708 | const pt = sema.pt; |
| 3739 | const zcu = pt.zcu; | 3709 | const zcu = pt.zcu; |
| 3740 | 3710 | ||
| ... | @@ -3764,9 +3734,6 @@ fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I | ... | @@ -3764,9 +3734,6 @@ fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 3764 | } | 3734 | } |
| 3765 | 3735 | ||
| 3766 | fn zirAllocMut(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 3736 | fn zirAllocMut(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3767 | const tracy = trace(@src()); | ||
| 3768 | defer tracy.end(); | ||
| 3769 | |||
| 3770 | const pt = sema.pt; | 3737 | const pt = sema.pt; |
| 3771 | const zcu = pt.zcu; | 3738 | const zcu = pt.zcu; |
| 3772 | 3739 | ||
| ... | @@ -3797,9 +3764,6 @@ fn zirAllocInferred( | ... | @@ -3797,9 +3764,6 @@ fn zirAllocInferred( |
| 3797 | block: *Block, | 3764 | block: *Block, |
| 3798 | is_const: bool, | 3765 | is_const: bool, |
| 3799 | ) CompileError!Air.Inst.Ref { | 3766 | ) CompileError!Air.Inst.Ref { |
| 3800 | const tracy = trace(@src()); | ||
| 3801 | defer tracy.end(); | ||
| 3802 | |||
| 3803 | const gpa = sema.gpa; | 3767 | const gpa = sema.gpa; |
| 3804 | 3768 | ||
| 3805 | if (block.isComptime()) { | 3769 | if (block.isComptime()) { |
| ... | @@ -3830,9 +3794,6 @@ fn zirAllocInferred( | ... | @@ -3830,9 +3794,6 @@ fn zirAllocInferred( |
| 3830 | } | 3794 | } |
| 3831 | 3795 | ||
| 3832 | fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 3796 | fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 3833 | const tracy = trace(@src()); | ||
| 3834 | defer tracy.end(); | ||
| 3835 | |||
| 3836 | const pt = sema.pt; | 3797 | const pt = sema.pt; |
| 3837 | const zcu = pt.zcu; | 3798 | const zcu = pt.zcu; |
| 3838 | const gpa = sema.gpa; | 3799 | const gpa = sema.gpa; |
| ... | @@ -4391,9 +4352,6 @@ fn zirValidatePtrStructInit( | ... | @@ -4391,9 +4352,6 @@ fn zirValidatePtrStructInit( |
| 4391 | block: *Block, | 4352 | block: *Block, |
| 4392 | inst: Zir.Inst.Index, | 4353 | inst: Zir.Inst.Index, |
| 4393 | ) CompileError!void { | 4354 | ) CompileError!void { |
| 4394 | const tracy = trace(@src()); | ||
| 4395 | defer tracy.end(); | ||
| 4396 | |||
| 4397 | const pt = sema.pt; | 4355 | const pt = sema.pt; |
| 4398 | const zcu = pt.zcu; | 4356 | const zcu = pt.zcu; |
| 4399 | const validate_inst = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 4357 | const validate_inst = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | @@ -4776,9 +4734,6 @@ pub fn addDeclaredHereNote(sema: *Sema, parent: *Zcu.ErrorMsg, decl_ty: Type) !v | ... | @@ -4776,9 +4734,6 @@ pub fn addDeclaredHereNote(sema: *Sema, parent: *Zcu.ErrorMsg, decl_ty: Type) !v |
| 4776 | } | 4734 | } |
| 4777 | 4735 | ||
| 4778 | fn zirStoreToInferredPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 4736 | fn zirStoreToInferredPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 4779 | const tracy = trace(@src()); | ||
| 4780 | defer tracy.end(); | ||
| 4781 | |||
| 4782 | const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 4737 | const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 4783 | const src = block.nodeOffset(pl_node.src_node); | 4738 | const src = block.nodeOffset(pl_node.src_node); |
| 4784 | const bin = sema.code.extraData(Zir.Inst.Bin, pl_node.payload_index).data; | 4739 | const bin = sema.code.extraData(Zir.Inst.Bin, pl_node.payload_index).data; |
| ... | @@ -4870,9 +4825,6 @@ fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi | ... | @@ -4870,9 +4825,6 @@ fn zirSetEvalBranchQuota(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi |
| 4870 | } | 4825 | } |
| 4871 | 4826 | ||
| 4872 | fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 4827 | fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 4873 | const tracy = trace(@src()); | ||
| 4874 | defer tracy.end(); | ||
| 4875 | |||
| 4876 | const zir_tags = sema.code.instructions.items(.tag); | 4828 | const zir_tags = sema.code.instructions.items(.tag); |
| 4877 | const zir_datas = sema.code.instructions.items(.data); | 4829 | const zir_datas = sema.code.instructions.items(.data); |
| 4878 | const inst_data = zir_datas[@intFromEnum(inst)].pl_node; | 4830 | const inst_data = zir_datas[@intFromEnum(inst)].pl_node; |
| ... | @@ -4935,8 +4887,6 @@ fn uavRef(sema: *Sema, val: Value) CompileError!Air.Inst.Ref { | ... | @@ -4935,8 +4887,6 @@ fn uavRef(sema: *Sema, val: Value) CompileError!Air.Inst.Ref { |
| 4935 | 4887 | ||
| 4936 | fn zirInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 4888 | fn zirInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4937 | _ = block; | 4889 | _ = block; |
| 4938 | const tracy = trace(@src()); | ||
| 4939 | defer tracy.end(); | ||
| 4940 | 4890 | ||
| 4941 | const int = sema.code.instructions.items(.data)[@intFromEnum(inst)].int; | 4891 | const int = sema.code.instructions.items(.data)[@intFromEnum(inst)].int; |
| 4942 | return sema.pt.intRef(.comptime_int, int); | 4892 | return sema.pt.intRef(.comptime_int, int); |
| ... | @@ -4944,8 +4894,6 @@ fn zirInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -4944,8 +4894,6 @@ fn zirInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 4944 | 4894 | ||
| 4945 | fn zirIntBig(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 4895 | fn zirIntBig(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 4946 | _ = block; | 4896 | _ = block; |
| 4947 | const tracy = trace(@src()); | ||
| 4948 | defer tracy.end(); | ||
| 4949 | 4897 | ||
| 4950 | const int = sema.code.instructions.items(.data)[@intFromEnum(inst)].str; | 4898 | const int = sema.code.instructions.items(.data)[@intFromEnum(inst)].str; |
| 4951 | const byte_count = int.len * @sizeOf(std.math.big.Limb); | 4899 | const byte_count = int.len * @sizeOf(std.math.big.Limb); |
| ... | @@ -4981,9 +4929,6 @@ fn zirFloat128(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -4981,9 +4929,6 @@ fn zirFloat128(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 4981 | } | 4929 | } |
| 4982 | 4930 | ||
| 4983 | fn zirCompileError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 4931 | fn zirCompileError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 4984 | const tracy = trace(@src()); | ||
| 4985 | defer tracy.end(); | ||
| 4986 | |||
| 4987 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 4932 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 4988 | const src = block.nodeOffset(inst_data.src_node); | 4933 | const src = block.nodeOffset(inst_data.src_node); |
| 4989 | const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0); | 4934 | const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0); |
| ... | @@ -5111,9 +5056,6 @@ fn zirTrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | ... | @@ -5111,9 +5056,6 @@ fn zirTrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 5111 | } | 5056 | } |
| 5112 | 5057 | ||
| 5113 | fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 5058 | fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5114 | const tracy = trace(@src()); | ||
| 5115 | defer tracy.end(); | ||
| 5116 | |||
| 5117 | const pt = sema.pt; | 5059 | const pt = sema.pt; |
| 5118 | const zcu = pt.zcu; | 5060 | const zcu = pt.zcu; |
| 5119 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 5061 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | @@ -5202,9 +5144,6 @@ fn zirSuspendBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) Comp | ... | @@ -5202,9 +5144,6 @@ fn zirSuspendBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) Comp |
| 5202 | } | 5144 | } |
| 5203 | 5145 | ||
| 5204 | fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 5146 | fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 5205 | const tracy = trace(@src()); | ||
| 5206 | defer tracy.end(); | ||
| 5207 | |||
| 5208 | const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 5147 | const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 5209 | const src = parent_block.nodeOffset(pl_node.src_node); | 5148 | const src = parent_block.nodeOffset(pl_node.src_node); |
| 5210 | const extra = sema.code.extraData(Zir.Inst.Block, pl_node.payload_index); | 5149 | const extra = sema.code.extraData(Zir.Inst.Block, pl_node.payload_index); |
| ... | @@ -5326,9 +5265,6 @@ fn resolveAnalyzedBlock( | ... | @@ -5326,9 +5265,6 @@ fn resolveAnalyzedBlock( |
| 5326 | merges: *Block.Merges, | 5265 | merges: *Block.Merges, |
| 5327 | need_debug_scope: bool, | 5266 | need_debug_scope: bool, |
| 5328 | ) CompileError!Air.Inst.Ref { | 5267 | ) CompileError!Air.Inst.Ref { |
| 5329 | const tracy = trace(@src()); | ||
| 5330 | defer tracy.end(); | ||
| 5331 | |||
| 5332 | const gpa = sema.gpa; | 5268 | const gpa = sema.gpa; |
| 5333 | const pt = sema.pt; | 5269 | const pt = sema.pt; |
| 5334 | const zcu = pt.zcu; | 5270 | const zcu = pt.zcu; |
| ... | @@ -5540,9 +5476,6 @@ fn resolveAnalyzedBlock( | ... | @@ -5540,9 +5476,6 @@ fn resolveAnalyzedBlock( |
| 5540 | } | 5476 | } |
| 5541 | 5477 | ||
| 5542 | fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 5478 | fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 5543 | const tracy = trace(@src()); | ||
| 5544 | defer tracy.end(); | ||
| 5545 | |||
| 5546 | const pt = sema.pt; | 5479 | const pt = sema.pt; |
| 5547 | const zcu = pt.zcu; | 5480 | const zcu = pt.zcu; |
| 5548 | const ip = &zcu.intern_pool; | 5481 | const ip = &zcu.intern_pool; |
| ... | @@ -5713,9 +5646,6 @@ fn zirSetRuntimeSafety(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile | ... | @@ -5713,9 +5646,6 @@ fn zirSetRuntimeSafety(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile |
| 5713 | } | 5646 | } |
| 5714 | 5647 | ||
| 5715 | fn zirBreak(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError!void { | 5648 | fn zirBreak(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 5716 | const tracy = trace(@src()); | ||
| 5717 | defer tracy.end(); | ||
| 5718 | |||
| 5719 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"break"; | 5649 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"break"; |
| 5720 | const extra = sema.code.extraData(Zir.Inst.Break, inst_data.payload_index).data; | 5650 | const extra = sema.code.extraData(Zir.Inst.Break, inst_data.payload_index).data; |
| 5721 | const operand = sema.resolveInst(inst_data.operand); | 5651 | const operand = sema.resolveInst(inst_data.operand); |
| ... | @@ -5746,9 +5676,6 @@ fn zirBreak(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -5746,9 +5676,6 @@ fn zirBreak(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError |
| 5746 | } | 5676 | } |
| 5747 | 5677 | ||
| 5748 | fn zirSwitchContinue(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError!void { | 5678 | fn zirSwitchContinue(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 5749 | const tracy = trace(@src()); | ||
| 5750 | defer tracy.end(); | ||
| 5751 | |||
| 5752 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"break"; | 5679 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"break"; |
| 5753 | const extra = sema.code.extraData(Zir.Inst.Break, inst_data.payload_index).data; | 5680 | const extra = sema.code.extraData(Zir.Inst.Break, inst_data.payload_index).data; |
| 5754 | const operand_src = start_block.nodeOffset(extra.operand_src_node.unwrap().?); | 5681 | const operand_src = start_block.nodeOffset(extra.operand_src_node.unwrap().?); |
| ... | @@ -6139,9 +6066,6 @@ fn zirCall( | ... | @@ -6139,9 +6066,6 @@ fn zirCall( |
| 6139 | inst: Zir.Inst.Index, | 6066 | inst: Zir.Inst.Index, |
| 6140 | comptime kind: enum { direct, field }, | 6067 | comptime kind: enum { direct, field }, |
| 6141 | ) CompileError!Air.Inst.Ref { | 6068 | ) CompileError!Air.Inst.Ref { |
| 6142 | const tracy = trace(@src()); | ||
| 6143 | defer tracy.end(); | ||
| 6144 | |||
| 6145 | const pt = sema.pt; | 6069 | const pt = sema.pt; |
| 6146 | const zcu = pt.zcu; | 6070 | const zcu = pt.zcu; |
| 6147 | const comp = zcu.comp; | 6071 | const comp = zcu.comp; |
| ... | @@ -7376,9 +7300,6 @@ fn zirIntType(sema: *Sema, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | ... | @@ -7376,9 +7300,6 @@ fn zirIntType(sema: *Sema, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7376 | } | 7300 | } |
| 7377 | 7301 | ||
| 7378 | fn zirOptionalType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 7302 | fn zirOptionalType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7379 | const tracy = trace(@src()); | ||
| 7380 | defer tracy.end(); | ||
| 7381 | |||
| 7382 | const pt = sema.pt; | 7303 | const pt = sema.pt; |
| 7383 | const zcu = pt.zcu; | 7304 | const zcu = pt.zcu; |
| 7384 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 7305 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | @@ -7469,9 +7390,6 @@ fn zirVectorType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -7469,9 +7390,6 @@ fn zirVectorType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 7469 | } | 7390 | } |
| 7470 | 7391 | ||
| 7471 | fn zirArrayType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 7392 | fn zirArrayType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7472 | const tracy = trace(@src()); | ||
| 7473 | defer tracy.end(); | ||
| 7474 | |||
| 7475 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 7393 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 7476 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 7394 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 7477 | const len_src = block.src(.{ .node_offset_array_type_len = inst_data.src_node }); | 7395 | const len_src = block.src(.{ .node_offset_array_type_len = inst_data.src_node }); |
| ... | @@ -7488,9 +7406,6 @@ fn zirArrayType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -7488,9 +7406,6 @@ fn zirArrayType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 7488 | } | 7406 | } |
| 7489 | 7407 | ||
| 7490 | fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 7408 | fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7491 | const tracy = trace(@src()); | ||
| 7492 | defer tracy.end(); | ||
| 7493 | |||
| 7494 | const pt = sema.pt; | 7409 | const pt = sema.pt; |
| 7495 | const zcu = pt.zcu; | 7410 | const zcu = pt.zcu; |
| 7496 | const comp = zcu.comp; | 7411 | const comp = zcu.comp; |
| ... | @@ -7534,9 +7449,6 @@ fn validateArrayElemType(sema: *Sema, block: *Block, elem_type: Type, elem_src: | ... | @@ -7534,9 +7449,6 @@ fn validateArrayElemType(sema: *Sema, block: *Block, elem_type: Type, elem_src: |
| 7534 | } | 7449 | } |
| 7535 | 7450 | ||
| 7536 | fn zirAnyframeType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 7451 | fn zirAnyframeType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7537 | const tracy = trace(@src()); | ||
| 7538 | defer tracy.end(); | ||
| 7539 | |||
| 7540 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 7452 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 7541 | if (true) { | 7453 | if (true) { |
| 7542 | return sema.failWithUseOfAsync(block, block.nodeOffset(inst_data.src_node)); | 7454 | return sema.failWithUseOfAsync(block, block.nodeOffset(inst_data.src_node)); |
| ... | @@ -7550,9 +7462,6 @@ fn zirAnyframeType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -7550,9 +7462,6 @@ fn zirAnyframeType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 7550 | } | 7462 | } |
| 7551 | 7463 | ||
| 7552 | fn zirErrorUnionType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 7464 | fn zirErrorUnionType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7553 | const tracy = trace(@src()); | ||
| 7554 | defer tracy.end(); | ||
| 7555 | |||
| 7556 | const pt = sema.pt; | 7465 | const pt = sema.pt; |
| 7557 | const zcu = pt.zcu; | 7466 | const zcu = pt.zcu; |
| 7558 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 7467 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | @@ -7613,9 +7522,6 @@ fn zirErrorValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -7613,9 +7522,6 @@ fn zirErrorValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 7613 | } | 7522 | } |
| 7614 | 7523 | ||
| 7615 | fn zirIntFromError(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { | 7524 | fn zirIntFromError(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { |
| 7616 | const tracy = trace(@src()); | ||
| 7617 | defer tracy.end(); | ||
| 7618 | |||
| 7619 | const pt = sema.pt; | 7525 | const pt = sema.pt; |
| 7620 | const zcu = pt.zcu; | 7526 | const zcu = pt.zcu; |
| 7621 | const ip = &zcu.intern_pool; | 7527 | const ip = &zcu.intern_pool; |
| ... | @@ -7655,9 +7561,6 @@ fn zirIntFromError(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD | ... | @@ -7655,9 +7561,6 @@ fn zirIntFromError(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD |
| 7655 | } | 7561 | } |
| 7656 | 7562 | ||
| 7657 | fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { | 7563 | fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { |
| 7658 | const tracy = trace(@src()); | ||
| 7659 | defer tracy.end(); | ||
| 7660 | |||
| 7661 | const pt = sema.pt; | 7564 | const pt = sema.pt; |
| 7662 | const zcu = pt.zcu; | 7565 | const zcu = pt.zcu; |
| 7663 | const io = zcu.comp.io; | 7566 | const io = zcu.comp.io; |
| ... | @@ -7702,9 +7605,6 @@ fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD | ... | @@ -7702,9 +7605,6 @@ fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD |
| 7702 | } | 7605 | } |
| 7703 | 7606 | ||
| 7704 | fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 7607 | fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7705 | const tracy = trace(@src()); | ||
| 7706 | defer tracy.end(); | ||
| 7707 | |||
| 7708 | const pt = sema.pt; | 7608 | const pt = sema.pt; |
| 7709 | const zcu = pt.zcu; | 7609 | const zcu = pt.zcu; |
| 7710 | const ip = &zcu.intern_pool; | 7610 | const ip = &zcu.intern_pool; |
| ... | @@ -7759,8 +7659,6 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr | ... | @@ -7759,8 +7659,6 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 7759 | 7659 | ||
| 7760 | fn zirEnumLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 7660 | fn zirEnumLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 7761 | _ = block; | 7661 | _ = block; |
| 7762 | const tracy = trace(@src()); | ||
| 7763 | defer tracy.end(); | ||
| 7764 | 7662 | ||
| 7765 | const pt = sema.pt; | 7663 | const pt = sema.pt; |
| 7766 | const zcu = pt.zcu; | 7664 | const zcu = pt.zcu; |
| ... | @@ -7776,9 +7674,6 @@ fn zirEnumLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -7776,9 +7674,6 @@ fn zirEnumLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 7776 | } | 7674 | } |
| 7777 | 7675 | ||
| 7778 | fn zirDeclLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index, do_coerce: bool) CompileError!Air.Inst.Ref { | 7676 | fn zirDeclLiteral(sema: *Sema, block: *Block, inst: Zir.Inst.Index, do_coerce: bool) CompileError!Air.Inst.Ref { |
| 7779 | const tracy = trace(@src()); | ||
| 7780 | defer tracy.end(); | ||
| 7781 | |||
| 7782 | const pt = sema.pt; | 7677 | const pt = sema.pt; |
| 7783 | const zcu = pt.zcu; | 7678 | const zcu = pt.zcu; |
| 7784 | const comp = zcu.comp; | 7679 | const comp = zcu.comp; |
| ... | @@ -7960,9 +7855,6 @@ fn zirOptionalPayloadPtr( | ... | @@ -7960,9 +7855,6 @@ fn zirOptionalPayloadPtr( |
| 7960 | inst: Zir.Inst.Index, | 7855 | inst: Zir.Inst.Index, |
| 7961 | safety_check: bool, | 7856 | safety_check: bool, |
| 7962 | ) CompileError!Air.Inst.Ref { | 7857 | ) CompileError!Air.Inst.Ref { |
| 7963 | const tracy = trace(@src()); | ||
| 7964 | defer tracy.end(); | ||
| 7965 | |||
| 7966 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 7858 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 7967 | const optional_ptr = sema.resolveInst(inst_data.operand); | 7859 | const optional_ptr = sema.resolveInst(inst_data.operand); |
| 7968 | const src = block.nodeOffset(inst_data.src_node); | 7860 | const src = block.nodeOffset(inst_data.src_node); |
| ... | @@ -8051,9 +7943,6 @@ fn zirOptionalPayload( | ... | @@ -8051,9 +7943,6 @@ fn zirOptionalPayload( |
| 8051 | inst: Zir.Inst.Index, | 7943 | inst: Zir.Inst.Index, |
| 8052 | safety_check: bool, | 7944 | safety_check: bool, |
| 8053 | ) CompileError!Air.Inst.Ref { | 7945 | ) CompileError!Air.Inst.Ref { |
| 8054 | const tracy = trace(@src()); | ||
| 8055 | defer tracy.end(); | ||
| 8056 | |||
| 8057 | const pt = sema.pt; | 7946 | const pt = sema.pt; |
| 8058 | const zcu = pt.zcu; | 7947 | const zcu = pt.zcu; |
| 8059 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 7948 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | @@ -8105,9 +7994,6 @@ fn zirErrUnionPayload( | ... | @@ -8105,9 +7994,6 @@ fn zirErrUnionPayload( |
| 8105 | block: *Block, | 7994 | block: *Block, |
| 8106 | inst: Zir.Inst.Index, | 7995 | inst: Zir.Inst.Index, |
| 8107 | ) CompileError!Air.Inst.Ref { | 7996 | ) CompileError!Air.Inst.Ref { |
| 8108 | const tracy = trace(@src()); | ||
| 8109 | defer tracy.end(); | ||
| 8110 | |||
| 8111 | const pt = sema.pt; | 7997 | const pt = sema.pt; |
| 8112 | const zcu = pt.zcu; | 7998 | const zcu = pt.zcu; |
| 8113 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 7999 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | @@ -8164,9 +8050,6 @@ fn zirErrUnionPayloadPtr( | ... | @@ -8164,9 +8050,6 @@ fn zirErrUnionPayloadPtr( |
| 8164 | block: *Block, | 8050 | block: *Block, |
| 8165 | inst: Zir.Inst.Index, | 8051 | inst: Zir.Inst.Index, |
| 8166 | ) CompileError!Air.Inst.Ref { | 8052 | ) CompileError!Air.Inst.Ref { |
| 8167 | const tracy = trace(@src()); | ||
| 8168 | defer tracy.end(); | ||
| 8169 | |||
| 8170 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 8053 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 8171 | const operand = sema.resolveInst(inst_data.operand); | 8054 | const operand = sema.resolveInst(inst_data.operand); |
| 8172 | const src = block.nodeOffset(inst_data.src_node); | 8055 | const src = block.nodeOffset(inst_data.src_node); |
| ... | @@ -8256,9 +8139,6 @@ fn analyzeErrUnionPayloadPtr( | ... | @@ -8256,9 +8139,6 @@ fn analyzeErrUnionPayloadPtr( |
| 8256 | 8139 | ||
| 8257 | /// Value in, value out | 8140 | /// Value in, value out |
| 8258 | fn zirErrUnionCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 8141 | fn zirErrUnionCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8259 | const tracy = trace(@src()); | ||
| 8260 | defer tracy.end(); | ||
| 8261 | |||
| 8262 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 8142 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 8263 | const src = block.nodeOffset(inst_data.src_node); | 8143 | const src = block.nodeOffset(inst_data.src_node); |
| 8264 | const operand = sema.resolveInst(inst_data.operand); | 8144 | const operand = sema.resolveInst(inst_data.operand); |
| ... | @@ -8292,9 +8172,6 @@ fn analyzeErrUnionCode(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air | ... | @@ -8292,9 +8172,6 @@ fn analyzeErrUnionCode(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air |
| 8292 | 8172 | ||
| 8293 | /// Pointer in, value out | 8173 | /// Pointer in, value out |
| 8294 | fn zirErrUnionCodePtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 8174 | fn zirErrUnionCodePtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 8295 | const tracy = trace(@src()); | ||
| 8296 | defer tracy.end(); | ||
| 8297 | |||
| 8298 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 8175 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 8299 | const src = block.nodeOffset(inst_data.src_node); | 8176 | const src = block.nodeOffset(inst_data.src_node); |
| 8300 | const operand = sema.resolveInst(inst_data.operand); | 8177 | const operand = sema.resolveInst(inst_data.operand); |
| ... | @@ -9088,9 +8965,6 @@ fn zirParamAnytype( | ... | @@ -9088,9 +8965,6 @@ fn zirParamAnytype( |
| 9088 | } | 8965 | } |
| 9089 | 8966 | ||
| 9090 | fn zirAsNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 8967 | fn zirAsNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9091 | const tracy = trace(@src()); | ||
| 9092 | defer tracy.end(); | ||
| 9093 | |||
| 9094 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 8968 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9095 | const src = block.nodeOffset(inst_data.src_node); | 8969 | const src = block.nodeOffset(inst_data.src_node); |
| 9096 | const extra = sema.code.extraData(Zir.Inst.As, inst_data.payload_index).data; | 8970 | const extra = sema.code.extraData(Zir.Inst.As, inst_data.payload_index).data; |
| ... | @@ -9098,9 +8972,6 @@ fn zirAsNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -9098,9 +8972,6 @@ fn zirAsNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 9098 | } | 8972 | } |
| 9099 | 8973 | ||
| 9100 | fn zirAsShiftOperand(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 8974 | fn zirAsShiftOperand(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9101 | const tracy = trace(@src()); | ||
| 9102 | defer tracy.end(); | ||
| 9103 | |||
| 9104 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 8975 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9105 | const src = block.nodeOffset(inst_data.src_node); | 8976 | const src = block.nodeOffset(inst_data.src_node); |
| 9106 | const extra = sema.code.extraData(Zir.Inst.As, inst_data.payload_index).data; | 8977 | const extra = sema.code.extraData(Zir.Inst.As, inst_data.payload_index).data; |
| ... | @@ -9136,9 +9007,6 @@ fn analyzeAs( | ... | @@ -9136,9 +9007,6 @@ fn analyzeAs( |
| 9136 | } | 9007 | } |
| 9137 | 9008 | ||
| 9138 | fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9009 | fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9139 | const tracy = trace(@src()); | ||
| 9140 | defer tracy.end(); | ||
| 9141 | |||
| 9142 | const pt = sema.pt; | 9010 | const pt = sema.pt; |
| 9143 | const zcu = pt.zcu; | 9011 | const zcu = pt.zcu; |
| 9144 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 9012 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | @@ -9193,9 +9061,6 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -9193,9 +9061,6 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 9193 | } | 9061 | } |
| 9194 | 9062 | ||
| 9195 | fn zirFieldPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9063 | fn zirFieldPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9196 | const tracy = trace(@src()); | ||
| 9197 | defer tracy.end(); | ||
| 9198 | |||
| 9199 | const pt = sema.pt; | 9064 | const pt = sema.pt; |
| 9200 | const zcu = pt.zcu; | 9065 | const zcu = pt.zcu; |
| 9201 | const comp = zcu.comp; | 9066 | const comp = zcu.comp; |
| ... | @@ -9218,9 +9083,6 @@ fn zirFieldPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -9218,9 +9083,6 @@ fn zirFieldPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 9218 | } | 9083 | } |
| 9219 | 9084 | ||
| 9220 | fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9085 | fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9221 | const tracy = trace(@src()); | ||
| 9222 | defer tracy.end(); | ||
| 9223 | |||
| 9224 | const pt = sema.pt; | 9086 | const pt = sema.pt; |
| 9225 | const zcu = pt.zcu; | 9087 | const zcu = pt.zcu; |
| 9226 | const comp = zcu.comp; | 9088 | const comp = zcu.comp; |
| ... | @@ -9243,9 +9105,6 @@ fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -9243,9 +9105,6 @@ fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 9243 | } | 9105 | } |
| 9244 | 9106 | ||
| 9245 | fn zirStructInitFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9107 | fn zirStructInitFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9246 | const tracy = trace(@src()); | ||
| 9247 | defer tracy.end(); | ||
| 9248 | |||
| 9249 | const pt = sema.pt; | 9108 | const pt = sema.pt; |
| 9250 | const zcu = pt.zcu; | 9109 | const zcu = pt.zcu; |
| 9251 | const comp = zcu.comp; | 9110 | const comp = zcu.comp; |
| ... | @@ -9276,9 +9135,6 @@ fn zirStructInitFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi | ... | @@ -9276,9 +9135,6 @@ fn zirStructInitFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi |
| 9276 | } | 9135 | } |
| 9277 | 9136 | ||
| 9278 | fn zirFieldPtrNamedLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9137 | fn zirFieldPtrNamedLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9279 | const tracy = trace(@src()); | ||
| 9280 | defer tracy.end(); | ||
| 9281 | |||
| 9282 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 9138 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9283 | const src = block.nodeOffset(inst_data.src_node); | 9139 | const src = block.nodeOffset(inst_data.src_node); |
| 9284 | const field_name_src = block.builtinCallArgSrc(inst_data.src_node, 1); | 9140 | const field_name_src = block.builtinCallArgSrc(inst_data.src_node, 1); |
| ... | @@ -9289,9 +9145,6 @@ fn zirFieldPtrNamedLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil | ... | @@ -9289,9 +9145,6 @@ fn zirFieldPtrNamedLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil |
| 9289 | } | 9145 | } |
| 9290 | 9146 | ||
| 9291 | fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9147 | fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9292 | const tracy = trace(@src()); | ||
| 9293 | defer tracy.end(); | ||
| 9294 | |||
| 9295 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 9148 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9296 | const src = block.nodeOffset(inst_data.src_node); | 9149 | const src = block.nodeOffset(inst_data.src_node); |
| 9297 | const field_name_src = block.builtinCallArgSrc(inst_data.src_node, 1); | 9150 | const field_name_src = block.builtinCallArgSrc(inst_data.src_node, 1); |
| ... | @@ -9302,9 +9155,6 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -9302,9 +9155,6 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 9302 | } | 9155 | } |
| 9303 | 9156 | ||
| 9304 | fn zirIntCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9157 | fn zirIntCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9305 | const tracy = trace(@src()); | ||
| 9306 | defer tracy.end(); | ||
| 9307 | |||
| 9308 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 9158 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9309 | const src = block.nodeOffset(inst_data.src_node); | 9159 | const src = block.nodeOffset(inst_data.src_node); |
| 9310 | const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0); | 9160 | const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0); |
| ... | @@ -9375,9 +9225,6 @@ fn intCast( | ... | @@ -9375,9 +9225,6 @@ fn intCast( |
| 9375 | } | 9225 | } |
| 9376 | 9226 | ||
| 9377 | fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9227 | fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9378 | const tracy = trace(@src()); | ||
| 9379 | defer tracy.end(); | ||
| 9380 | |||
| 9381 | const pt = sema.pt; | 9228 | const pt = sema.pt; |
| 9382 | const zcu = pt.zcu; | 9229 | const zcu = pt.zcu; |
| 9383 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 9230 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | @@ -9541,9 +9388,6 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -9541,9 +9388,6 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 9541 | } | 9388 | } |
| 9542 | 9389 | ||
| 9543 | fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9390 | fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9544 | const tracy = trace(@src()); | ||
| 9545 | defer tracy.end(); | ||
| 9546 | |||
| 9547 | const pt = sema.pt; | 9391 | const pt = sema.pt; |
| 9548 | const zcu = pt.zcu; | 9392 | const zcu = pt.zcu; |
| 9549 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 9393 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | @@ -9609,9 +9453,6 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -9609,9 +9453,6 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 9609 | } | 9453 | } |
| 9610 | 9454 | ||
| 9611 | fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9455 | fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9612 | const tracy = trace(@src()); | ||
| 9613 | defer tracy.end(); | ||
| 9614 | |||
| 9615 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 9456 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9616 | const src = block.nodeOffset(inst_data.src_node); | 9457 | const src = block.nodeOffset(inst_data.src_node); |
| 9617 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 9458 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| ... | @@ -9621,9 +9462,6 @@ fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -9621,9 +9462,6 @@ fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 9621 | } | 9462 | } |
| 9622 | 9463 | ||
| 9623 | fn zirElemPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9464 | fn zirElemPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9624 | const tracy = trace(@src()); | ||
| 9625 | defer tracy.end(); | ||
| 9626 | |||
| 9627 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 9465 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9628 | const src = block.nodeOffset(inst_data.src_node); | 9466 | const src = block.nodeOffset(inst_data.src_node); |
| 9629 | const elem_index_src = block.src(.{ .node_offset_array_access_index = inst_data.src_node }); | 9467 | const elem_index_src = block.src(.{ .node_offset_array_access_index = inst_data.src_node }); |
| ... | @@ -9643,9 +9481,6 @@ fn zirElemPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -9643,9 +9481,6 @@ fn zirElemPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 9643 | } | 9481 | } |
| 9644 | 9482 | ||
| 9645 | fn zirElemValImm(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9483 | fn zirElemValImm(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9646 | const tracy = trace(@src()); | ||
| 9647 | defer tracy.end(); | ||
| 9648 | |||
| 9649 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].elem_val_imm; | 9484 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].elem_val_imm; |
| 9650 | const array = sema.resolveInst(inst_data.operand); | 9485 | const array = sema.resolveInst(inst_data.operand); |
| 9651 | const elem_index = try sema.pt.intRef(.usize, inst_data.idx); | 9486 | const elem_index = try sema.pt.intRef(.usize, inst_data.idx); |
| ... | @@ -9653,9 +9488,6 @@ fn zirElemValImm(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -9653,9 +9488,6 @@ fn zirElemValImm(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 9653 | } | 9488 | } |
| 9654 | 9489 | ||
| 9655 | fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9490 | fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9656 | const tracy = trace(@src()); | ||
| 9657 | defer tracy.end(); | ||
| 9658 | |||
| 9659 | const pt = sema.pt; | 9491 | const pt = sema.pt; |
| 9660 | const zcu = pt.zcu; | 9492 | const zcu = pt.zcu; |
| 9661 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 9493 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | @@ -9684,9 +9516,6 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -9684,9 +9516,6 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 9684 | } | 9516 | } |
| 9685 | 9517 | ||
| 9686 | fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9518 | fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9687 | const tracy = trace(@src()); | ||
| 9688 | defer tracy.end(); | ||
| 9689 | |||
| 9690 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 9519 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9691 | const src = block.nodeOffset(inst_data.src_node); | 9520 | const src = block.nodeOffset(inst_data.src_node); |
| 9692 | const elem_index_src = block.src(.{ .node_offset_array_access_index = inst_data.src_node }); | 9521 | const elem_index_src = block.src(.{ .node_offset_array_access_index = inst_data.src_node }); |
| ... | @@ -9698,9 +9527,6 @@ fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -9698,9 +9527,6 @@ fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 9698 | } | 9527 | } |
| 9699 | 9528 | ||
| 9700 | fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9529 | fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9701 | const tracy = trace(@src()); | ||
| 9702 | defer tracy.end(); | ||
| 9703 | |||
| 9704 | const pt = sema.pt; | 9530 | const pt = sema.pt; |
| 9705 | const zcu = pt.zcu; | 9531 | const zcu = pt.zcu; |
| 9706 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 9532 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | @@ -9719,9 +9545,6 @@ fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile | ... | @@ -9719,9 +9545,6 @@ fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile |
| 9719 | } | 9545 | } |
| 9720 | 9546 | ||
| 9721 | fn zirSliceStart(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9547 | fn zirSliceStart(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9722 | const tracy = trace(@src()); | ||
| 9723 | defer tracy.end(); | ||
| 9724 | |||
| 9725 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 9548 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9726 | const src = block.nodeOffset(inst_data.src_node); | 9549 | const src = block.nodeOffset(inst_data.src_node); |
| 9727 | const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data; | 9550 | const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data; |
| ... | @@ -9735,9 +9558,6 @@ fn zirSliceStart(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -9735,9 +9558,6 @@ fn zirSliceStart(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 9735 | } | 9558 | } |
| 9736 | 9559 | ||
| 9737 | fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9560 | fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9738 | const tracy = trace(@src()); | ||
| 9739 | defer tracy.end(); | ||
| 9740 | |||
| 9741 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 9561 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9742 | const src = block.nodeOffset(inst_data.src_node); | 9562 | const src = block.nodeOffset(inst_data.src_node); |
| 9743 | const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data; | 9563 | const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data; |
| ... | @@ -9752,9 +9572,6 @@ fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -9752,9 +9572,6 @@ fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 9752 | } | 9572 | } |
| 9753 | 9573 | ||
| 9754 | fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9574 | fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9755 | const tracy = trace(@src()); | ||
| 9756 | defer tracy.end(); | ||
| 9757 | |||
| 9758 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 9575 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9759 | const src = block.nodeOffset(inst_data.src_node); | 9576 | const src = block.nodeOffset(inst_data.src_node); |
| 9760 | const sentinel_src = block.src(.{ .node_offset_slice_sentinel = inst_data.src_node }); | 9577 | const sentinel_src = block.src(.{ .node_offset_slice_sentinel = inst_data.src_node }); |
| ... | @@ -9771,9 +9588,6 @@ fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -9771,9 +9588,6 @@ fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 9771 | } | 9588 | } |
| 9772 | 9589 | ||
| 9773 | fn zirSliceLength(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9590 | fn zirSliceLength(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9774 | const tracy = trace(@src()); | ||
| 9775 | defer tracy.end(); | ||
| 9776 | |||
| 9777 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 9591 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 9778 | const src = block.nodeOffset(inst_data.src_node); | 9592 | const src = block.nodeOffset(inst_data.src_node); |
| 9779 | const extra = sema.code.extraData(Zir.Inst.SliceLength, inst_data.payload_index).data; | 9593 | const extra = sema.code.extraData(Zir.Inst.SliceLength, inst_data.payload_index).data; |
| ... | @@ -9793,9 +9607,6 @@ fn zirSliceLength(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -9793,9 +9607,6 @@ fn zirSliceLength(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 9793 | } | 9607 | } |
| 9794 | 9608 | ||
| 9795 | fn zirSliceSentinelTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9609 | fn zirSliceSentinelTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9796 | const tracy = trace(@src()); | ||
| 9797 | defer tracy.end(); | ||
| 9798 | |||
| 9799 | const pt = sema.pt; | 9610 | const pt = sema.pt; |
| 9800 | const zcu = pt.zcu; | 9611 | const zcu = pt.zcu; |
| 9801 | 9612 | ||
| ... | @@ -9833,9 +9644,6 @@ fn zirSliceSentinelTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE | ... | @@ -9833,9 +9644,6 @@ fn zirSliceSentinelTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 9833 | } | 9644 | } |
| 9834 | 9645 | ||
| 9835 | fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 9646 | fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 9836 | const tracy = trace(@src()); | ||
| 9837 | defer tracy.end(); | ||
| 9838 | |||
| 9839 | const pt = sema.pt; | 9647 | const pt = sema.pt; |
| 9840 | const zcu = pt.zcu; | 9648 | const zcu = pt.zcu; |
| 9841 | const gpa = sema.gpa; | 9649 | const gpa = sema.gpa; |
| ... | @@ -9999,8 +9807,6 @@ fn zirSwitchBlock( | ... | @@ -9999,8 +9807,6 @@ fn zirSwitchBlock( |
| 9999 | inst: Zir.Inst.Index, | 9807 | inst: Zir.Inst.Index, |
| 10000 | operand_is_ref: bool, | 9808 | operand_is_ref: bool, |
| 10001 | ) CompileError!Air.Inst.Ref { | 9809 | ) CompileError!Air.Inst.Ref { |
| 10002 | const tracy = trace(@src()); | ||
| 10003 | defer tracy.end(); | ||
| 10004 | const zir_switch = sema.code.getSwitchBlock(inst); | 9810 | const zir_switch = sema.code.getSwitchBlock(inst); |
| 10005 | 9811 | ||
| 10006 | const block_inst: Air.Inst.Index = @enumFromInt(sema.air_instructions.len); | 9812 | const block_inst: Air.Inst.Index = @enumFromInt(sema.air_instructions.len); |
| ... | @@ -12847,9 +12653,6 @@ fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -12847,9 +12653,6 @@ fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 12847 | } | 12653 | } |
| 12848 | 12654 | ||
| 12849 | fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 12655 | fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 12850 | const tracy = trace(@src()); | ||
| 12851 | defer tracy.end(); | ||
| 12852 | |||
| 12853 | const pt = sema.pt; | 12656 | const pt = sema.pt; |
| 12854 | const zcu = pt.zcu; | 12657 | const zcu = pt.zcu; |
| 12855 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_tok; | 12658 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_tok; |
| ... | @@ -12898,9 +12701,6 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -12898,9 +12701,6 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 12898 | } | 12701 | } |
| 12899 | 12702 | ||
| 12900 | fn zirEmbedFile(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 12703 | fn zirEmbedFile(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 12901 | const tracy = trace(@src()); | ||
| 12902 | defer tracy.end(); | ||
| 12903 | |||
| 12904 | const pt = sema.pt; | 12704 | const pt = sema.pt; |
| 12905 | const zcu = pt.zcu; | 12705 | const zcu = pt.zcu; |
| 12906 | 12706 | ||
| ... | @@ -12935,9 +12735,6 @@ fn zirShl( | ... | @@ -12935,9 +12735,6 @@ fn zirShl( |
| 12935 | inst: Zir.Inst.Index, | 12735 | inst: Zir.Inst.Index, |
| 12936 | air_tag: Air.Inst.Tag, | 12736 | air_tag: Air.Inst.Tag, |
| 12937 | ) CompileError!Air.Inst.Ref { | 12737 | ) CompileError!Air.Inst.Ref { |
| 12938 | const tracy = trace(@src()); | ||
| 12939 | defer tracy.end(); | ||
| 12940 | |||
| 12941 | const pt = sema.pt; | 12738 | const pt = sema.pt; |
| 12942 | const zcu = pt.zcu; | 12739 | const zcu = pt.zcu; |
| 12943 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 12740 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | @@ -13125,9 +12922,6 @@ fn zirShr( | ... | @@ -13125,9 +12922,6 @@ fn zirShr( |
| 13125 | inst: Zir.Inst.Index, | 12922 | inst: Zir.Inst.Index, |
| 13126 | air_tag: Air.Inst.Tag, | 12923 | air_tag: Air.Inst.Tag, |
| 13127 | ) CompileError!Air.Inst.Ref { | 12924 | ) CompileError!Air.Inst.Ref { |
| 13128 | const tracy = trace(@src()); | ||
| 13129 | defer tracy.end(); | ||
| 13130 | |||
| 13131 | const pt = sema.pt; | 12925 | const pt = sema.pt; |
| 13132 | const zcu = pt.zcu; | 12926 | const zcu = pt.zcu; |
| 13133 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 12927 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | @@ -13255,9 +13049,6 @@ fn zirBitwise( | ... | @@ -13255,9 +13049,6 @@ fn zirBitwise( |
| 13255 | inst: Zir.Inst.Index, | 13049 | inst: Zir.Inst.Index, |
| 13256 | air_tag: Air.Inst.Tag, | 13050 | air_tag: Air.Inst.Tag, |
| 13257 | ) CompileError!Air.Inst.Ref { | 13051 | ) CompileError!Air.Inst.Ref { |
| 13258 | const tracy = trace(@src()); | ||
| 13259 | defer tracy.end(); | ||
| 13260 | |||
| 13261 | const pt = sema.pt; | 13052 | const pt = sema.pt; |
| 13262 | const zcu = pt.zcu; | 13053 | const zcu = pt.zcu; |
| 13263 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 13054 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | @@ -13438,9 +13229,6 @@ fn analyzeTupleCat( | ... | @@ -13438,9 +13229,6 @@ fn analyzeTupleCat( |
| 13438 | } | 13229 | } |
| 13439 | 13230 | ||
| 13440 | fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 13231 | fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 13441 | const tracy = trace(@src()); | ||
| 13442 | defer tracy.end(); | ||
| 13443 | |||
| 13444 | const pt = sema.pt; | 13232 | const pt = sema.pt; |
| 13445 | const zcu = pt.zcu; | 13233 | const zcu = pt.zcu; |
| 13446 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 13234 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | @@ -13933,9 +13721,6 @@ fn zirArithmetic( | ... | @@ -13933,9 +13721,6 @@ fn zirArithmetic( |
| 13933 | zir_tag: Zir.Inst.Tag, | 13721 | zir_tag: Zir.Inst.Tag, |
| 13934 | safety: bool, | 13722 | safety: bool, |
| 13935 | ) CompileError!Air.Inst.Ref { | 13723 | ) CompileError!Air.Inst.Ref { |
| 13936 | const tracy = trace(@src()); | ||
| 13937 | defer tracy.end(); | ||
| 13938 | |||
| 13939 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 13724 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 13940 | const src = block.src(.{ .node_offset_bin_op = inst_data.src_node }); | 13725 | const src = block.src(.{ .node_offset_bin_op = inst_data.src_node }); |
| 13941 | const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node }); | 13726 | const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node }); |
| ... | @@ -14663,9 +14448,6 @@ fn zirOverflowArithmetic( | ... | @@ -14663,9 +14448,6 @@ fn zirOverflowArithmetic( |
| 14663 | extended: Zir.Inst.Extended.InstData, | 14448 | extended: Zir.Inst.Extended.InstData, |
| 14664 | zir_tag: Zir.Inst.Extended, | 14449 | zir_tag: Zir.Inst.Extended, |
| 14665 | ) CompileError!Air.Inst.Ref { | 14450 | ) CompileError!Air.Inst.Ref { |
| 14666 | const tracy = trace(@src()); | ||
| 14667 | defer tracy.end(); | ||
| 14668 | |||
| 14669 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; | 14451 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 14670 | const src = block.nodeOffset(extra.node); | 14452 | const src = block.nodeOffset(extra.node); |
| 14671 | 14453 | ||
| ... | @@ -15183,9 +14965,6 @@ fn analyzePtrArithmetic( | ... | @@ -15183,9 +14965,6 @@ fn analyzePtrArithmetic( |
| 15183 | } | 14965 | } |
| 15184 | 14966 | ||
| 15185 | fn zirLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 14967 | fn zirLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 15186 | const tracy = trace(@src()); | ||
| 15187 | defer tracy.end(); | ||
| 15188 | |||
| 15189 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 14968 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 15190 | const src = block.nodeOffset(inst_data.src_node); | 14969 | const src = block.nodeOffset(inst_data.src_node); |
| 15191 | const ptr_src = src; // TODO better source location | 14970 | const ptr_src = src; // TODO better source location |
| ... | @@ -15199,9 +14978,6 @@ fn zirAsm( | ... | @@ -15199,9 +14978,6 @@ fn zirAsm( |
| 15199 | extended: Zir.Inst.Extended.InstData, | 14978 | extended: Zir.Inst.Extended.InstData, |
| 15200 | tmpl_is_expr: bool, | 14979 | tmpl_is_expr: bool, |
| 15201 | ) CompileError!Air.Inst.Ref { | 14980 | ) CompileError!Air.Inst.Ref { |
| 15202 | const tracy = trace(@src()); | ||
| 15203 | defer tracy.end(); | ||
| 15204 | |||
| 15205 | const pt = sema.pt; | 14981 | const pt = sema.pt; |
| 15206 | const zcu = pt.zcu; | 14982 | const zcu = pt.zcu; |
| 15207 | const comp = zcu.comp; | 14983 | const comp = zcu.comp; |
| ... | @@ -15393,9 +15169,6 @@ fn zirCmpEq( | ... | @@ -15393,9 +15169,6 @@ fn zirCmpEq( |
| 15393 | op: std.math.CompareOperator, | 15169 | op: std.math.CompareOperator, |
| 15394 | air_tag: Air.Inst.Tag, | 15170 | air_tag: Air.Inst.Tag, |
| 15395 | ) CompileError!Air.Inst.Ref { | 15171 | ) CompileError!Air.Inst.Ref { |
| 15396 | const tracy = trace(@src()); | ||
| 15397 | defer tracy.end(); | ||
| 15398 | |||
| 15399 | const pt = sema.pt; | 15172 | const pt = sema.pt; |
| 15400 | const zcu = pt.zcu; | 15173 | const zcu = pt.zcu; |
| 15401 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 15174 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | @@ -15509,9 +15282,6 @@ fn zirCmp( | ... | @@ -15509,9 +15282,6 @@ fn zirCmp( |
| 15509 | inst: Zir.Inst.Index, | 15282 | inst: Zir.Inst.Index, |
| 15510 | op: std.math.CompareOperator, | 15283 | op: std.math.CompareOperator, |
| 15511 | ) CompileError!Air.Inst.Ref { | 15284 | ) CompileError!Air.Inst.Ref { |
| 15512 | const tracy = trace(@src()); | ||
| 15513 | defer tracy.end(); | ||
| 15514 | |||
| 15515 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 15285 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 15516 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 15286 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 15517 | const src: LazySrcLoc = block.nodeOffset(inst_data.src_node); | 15287 | const src: LazySrcLoc = block.nodeOffset(inst_data.src_node); |
| ... | @@ -15852,9 +15622,6 @@ fn zirBuiltinSrc( | ... | @@ -15852,9 +15622,6 @@ fn zirBuiltinSrc( |
| 15852 | block: *Block, | 15622 | block: *Block, |
| 15853 | extended: Zir.Inst.Extended.InstData, | 15623 | extended: Zir.Inst.Extended.InstData, |
| 15854 | ) CompileError!Air.Inst.Ref { | 15624 | ) CompileError!Air.Inst.Ref { |
| 15855 | const tracy = trace(@src()); | ||
| 15856 | defer tracy.end(); | ||
| 15857 | |||
| 15858 | const pt = sema.pt; | 15625 | const pt = sema.pt; |
| 15859 | const zcu = pt.zcu; | 15626 | const zcu = pt.zcu; |
| 15860 | const comp = zcu.comp; | 15627 | const comp = zcu.comp; |
| ... | @@ -17181,9 +16948,6 @@ fn zirTypeofPeer( | ... | @@ -17181,9 +16948,6 @@ fn zirTypeofPeer( |
| 17181 | extended: Zir.Inst.Extended.InstData, | 16948 | extended: Zir.Inst.Extended.InstData, |
| 17182 | inst: Zir.Inst.Index, | 16949 | inst: Zir.Inst.Index, |
| 17183 | ) CompileError!Air.Inst.Ref { | 16950 | ) CompileError!Air.Inst.Ref { |
| 17184 | const tracy = trace(@src()); | ||
| 17185 | defer tracy.end(); | ||
| 17186 | |||
| 17187 | const extra = sema.code.extraData(Zir.Inst.TypeOfPeer, extended.operand); | 16951 | const extra = sema.code.extraData(Zir.Inst.TypeOfPeer, extended.operand); |
| 17188 | const src = block.nodeOffset(extra.data.src_node); | 16952 | const src = block.nodeOffset(extra.data.src_node); |
| 17189 | const body = sema.code.bodySlice(extra.data.body_index, extra.data.body_len); | 16953 | const body = sema.code.bodySlice(extra.data.body_index, extra.data.body_len); |
| ... | @@ -17249,9 +17013,6 @@ fn zirBoolBr( | ... | @@ -17249,9 +17013,6 @@ fn zirBoolBr( |
| 17249 | inst: Zir.Inst.Index, | 17013 | inst: Zir.Inst.Index, |
| 17250 | is_bool_or: bool, | 17014 | is_bool_or: bool, |
| 17251 | ) CompileError!Air.Inst.Ref { | 17015 | ) CompileError!Air.Inst.Ref { |
| 17252 | const tracy = trace(@src()); | ||
| 17253 | defer tracy.end(); | ||
| 17254 | |||
| 17255 | const pt = sema.pt; | 17016 | const pt = sema.pt; |
| 17256 | const zcu = pt.zcu; | 17017 | const zcu = pt.zcu; |
| 17257 | const gpa = sema.gpa; | 17018 | const gpa = sema.gpa; |
| ... | @@ -17418,9 +17179,6 @@ fn zirIsNonNull( | ... | @@ -17418,9 +17179,6 @@ fn zirIsNonNull( |
| 17418 | block: *Block, | 17179 | block: *Block, |
| 17419 | inst: Zir.Inst.Index, | 17180 | inst: Zir.Inst.Index, |
| 17420 | ) CompileError!Air.Inst.Ref { | 17181 | ) CompileError!Air.Inst.Ref { |
| 17421 | const tracy = trace(@src()); | ||
| 17422 | defer tracy.end(); | ||
| 17423 | |||
| 17424 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 17182 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 17425 | const src = block.nodeOffset(inst_data.src_node); | 17183 | const src = block.nodeOffset(inst_data.src_node); |
| 17426 | const operand = sema.resolveInst(inst_data.operand); | 17184 | const operand = sema.resolveInst(inst_data.operand); |
| ... | @@ -17433,9 +17191,6 @@ fn zirIsNonNullPtr( | ... | @@ -17433,9 +17191,6 @@ fn zirIsNonNullPtr( |
| 17433 | block: *Block, | 17191 | block: *Block, |
| 17434 | inst: Zir.Inst.Index, | 17192 | inst: Zir.Inst.Index, |
| 17435 | ) CompileError!Air.Inst.Ref { | 17193 | ) CompileError!Air.Inst.Ref { |
| 17436 | const tracy = trace(@src()); | ||
| 17437 | defer tracy.end(); | ||
| 17438 | |||
| 17439 | const pt = sema.pt; | 17194 | const pt = sema.pt; |
| 17440 | const zcu = pt.zcu; | 17195 | const zcu = pt.zcu; |
| 17441 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 17196 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | @@ -17472,9 +17227,6 @@ fn checkErrorType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void { | ... | @@ -17472,9 +17227,6 @@ fn checkErrorType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void { |
| 17472 | } | 17227 | } |
| 17473 | 17228 | ||
| 17474 | fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 17229 | fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 17475 | const tracy = trace(@src()); | ||
| 17476 | defer tracy.end(); | ||
| 17477 | |||
| 17478 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 17230 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 17479 | const src = block.nodeOffset(inst_data.src_node); | 17231 | const src = block.nodeOffset(inst_data.src_node); |
| 17480 | const operand = sema.resolveInst(inst_data.operand); | 17232 | const operand = sema.resolveInst(inst_data.operand); |
| ... | @@ -17483,9 +17235,6 @@ fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17483,9 +17235,6 @@ fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17483 | } | 17235 | } |
| 17484 | 17236 | ||
| 17485 | fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 17237 | fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 17486 | const tracy = trace(@src()); | ||
| 17487 | defer tracy.end(); | ||
| 17488 | |||
| 17489 | const pt = sema.pt; | 17238 | const pt = sema.pt; |
| 17490 | const zcu = pt.zcu; | 17239 | const zcu = pt.zcu; |
| 17491 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 17240 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | @@ -17500,9 +17249,6 @@ fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -17500,9 +17249,6 @@ fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 17500 | } | 17249 | } |
| 17501 | 17250 | ||
| 17502 | fn zirRetIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 17251 | fn zirRetIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 17503 | const tracy = trace(@src()); | ||
| 17504 | defer tracy.end(); | ||
| 17505 | |||
| 17506 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 17252 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 17507 | const src = block.nodeOffset(inst_data.src_node); | 17253 | const src = block.nodeOffset(inst_data.src_node); |
| 17508 | const operand = sema.resolveInst(inst_data.operand); | 17254 | const operand = sema.resolveInst(inst_data.operand); |
| ... | @@ -17514,9 +17260,6 @@ fn zirCondbr( | ... | @@ -17514,9 +17260,6 @@ fn zirCondbr( |
| 17514 | parent_block: *Block, | 17260 | parent_block: *Block, |
| 17515 | inst: Zir.Inst.Index, | 17261 | inst: Zir.Inst.Index, |
| 17516 | ) CompileError!void { | 17262 | ) CompileError!void { |
| 17517 | const tracy = trace(@src()); | ||
| 17518 | defer tracy.end(); | ||
| 17519 | |||
| 17520 | const pt = sema.pt; | 17263 | const pt = sema.pt; |
| 17521 | const zcu = pt.zcu; | 17264 | const zcu = pt.zcu; |
| 17522 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 17265 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | @@ -17866,9 +17609,6 @@ fn zirRetImplicit( | ... | @@ -17866,9 +17609,6 @@ fn zirRetImplicit( |
| 17866 | block: *Block, | 17609 | block: *Block, |
| 17867 | inst: Zir.Inst.Index, | 17610 | inst: Zir.Inst.Index, |
| 17868 | ) CompileError!void { | 17611 | ) CompileError!void { |
| 17869 | const tracy = trace(@src()); | ||
| 17870 | defer tracy.end(); | ||
| 17871 | |||
| 17872 | const pt = sema.pt; | 17612 | const pt = sema.pt; |
| 17873 | const zcu = pt.zcu; | 17613 | const zcu = pt.zcu; |
| 17874 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok; | 17614 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok; |
| ... | @@ -17913,9 +17653,6 @@ fn zirRetImplicit( | ... | @@ -17913,9 +17653,6 @@ fn zirRetImplicit( |
| 17913 | } | 17653 | } |
| 17914 | 17654 | ||
| 17915 | fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 17655 | fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 17916 | const tracy = trace(@src()); | ||
| 17917 | defer tracy.end(); | ||
| 17918 | |||
| 17919 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 17656 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 17920 | const operand = sema.resolveInst(inst_data.operand); | 17657 | const operand = sema.resolveInst(inst_data.operand); |
| 17921 | const src = block.nodeOffset(inst_data.src_node); | 17658 | const src = block.nodeOffset(inst_data.src_node); |
| ... | @@ -17924,9 +17661,6 @@ fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi | ... | @@ -17924,9 +17661,6 @@ fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi |
| 17924 | } | 17661 | } |
| 17925 | 17662 | ||
| 17926 | fn zirRetLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 17663 | fn zirRetLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| 17927 | const tracy = trace(@src()); | ||
| 17928 | defer tracy.end(); | ||
| 17929 | |||
| 17930 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 17664 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 17931 | const src = block.nodeOffset(inst_data.src_node); | 17665 | const src = block.nodeOffset(inst_data.src_node); |
| 17932 | const ret_ptr = sema.resolveInst(inst_data.operand); | 17666 | const ret_ptr = sema.resolveInst(inst_data.operand); |
| ... | @@ -18071,9 +17805,6 @@ fn zirRestoreErrRetIndex(sema: *Sema, start_block: *Block, extended: Zir.Inst.Ex | ... | @@ -18071,9 +17805,6 @@ fn zirRestoreErrRetIndex(sema: *Sema, start_block: *Block, extended: Zir.Inst.Ex |
| 18071 | /// its state at the point `block` was reached (or, if `block` is `none`, the | 17805 | /// its state at the point `block` was reached (or, if `block` is `none`, the |
| 18072 | /// point this function began execution). | 17806 | /// point this function began execution). |
| 18073 | fn restoreErrRetIndex(sema: *Sema, start_block: *Block, src: LazySrcLoc, target_block: Zir.Inst.Ref, operand_zir: Zir.Inst.Ref) CompileError!void { | 17807 | fn restoreErrRetIndex(sema: *Sema, start_block: *Block, src: LazySrcLoc, target_block: Zir.Inst.Ref, operand_zir: Zir.Inst.Ref) CompileError!void { |
| 18074 | const tracy = trace(@src()); | ||
| 18075 | defer tracy.end(); | ||
| 18076 | |||
| 18077 | const pt = sema.pt; | 17808 | const pt = sema.pt; |
| 18078 | const zcu = pt.zcu; | 17809 | const zcu = pt.zcu; |
| 18079 | 17810 | ||
| ... | @@ -18229,9 +17960,6 @@ fn floatOpAllowed(tag: Zir.Inst.Tag) bool { | ... | @@ -18229,9 +17960,6 @@ fn floatOpAllowed(tag: Zir.Inst.Tag) bool { |
| 18229 | } | 17960 | } |
| 18230 | 17961 | ||
| 18231 | fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 17962 | fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 18232 | const tracy = trace(@src()); | ||
| 18233 | defer tracy.end(); | ||
| 18234 | |||
| 18235 | const pt = sema.pt; | 17963 | const pt = sema.pt; |
| 18236 | const zcu = pt.zcu; | 17964 | const zcu = pt.zcu; |
| 18237 | const comp = zcu.comp; | 17965 | const comp = zcu.comp; |
| ... | @@ -18361,9 +18089,6 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -18361,9 +18089,6 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 18361 | } | 18089 | } |
| 18362 | 18090 | ||
| 18363 | fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 18091 | fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 18364 | const tracy = trace(@src()); | ||
| 18365 | defer tracy.end(); | ||
| 18366 | |||
| 18367 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 18092 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 18368 | const src = block.nodeOffset(inst_data.src_node); | 18093 | const src = block.nodeOffset(inst_data.src_node); |
| 18369 | const ty_src = block.src(.{ .node_offset_init_ty = inst_data.src_node }); | 18094 | const ty_src = block.src(.{ .node_offset_init_ty = inst_data.src_node }); |
| ... | @@ -18382,9 +18107,6 @@ fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE | ... | @@ -18382,9 +18107,6 @@ fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 18382 | } | 18107 | } |
| 18383 | 18108 | ||
| 18384 | fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is_byref: bool) CompileError!Air.Inst.Ref { | 18109 | fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is_byref: bool) CompileError!Air.Inst.Ref { |
| 18385 | const tracy = trace(@src()); | ||
| 18386 | defer tracy.end(); | ||
| 18387 | |||
| 18388 | const pt = sema.pt; | 18110 | const pt = sema.pt; |
| 18389 | const zcu = pt.zcu; | 18111 | const zcu = pt.zcu; |
| 18390 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 18112 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| ... | @@ -19622,9 +19344,6 @@ fn zirUnaryMath( | ... | @@ -19622,9 +19344,6 @@ fn zirUnaryMath( |
| 19622 | air_tag: Air.Inst.Tag, | 19344 | air_tag: Air.Inst.Tag, |
| 19623 | comptime eval: fn (Value, Type, Allocator, Zcu.PerThread) Allocator.Error!Value, | 19345 | comptime eval: fn (Value, Type, Allocator, Zcu.PerThread) Allocator.Error!Value, |
| 19624 | ) CompileError!Air.Inst.Ref { | 19346 | ) CompileError!Air.Inst.Ref { |
| 19625 | const tracy = trace(@src()); | ||
| 19626 | defer tracy.end(); | ||
| 19627 | |||
| 19628 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 19347 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 19629 | const operand = sema.resolveInst(inst_data.operand); | 19348 | const operand = sema.resolveInst(inst_data.operand); |
| 19630 | const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0); | 19349 | const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0); |
| ... | @@ -23441,9 +23160,6 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -23441,9 +23160,6 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 23441 | } | 23160 | } |
| 23442 | 23161 | ||
| 23443 | fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 23162 | fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 23444 | const tracy = trace(@src()); | ||
| 23445 | defer tracy.end(); | ||
| 23446 | |||
| 23447 | const pt = sema.pt; | 23163 | const pt = sema.pt; |
| 23448 | const zcu = pt.zcu; | 23164 | const zcu = pt.zcu; |
| 23449 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 23165 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | @@ -24489,9 +24205,6 @@ fn zirResume(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -24489,9 +24205,6 @@ fn zirResume(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 24489 | } | 24205 | } |
| 24490 | 24206 | ||
| 24491 | fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 24207 | fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 24492 | const tracy = trace(@src()); | ||
| 24493 | defer tracy.end(); | ||
| 24494 | |||
| 24495 | const pt = sema.pt; | 24208 | const pt = sema.pt; |
| 24496 | const zcu = pt.zcu; | 24209 | const zcu = pt.zcu; |
| 24497 | const comp = zcu.comp; | 24210 | const comp = zcu.comp; |
src/Sema/type_resolution.zig+21| ... | @@ -13,6 +13,7 @@ const LazySrcLoc = Zcu.LazySrcLoc; | ... | @@ -13,6 +13,7 @@ const LazySrcLoc = Zcu.LazySrcLoc; |
| 13 | const InternPool = @import("../InternPool.zig"); | 13 | const InternPool = @import("../InternPool.zig"); |
| 14 | const Alignment = InternPool.Alignment; | 14 | const Alignment = InternPool.Alignment; |
| 15 | const arith = @import("arith.zig"); | 15 | const arith = @import("arith.zig"); |
| 16 | const trace = @import("../tracy.zig").trace; | ||
| 16 | 17 | ||
| 17 | pub const LayoutResolveReason = enum { | 18 | pub const LayoutResolveReason = enum { |
| 18 | variable, | 19 | variable, |
| ... | @@ -174,6 +175,11 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void { | ... | @@ -174,6 +175,11 @@ pub fn resolveStructLayout(sema: *Sema, struct_ty: Type) CompileError!void { |
| 174 | const gpa = comp.gpa; | 175 | const gpa = comp.gpa; |
| 175 | const ip = &zcu.intern_pool; | 176 | const ip = &zcu.intern_pool; |
| 176 | 177 | ||
| 178 | const tracy = trace(@src()); | ||
| 179 | defer tracy.end(); | ||
| 180 | tracy.addText(struct_ty.containerTypeName(ip).toSlice(ip)); | ||
| 181 | tracy.addTextFmt("ip_index={d}", .{struct_ty.toIntern()}); | ||
| 182 | |||
| 177 | assert(sema.owner.unwrap().type_layout == struct_ty.toIntern()); | 183 | assert(sema.owner.unwrap().type_layout == struct_ty.toIntern()); |
| 178 | 184 | ||
| 179 | const struct_obj = ip.loadStructType(struct_ty.toIntern()); | 185 | const struct_obj = ip.loadStructType(struct_ty.toIntern()); |
| ... | @@ -548,6 +554,11 @@ pub fn resolveStructDefaults(sema: *Sema, struct_ty: Type) CompileError!void { | ... | @@ -548,6 +554,11 @@ pub fn resolveStructDefaults(sema: *Sema, struct_ty: Type) CompileError!void { |
| 548 | const gpa = comp.gpa; | 554 | const gpa = comp.gpa; |
| 549 | const ip = &zcu.intern_pool; | 555 | const ip = &zcu.intern_pool; |
| 550 | 556 | ||
| 557 | const tracy = trace(@src()); | ||
| 558 | defer tracy.end(); | ||
| 559 | tracy.addText(struct_ty.containerTypeName(ip).toSlice(ip)); | ||
| 560 | tracy.addTextFmt("ip_index={d}", .{struct_ty.toIntern()}); | ||
| 561 | |||
| 551 | assert(sema.owner.unwrap().struct_defaults == struct_ty.toIntern()); | 562 | assert(sema.owner.unwrap().struct_defaults == struct_ty.toIntern()); |
| 552 | 563 | ||
| 553 | // We always depend on the layout of `struct_ty`. However, we don't actually need to resolve it | 564 | // We always depend on the layout of `struct_ty`. However, we don't actually need to resolve it |
| ... | @@ -655,6 +666,11 @@ pub fn resolveUnionLayout(sema: *Sema, union_ty: Type) CompileError!void { | ... | @@ -655,6 +666,11 @@ pub fn resolveUnionLayout(sema: *Sema, union_ty: Type) CompileError!void { |
| 655 | const gpa = comp.gpa; | 666 | const gpa = comp.gpa; |
| 656 | const ip = &zcu.intern_pool; | 667 | const ip = &zcu.intern_pool; |
| 657 | 668 | ||
| 669 | const tracy = trace(@src()); | ||
| 670 | defer tracy.end(); | ||
| 671 | tracy.addText(union_ty.containerTypeName(ip).toSlice(ip)); | ||
| 672 | tracy.addTextFmt("ip_index={d}", .{union_ty.toIntern()}); | ||
| 673 | |||
| 658 | assert(sema.owner.unwrap().type_layout == union_ty.toIntern()); | 674 | assert(sema.owner.unwrap().type_layout == union_ty.toIntern()); |
| 659 | 675 | ||
| 660 | const union_obj = ip.loadUnionType(union_ty.toIntern()); | 676 | const union_obj = ip.loadUnionType(union_ty.toIntern()); |
| ... | @@ -1134,6 +1150,11 @@ pub fn resolveEnumLayout(sema: *Sema, enum_ty: Type) CompileError!void { | ... | @@ -1134,6 +1150,11 @@ pub fn resolveEnumLayout(sema: *Sema, enum_ty: Type) CompileError!void { |
| 1134 | const gpa = comp.gpa; | 1150 | const gpa = comp.gpa; |
| 1135 | const ip = &zcu.intern_pool; | 1151 | const ip = &zcu.intern_pool; |
| 1136 | 1152 | ||
| 1153 | const tracy = trace(@src()); | ||
| 1154 | defer tracy.end(); | ||
| 1155 | tracy.addText(enum_ty.containerTypeName(ip).toSlice(ip)); | ||
| 1156 | tracy.addTextFmt("ip_index={d}", .{enum_ty.toIntern()}); | ||
| 1157 | |||
| 1137 | assert(sema.owner.unwrap().type_layout == enum_ty.toIntern()); | 1158 | assert(sema.owner.unwrap().type_layout == enum_ty.toIntern()); |
| 1138 | 1159 | ||
| 1139 | const enum_obj = ip.loadEnumType(enum_ty.toIntern()); | 1160 | const enum_obj = ip.loadEnumType(enum_ty.toIntern()); |
src/Zcu.zig+52-3| ... | @@ -29,7 +29,7 @@ const Package = @import("Package.zig"); | ... | @@ -29,7 +29,7 @@ const Package = @import("Package.zig"); |
| 29 | const link = @import("link.zig"); | 29 | const link = @import("link.zig"); |
| 30 | const Air = @import("Air.zig"); | 30 | const Air = @import("Air.zig"); |
| 31 | const Zir = std.zig.Zir; | 31 | const Zir = std.zig.Zir; |
| 32 | const trace = @import("tracy.zig").trace; | 32 | const tracy = @import("tracy.zig"); |
| 33 | const AstGen = std.zig.AstGen; | 33 | const AstGen = std.zig.AstGen; |
| 34 | const Sema = @import("Sema.zig"); | 34 | const Sema = @import("Sema.zig"); |
| 35 | const target_util = @import("target.zig"); | 35 | const target_util = @import("target.zig"); |
| ... | @@ -2811,6 +2811,7 @@ pub const CompileError = error{ | ... | @@ -2811,6 +2811,7 @@ pub const CompileError = error{ |
| 2811 | 2811 | ||
| 2812 | pub fn init(zcu: *Zcu, gpa: Allocator, io: Io, thread_count: usize) !void { | 2812 | pub fn init(zcu: *Zcu, gpa: Allocator, io: Io, thread_count: usize) !void { |
| 2813 | try zcu.intern_pool.init(gpa, io, thread_count); | 2813 | try zcu.intern_pool.init(gpa, io, thread_count); |
| 2814 | zcu.initTracyPlots(); | ||
| 2814 | } | 2815 | } |
| 2815 | 2816 | ||
| 2816 | pub fn deinit(zcu: *Zcu) void { | 2817 | pub fn deinit(zcu: *Zcu) void { |
| ... | @@ -3161,12 +3162,15 @@ pub fn markDependeeOutdated( | ... | @@ -3161,12 +3162,15 @@ pub fn markDependeeOutdated( |
| 3161 | try zcu.markTransitiveDependersPotentiallyOutdated(depender); | 3162 | try zcu.markTransitiveDependersPotentiallyOutdated(depender); |
| 3162 | } | 3163 | } |
| 3163 | } | 3164 | } |
| 3165 | |||
| 3166 | zcu.updateTracyOutdatedPlots(); | ||
| 3164 | } | 3167 | } |
| 3165 | 3168 | ||
| 3166 | pub fn markPoDependeeUpToDate(zcu: *Zcu, dependee: InternPool.Dependee) !void { | 3169 | pub fn markPoDependeeUpToDate(zcu: *Zcu, dependee: InternPool.Dependee) !void { |
| 3167 | if (std.debug.runtime_safety) zcu.outdated_lock.lockUncancelable(zcu.comp.io); | 3170 | if (std.debug.runtime_safety) zcu.outdated_lock.lockUncancelable(zcu.comp.io); |
| 3168 | defer if (std.debug.runtime_safety) zcu.outdated_lock.unlock(zcu.comp.io); | 3171 | defer if (std.debug.runtime_safety) zcu.outdated_lock.unlock(zcu.comp.io); |
| 3169 | return markPoDependeeUpToDateInner(zcu, dependee); | 3172 | try markPoDependeeUpToDateInner(zcu, dependee); |
| 3173 | zcu.updateTracyOutdatedPlots(); | ||
| 3170 | } | 3174 | } |
| 3171 | /// Assumes that `zcu.outdated_lock` is already held exclusively. | 3175 | /// Assumes that `zcu.outdated_lock` is already held exclusively. |
| 3172 | fn markPoDependeeUpToDateInner(zcu: *Zcu, dependee: InternPool.Dependee) !void { | 3176 | fn markPoDependeeUpToDateInner(zcu: *Zcu, dependee: InternPool.Dependee) !void { |
| ... | @@ -3304,6 +3308,7 @@ pub fn findOutdatedToAnalyze(zcu: *Zcu) Allocator.Error!?AnalUnit { | ... | @@ -3304,6 +3308,7 @@ pub fn findOutdatedToAnalyze(zcu: *Zcu) Allocator.Error!?AnalUnit { |
| 3304 | // Everything is up-to-date. There could be lingering entries in `zcu.potentially_outdated` | 3308 | // Everything is up-to-date. There could be lingering entries in `zcu.potentially_outdated` |
| 3305 | // from a dependency loop on a previous update. | 3309 | // from a dependency loop on a previous update. |
| 3306 | zcu.potentially_outdated.clearRetainingCapacity(); | 3310 | zcu.potentially_outdated.clearRetainingCapacity(); |
| 3311 | zcu.updateTracyOutdatedPlots(); | ||
| 3307 | log.debug("findOutdatedToAnalyze: all up-to-date", .{}); | 3312 | log.debug("findOutdatedToAnalyze: all up-to-date", .{}); |
| 3308 | return null; | 3313 | return null; |
| 3309 | } | 3314 | } |
| ... | @@ -3337,6 +3342,7 @@ pub fn flushRetryableFailures(zcu: *Zcu) !void { | ... | @@ -3337,6 +3342,7 @@ pub fn flushRetryableFailures(zcu: *Zcu) !void { |
| 3337 | try zcu.markTransitiveDependersPotentiallyOutdated(depender); | 3342 | try zcu.markTransitiveDependersPotentiallyOutdated(depender); |
| 3338 | } | 3343 | } |
| 3339 | zcu.retryable_failures.clearRetainingCapacity(); | 3344 | zcu.retryable_failures.clearRetainingCapacity(); |
| 3345 | zcu.updateTracyOutdatedPlots(); | ||
| 3340 | } | 3346 | } |
| 3341 | 3347 | ||
| 3342 | pub fn mapOldZirToNew( | 3348 | pub fn mapOldZirToNew( |
| ... | @@ -3580,6 +3586,7 @@ pub fn ensureFuncBodyAnalysisQueued(zcu: *Zcu, func: InternPool.Index) !void { | ... | @@ -3580,6 +3586,7 @@ pub fn ensureFuncBodyAnalysisQueued(zcu: *Zcu, func: InternPool.Index) !void { |
| 3580 | try zcu.outdated_ready.funcs.ensureUnusedCapacity(gpa, 1); | 3586 | try zcu.outdated_ready.funcs.ensureUnusedCapacity(gpa, 1); |
| 3581 | zcu.outdated.putAssumeCapacityNoClobber(.wrap(.{ .func = func }), 0); | 3587 | zcu.outdated.putAssumeCapacityNoClobber(.wrap(.{ .func = func }), 0); |
| 3582 | zcu.outdated_ready.funcs.putAssumeCapacityNoClobber(func, {}); | 3588 | zcu.outdated_ready.funcs.putAssumeCapacityNoClobber(func, {}); |
| 3589 | zcu.updateTracyOutdatedPlots(); | ||
| 3583 | } | 3590 | } |
| 3584 | } | 3591 | } |
| 3585 | 3592 | ||
| ... | @@ -3598,6 +3605,7 @@ pub fn ensureNavValAnalysisQueued(zcu: *Zcu, nav: InternPool.Nav.Index) !void { | ... | @@ -3598,6 +3605,7 @@ pub fn ensureNavValAnalysisQueued(zcu: *Zcu, nav: InternPool.Nav.Index) !void { |
| 3598 | zcu.outdated.putAssumeCapacityNoClobber(.wrap(.{ .nav_ty = nav }), 0); | 3605 | zcu.outdated.putAssumeCapacityNoClobber(.wrap(.{ .nav_ty = nav }), 0); |
| 3599 | zcu.outdated_ready.other.putAssumeCapacityNoClobber(.wrap(.{ .nav_val = nav }), {}); | 3606 | zcu.outdated_ready.other.putAssumeCapacityNoClobber(.wrap(.{ .nav_val = nav }), {}); |
| 3600 | zcu.outdated_ready.other.putAssumeCapacityNoClobber(.wrap(.{ .nav_ty = nav }), {}); | 3607 | zcu.outdated_ready.other.putAssumeCapacityNoClobber(.wrap(.{ .nav_ty = nav }), {}); |
| 3608 | zcu.updateTracyOutdatedPlots(); | ||
| 3601 | } | 3609 | } |
| 3602 | } | 3610 | } |
| 3603 | 3611 | ||
| ... | @@ -3614,6 +3622,7 @@ pub fn queueComptimeUnitAnalysis(zcu: *Zcu, cu: InternPool.ComptimeUnit.Id) Allo | ... | @@ -3614,6 +3622,7 @@ pub fn queueComptimeUnitAnalysis(zcu: *Zcu, cu: InternPool.ComptimeUnit.Id) Allo |
| 3614 | try zcu.outdated_ready.other.ensureUnusedCapacity(gpa, 1); | 3622 | try zcu.outdated_ready.other.ensureUnusedCapacity(gpa, 1); |
| 3615 | zcu.outdated.putAssumeCapacityNoClobber(unit, 0); | 3623 | zcu.outdated.putAssumeCapacityNoClobber(unit, 0); |
| 3616 | zcu.outdated_ready.other.putAssumeCapacityNoClobber(unit, {}); | 3624 | zcu.outdated_ready.other.putAssumeCapacityNoClobber(unit, {}); |
| 3625 | zcu.updateTracyOutdatedPlots(); | ||
| 3617 | } | 3626 | } |
| 3618 | 3627 | ||
| 3619 | /// If `unit` was marked as outdated or porentially outdated, clears that status and returns `true`. | 3628 | /// If `unit` was marked as outdated or porentially outdated, clears that status and returns `true`. |
| ... | @@ -3632,8 +3641,10 @@ pub fn clearOutdatedState(zcu: *Zcu, unit: AnalUnit) bool { | ... | @@ -3632,8 +3641,10 @@ pub fn clearOutdatedState(zcu: *Zcu, unit: AnalUnit) bool { |
| 3632 | } else { | 3641 | } else { |
| 3633 | assert(!was_ready); | 3642 | assert(!was_ready); |
| 3634 | } | 3643 | } |
| 3644 | zcu.updateTracyOutdatedPlots(); | ||
| 3635 | return true; | 3645 | return true; |
| 3636 | } else if (zcu.potentially_outdated.swapRemove(unit)) { | 3646 | } else if (zcu.potentially_outdated.swapRemove(unit)) { |
| 3647 | zcu.updateTracyOutdatedPlots(); | ||
| 3637 | return true; | 3648 | return true; |
| 3638 | } else { | 3649 | } else { |
| 3639 | return false; | 3650 | return false; |
| ... | @@ -4164,6 +4175,9 @@ pub fn resolveReferences(zcu: *Zcu) Allocator.Error!*const std.AutoArrayHashMapU | ... | @@ -4164,6 +4175,9 @@ pub fn resolveReferences(zcu: *Zcu) Allocator.Error!*const std.AutoArrayHashMapU |
| 4164 | return &zcu.resolved_references.?; | 4175 | return &zcu.resolved_references.?; |
| 4165 | } | 4176 | } |
| 4166 | fn resolveReferencesInner(zcu: *Zcu) Allocator.Error!std.AutoArrayHashMapUnmanaged(AnalUnit, ?ResolvedReference) { | 4177 | fn resolveReferencesInner(zcu: *Zcu) Allocator.Error!std.AutoArrayHashMapUnmanaged(AnalUnit, ?ResolvedReference) { |
| 4178 | const trace = tracy.trace(@src()); | ||
| 4179 | defer trace.end(); | ||
| 4180 | |||
| 4167 | const gpa = zcu.gpa; | 4181 | const gpa = zcu.gpa; |
| 4168 | const comp = zcu.comp; | 4182 | const comp = zcu.comp; |
| 4169 | const ip = &zcu.intern_pool; | 4183 | const ip = &zcu.intern_pool; |
| ... | @@ -5265,6 +5279,7 @@ pub const CodegenTaskPool = struct { | ... | @@ -5265,6 +5279,7 @@ pub const CodegenTaskPool = struct { |
| 5265 | mir.deinit(zcu); | 5279 | mir.deinit(zcu); |
| 5266 | } | 5280 | } |
| 5267 | assert(pool.available_air_bytes == max_air_bytes_in_flight); | 5281 | assert(pool.available_air_bytes == max_air_bytes_in_flight); |
| 5282 | zcu.updateTracyPlot("air_bytes_in_flight", 0); | ||
| 5268 | } | 5283 | } |
| 5269 | 5284 | ||
| 5270 | pub fn start( | 5285 | pub fn start( |
| ... | @@ -5298,6 +5313,12 @@ pub const CodegenTaskPool = struct { | ... | @@ -5298,6 +5313,12 @@ pub const CodegenTaskPool = struct { |
| 5298 | } | 5313 | } |
| 5299 | 5314 | ||
| 5300 | pool.available_air_bytes -= effective_air_bytes; | 5315 | pool.available_air_bytes -= effective_air_bytes; |
| 5316 | |||
| 5317 | zcu.updateTracyPlot("air_bytes_in_flight", @max( | ||
| 5318 | max_air_bytes_in_flight - pool.available_air_bytes, | ||
| 5319 | actual_air_bytes, | ||
| 5320 | )); | ||
| 5321 | |||
| 5301 | break :index pool.free.pop().?; | 5322 | break :index pool.free.pop().?; |
| 5302 | }; | 5323 | }; |
| 5303 | 5324 | ||
| ... | @@ -5326,8 +5347,9 @@ pub const CodegenTaskPool = struct { | ... | @@ -5326,8 +5347,9 @@ pub const CodegenTaskPool = struct { |
| 5326 | pub fn wait( | 5347 | pub fn wait( |
| 5327 | index: Index, | 5348 | index: Index, |
| 5328 | pool: *CodegenTaskPool, | 5349 | pool: *CodegenTaskPool, |
| 5329 | io: Io, | 5350 | zcu: *const Zcu, |
| 5330 | ) PerThread.RunCodegenError!struct { InternPool.Index, codegen.AnyMir } { | 5351 | ) PerThread.RunCodegenError!struct { InternPool.Index, codegen.AnyMir } { |
| 5352 | const io = zcu.comp.io; | ||
| 5331 | const func = pool.task_funcs[@intFromEnum(index)]; | 5353 | const func = pool.task_funcs[@intFromEnum(index)]; |
| 5332 | assert(func != .none); | 5354 | assert(func != .none); |
| 5333 | const effective_air_bytes = pool.task_air_bytes[@intFromEnum(index)]; | 5355 | const effective_air_bytes = pool.task_air_bytes[@intFromEnum(index)]; |
| ... | @@ -5343,6 +5365,7 @@ pub const CodegenTaskPool = struct { | ... | @@ -5343,6 +5365,7 @@ pub const CodegenTaskPool = struct { |
| 5343 | pool.available_air_bytes += effective_air_bytes; | 5365 | pool.available_air_bytes += effective_air_bytes; |
| 5344 | pool.free.appendAssumeCapacity(index); | 5366 | pool.free.appendAssumeCapacity(index); |
| 5345 | pool.free_cond.signal(io); | 5367 | pool.free_cond.signal(io); |
| 5368 | zcu.updateTracyPlot("air_bytes_in_flight", max_air_bytes_in_flight - pool.available_air_bytes); | ||
| 5346 | } | 5369 | } |
| 5347 | 5370 | ||
| 5348 | return .{ func, try result }; | 5371 | return .{ func, try result }; |
| ... | @@ -5376,3 +5399,29 @@ pub const CodegenTaskPool = struct { | ... | @@ -5376,3 +5399,29 @@ pub const CodegenTaskPool = struct { |
| 5376 | return pt.runCodegen(func_index, air); | 5399 | return pt.runCodegen(func_index, air); |
| 5377 | } | 5400 | } |
| 5378 | }; | 5401 | }; |
| 5402 | |||
| 5403 | fn initTracyPlots(zcu: *const Zcu) void { | ||
| 5404 | if (zcu.comp.skip_linker_dependencies) return; | ||
| 5405 | |||
| 5406 | tracy.plotConfig("air_bytes_in_flight", .{ .format = .memory, .mode = .step }); | ||
| 5407 | |||
| 5408 | tracy.plotConfig("outdated + potentially_outdated", .{ .format = .number, .mode = .step, .color = 0xFFFF00 }); | ||
| 5409 | tracy.plotConfig("outdated", .{ .format = .number, .mode = .step, .color = 0xFF0000 }); | ||
| 5410 | tracy.plotConfig("potentially_outdated", .{ .format = .number, .mode = .step, .color = 0xFF7700 }); | ||
| 5411 | tracy.plotConfig("outdated_ready", .{ .format = .number, .mode = .step, .color = 0x00FF00 }); | ||
| 5412 | } | ||
| 5413 | |||
| 5414 | /// Marked `inline` to prevent binary bloat from trivial generic instances, and to ensure there is | ||
| 5415 | /// minimal overhead to this call when Tracy is disabled, even in Debug builds. | ||
| 5416 | inline fn updateTracyPlot(zcu: *const Zcu, comptime name: [*:0]const u8, val: u64) void { | ||
| 5417 | if (zcu.comp.skip_linker_dependencies) return; | ||
| 5418 | tracy.plotInt(name, @intCast(val)); | ||
| 5419 | } | ||
| 5420 | |||
| 5421 | /// Assumes that `zcu.outdated_lock` is already held. | ||
| 5422 | fn updateTracyOutdatedPlots(zcu: *const Zcu) void { | ||
| 5423 | zcu.updateTracyPlot("outdated + potentially_outdated", zcu.outdated.count() + zcu.potentially_outdated.count()); | ||
| 5424 | zcu.updateTracyPlot("outdated", zcu.outdated.count()); | ||
| 5425 | zcu.updateTracyPlot("potentially_outdated", zcu.potentially_outdated.count()); | ||
| 5426 | zcu.updateTracyPlot("outdated_ready", zcu.outdated_ready.funcs.count() + zcu.outdated_ready.other.count()); | ||
| 5427 | } |
src/Zcu/PerThread.zig+52-36| ... | @@ -313,18 +313,22 @@ pub fn update( | ... | @@ -313,18 +313,22 @@ pub fn update( |
| 313 | // `comptime` declarations, any declarations marked `export`, and `test` declarations in the | 313 | // `comptime` declarations, any declarations marked `export`, and `test` declarations in the |
| 314 | // main module if this is a test compilation---become referenced, and so will be picked up | 314 | // main module if this is a test compilation---become referenced, and so will be picked up |
| 315 | // up by the main semantic analysis loop below. | 315 | // up by the main semantic analysis loop below. |
| 316 | for (zcu.analysisRoots()) |analysis_root_mod| { | 316 | { |
| 317 | const analysis_root_file = zcu.module_roots.get(analysis_root_mod).?.unwrap().?; | 317 | const tracy_trace = traceNamed(@src(), "populate_sema_roots"); |
| 318 | try pt.ensureFilePopulated(analysis_root_file); | 318 | defer tracy_trace.end(); |
| 319 | for (zcu.analysisRoots()) |analysis_root_mod| { | ||
| 320 | const analysis_root_file = zcu.module_roots.get(analysis_root_mod).?.unwrap().?; | ||
| 321 | try pt.ensureFilePopulated(analysis_root_file); | ||
| 322 | } | ||
| 319 | } | 323 | } |
| 320 | 324 | ||
| 325 | const tracy_trace = traceNamed(@src(), "sema_loop"); | ||
| 326 | defer tracy_trace.end(); | ||
| 327 | |||
| 321 | // This is the main semantic analysis loop, which is essentially the main loop of the whole | 328 | // This is the main semantic analysis loop, which is essentially the main loop of the whole |
| 322 | // Zig compilation pipeline. It selects some `AnalUnit` which we know needs to be analyzed, | 329 | // Zig compilation pipeline. It selects some `AnalUnit` which we know needs to be analyzed, |
| 323 | // and analyzes it, which may in turn discover more `AnalUnit`s which we need to analyze. | 330 | // and analyzes it, which may in turn discover more `AnalUnit`s which we need to analyze. |
| 324 | while (try zcu.findOutdatedToAnalyze()) |unit| { | 331 | while (try zcu.findOutdatedToAnalyze()) |unit| { |
| 325 | const tracy_trace = traceNamed(@src(), "analyze_outdated"); | ||
| 326 | defer tracy_trace.end(); | ||
| 327 | |||
| 328 | const maybe_err: Zcu.SemaError!void = switch (unit.unwrap()) { | 332 | const maybe_err: Zcu.SemaError!void = switch (unit.unwrap()) { |
| 329 | .@"comptime" => |cu| pt.ensureComptimeUnitUpToDate(cu), | 333 | .@"comptime" => |cu| pt.ensureComptimeUnitUpToDate(cu), |
| 330 | .nav_ty => |nav| pt.ensureNavTypeUpToDate(nav, null), | 334 | .nav_ty => |nav| pt.ensureNavTypeUpToDate(nav, null), |
| ... | @@ -823,6 +827,9 @@ fn updateZirRefs(pt: Zcu.PerThread) (Io.Cancelable || Allocator.Error)!void { | ... | @@ -823,6 +827,9 @@ fn updateZirRefs(pt: Zcu.PerThread) (Io.Cancelable || Allocator.Error)!void { |
| 823 | const gpa = comp.gpa; | 827 | const gpa = comp.gpa; |
| 824 | const io = comp.io; | 828 | const io = comp.io; |
| 825 | 829 | ||
| 830 | const tracy_trace = trace(@src()); | ||
| 831 | defer tracy_trace.end(); | ||
| 832 | |||
| 826 | // We need to visit every updated File for every TrackedInst in InternPool. | 833 | // We need to visit every updated File for every TrackedInst in InternPool. |
| 827 | // This only includes Zig files; ZON files are omitted. | 834 | // This only includes Zig files; ZON files are omitted. |
| 828 | var updated_files: std.AutoArrayHashMapUnmanaged(Zcu.File.Index, UpdatedFile) = .empty; | 835 | var updated_files: std.AutoArrayHashMapUnmanaged(Zcu.File.Index, UpdatedFile) = .empty; |
| ... | @@ -1008,9 +1015,6 @@ fn updateZirRefs(pt: Zcu.PerThread) (Io.Cancelable || Allocator.Error)!void { | ... | @@ -1008,9 +1015,6 @@ fn updateZirRefs(pt: Zcu.PerThread) (Io.Cancelable || Allocator.Error)!void { |
| 1008 | pub fn ensureFilePopulated(pt: Zcu.PerThread, file_index: Zcu.File.Index) (Allocator.Error || Io.Cancelable)!void { | 1015 | pub fn ensureFilePopulated(pt: Zcu.PerThread, file_index: Zcu.File.Index) (Allocator.Error || Io.Cancelable)!void { |
| 1009 | dev.check(.sema); | 1016 | dev.check(.sema); |
| 1010 | 1017 | ||
| 1011 | const tracy_trace = trace(@src()); | ||
| 1012 | defer tracy_trace.end(); | ||
| 1013 | |||
| 1014 | const zcu = pt.zcu; | 1018 | const zcu = pt.zcu; |
| 1015 | const comp = zcu.comp; | 1019 | const comp = zcu.comp; |
| 1016 | const io = comp.io; | 1020 | const io = comp.io; |
| ... | @@ -1019,6 +1023,9 @@ pub fn ensureFilePopulated(pt: Zcu.PerThread, file_index: Zcu.File.Index) (Alloc | ... | @@ -1019,6 +1023,9 @@ pub fn ensureFilePopulated(pt: Zcu.PerThread, file_index: Zcu.File.Index) (Alloc |
| 1019 | 1023 | ||
| 1020 | if (zcu.fileRootType(file_index) != .none) return; // already good | 1024 | if (zcu.fileRootType(file_index) != .none) return; // already good |
| 1021 | 1025 | ||
| 1026 | const tracy_trace = traceNamed(@src(), "create_file_struct"); | ||
| 1027 | defer tracy_trace.end(); | ||
| 1028 | |||
| 1022 | if (zcu.comp.time_report) |*tr| tr.stats.n_imported_files += 1; | 1029 | if (zcu.comp.time_report) |*tr| tr.stats.n_imported_files += 1; |
| 1023 | 1030 | ||
| 1024 | const file = zcu.fileByIndex(file_index); | 1031 | const file = zcu.fileByIndex(file_index); |
| ... | @@ -1065,9 +1072,6 @@ pub fn ensureMemoizedStateUpToDate( | ... | @@ -1065,9 +1072,6 @@ pub fn ensureMemoizedStateUpToDate( |
| 1065 | /// `null` is valid only for the "root" analysis, i.e. called from `Compilation.processOneJob`. | 1072 | /// `null` is valid only for the "root" analysis, i.e. called from `Compilation.processOneJob`. |
| 1066 | reason: ?*const Zcu.DependencyReason, | 1073 | reason: ?*const Zcu.DependencyReason, |
| 1067 | ) Zcu.SemaError!void { | 1074 | ) Zcu.SemaError!void { |
| 1068 | const tracy_trace = trace(@src()); | ||
| 1069 | defer tracy_trace.end(); | ||
| 1070 | |||
| 1071 | const zcu = pt.zcu; | 1075 | const zcu = pt.zcu; |
| 1072 | const gpa = zcu.gpa; | 1076 | const gpa = zcu.gpa; |
| 1073 | 1077 | ||
| ... | @@ -1142,6 +1146,10 @@ fn analyzeMemoizedState( | ... | @@ -1142,6 +1146,10 @@ fn analyzeMemoizedState( |
| 1142 | 1146 | ||
| 1143 | log.debug("analyzeMemoizedState({t})", .{stage}); | 1147 | log.debug("analyzeMemoizedState({t})", .{stage}); |
| 1144 | 1148 | ||
| 1149 | const tracy_trace = trace(@src()); | ||
| 1150 | defer tracy_trace.end(); | ||
| 1151 | tracy_trace.addText(@tagName(stage)); | ||
| 1152 | |||
| 1145 | const unit: AnalUnit = .wrap(.{ .memoized_state = stage }); | 1153 | const unit: AnalUnit = .wrap(.{ .memoized_state = stage }); |
| 1146 | 1154 | ||
| 1147 | try zcu.analysis_in_progress.putNoClobber(gpa, unit, reason); | 1155 | try zcu.analysis_in_progress.putNoClobber(gpa, unit, reason); |
| ... | @@ -1174,9 +1182,6 @@ fn analyzeMemoizedState( | ... | @@ -1174,9 +1182,6 @@ fn analyzeMemoizedState( |
| 1174 | /// if necessary. Returns `error.AnalysisFail` if an analysis error is encountered; the caller is | 1182 | /// if necessary. Returns `error.AnalysisFail` if an analysis error is encountered; the caller is |
| 1175 | /// free to ignore this, since the error is already registered. | 1183 | /// free to ignore this, since the error is already registered. |
| 1176 | pub fn ensureComptimeUnitUpToDate(pt: Zcu.PerThread, cu_id: InternPool.ComptimeUnit.Id) Zcu.SemaError!void { | 1184 | pub fn ensureComptimeUnitUpToDate(pt: Zcu.PerThread, cu_id: InternPool.ComptimeUnit.Id) Zcu.SemaError!void { |
| 1177 | const tracy_trace = trace(@src()); | ||
| 1178 | defer tracy_trace.end(); | ||
| 1179 | |||
| 1180 | const zcu = pt.zcu; | 1185 | const zcu = pt.zcu; |
| 1181 | const gpa = zcu.gpa; | 1186 | const gpa = zcu.gpa; |
| 1182 | 1187 | ||
| ... | @@ -1257,6 +1262,10 @@ fn analyzeComptimeUnit(pt: Zcu.PerThread, cu_id: InternPool.ComptimeUnit.Id) Zcu | ... | @@ -1257,6 +1262,10 @@ fn analyzeComptimeUnit(pt: Zcu.PerThread, cu_id: InternPool.ComptimeUnit.Id) Zcu |
| 1257 | 1262 | ||
| 1258 | log.debug("analyzeComptimeUnit {f}", .{zcu.fmtAnalUnit(anal_unit)}); | 1263 | log.debug("analyzeComptimeUnit {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 1259 | 1264 | ||
| 1265 | const tracy_trace = trace(@src()); | ||
| 1266 | defer tracy_trace.end(); | ||
| 1267 | tracy_trace.addTextFmt("cu_id={d}", .{cu_id}); | ||
| 1268 | |||
| 1260 | const inst_resolved = comptime_unit.zir_index.resolveFull(ip) orelse return error.AnalysisFail; | 1269 | const inst_resolved = comptime_unit.zir_index.resolveFull(ip) orelse return error.AnalysisFail; |
| 1261 | const file = zcu.fileByIndex(inst_resolved.file); | 1270 | const file = zcu.fileByIndex(inst_resolved.file); |
| 1262 | const zir = file.zir.?; | 1271 | const zir = file.zir.?; |
| ... | @@ -1333,9 +1342,6 @@ pub fn ensureTypeLayoutUpToDate( | ... | @@ -1333,9 +1342,6 @@ pub fn ensureTypeLayoutUpToDate( |
| 1333 | /// `null` is valid only for the "root" analysis, i.e. called from `Compilation.processOneJob`. | 1342 | /// `null` is valid only for the "root" analysis, i.e. called from `Compilation.processOneJob`. |
| 1334 | reason: ?*const Zcu.DependencyReason, | 1343 | reason: ?*const Zcu.DependencyReason, |
| 1335 | ) Zcu.SemaError!void { | 1344 | ) Zcu.SemaError!void { |
| 1336 | const tracy_trace = trace(@src()); | ||
| 1337 | defer tracy_trace.end(); | ||
| 1338 | |||
| 1339 | const zcu = pt.zcu; | 1345 | const zcu = pt.zcu; |
| 1340 | const ip = &zcu.intern_pool; | 1346 | const ip = &zcu.intern_pool; |
| 1341 | const comp = zcu.comp; | 1347 | const comp = zcu.comp; |
| ... | @@ -1464,9 +1470,6 @@ pub fn ensureStructDefaultsUpToDate( | ... | @@ -1464,9 +1470,6 @@ pub fn ensureStructDefaultsUpToDate( |
| 1464 | /// `null` is valid only for the "root" analysis, i.e. called from `Compilation.processOneJob`. | 1470 | /// `null` is valid only for the "root" analysis, i.e. called from `Compilation.processOneJob`. |
| 1465 | reason: ?*const Zcu.DependencyReason, | 1471 | reason: ?*const Zcu.DependencyReason, |
| 1466 | ) Zcu.SemaError!void { | 1472 | ) Zcu.SemaError!void { |
| 1467 | const tracy_trace = trace(@src()); | ||
| 1468 | defer tracy_trace.end(); | ||
| 1469 | |||
| 1470 | const zcu = pt.zcu; | 1473 | const zcu = pt.zcu; |
| 1471 | const ip = &zcu.intern_pool; | 1474 | const ip = &zcu.intern_pool; |
| 1472 | const comp = zcu.comp; | 1475 | const comp = zcu.comp; |
| ... | @@ -1572,9 +1575,6 @@ pub fn ensureNavValUpToDate( | ... | @@ -1572,9 +1575,6 @@ pub fn ensureNavValUpToDate( |
| 1572 | /// `null` is valid only for the "root" analysis, i.e. called from `Compilation.processOneJob`. | 1575 | /// `null` is valid only for the "root" analysis, i.e. called from `Compilation.processOneJob`. |
| 1573 | reason: ?*const Zcu.DependencyReason, | 1576 | reason: ?*const Zcu.DependencyReason, |
| 1574 | ) Zcu.SemaError!void { | 1577 | ) Zcu.SemaError!void { |
| 1575 | const tracy_trace = trace(@src()); | ||
| 1576 | defer tracy_trace.end(); | ||
| 1577 | |||
| 1578 | const zcu = pt.zcu; | 1578 | const zcu = pt.zcu; |
| 1579 | const gpa = zcu.gpa; | 1579 | const gpa = zcu.gpa; |
| 1580 | const ip = &zcu.intern_pool; | 1580 | const ip = &zcu.intern_pool; |
| ... | @@ -1677,6 +1677,11 @@ fn analyzeNavVal( | ... | @@ -1677,6 +1677,11 @@ fn analyzeNavVal( |
| 1677 | 1677 | ||
| 1678 | log.debug("analyzeNavVal {f}", .{zcu.fmtAnalUnit(anal_unit)}); | 1678 | log.debug("analyzeNavVal {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 1679 | 1679 | ||
| 1680 | const tracy_trace = trace(@src()); | ||
| 1681 | defer tracy_trace.end(); | ||
| 1682 | tracy_trace.addText(old_nav.fqn.toSlice(ip)); | ||
| 1683 | tracy_trace.addTextFmt("nav_id={d}", .{nav_id}); | ||
| 1684 | |||
| 1680 | const inst_resolved = old_nav.analysis.?.zir_index.resolveFull(ip) orelse return error.AnalysisFail; | 1685 | const inst_resolved = old_nav.analysis.?.zir_index.resolveFull(ip) orelse return error.AnalysisFail; |
| 1681 | const file = zcu.fileByIndex(inst_resolved.file); | 1686 | const file = zcu.fileByIndex(inst_resolved.file); |
| 1682 | const zir = file.zir.?; | 1687 | const zir = file.zir.?; |
| ... | @@ -1939,9 +1944,6 @@ pub fn ensureNavTypeUpToDate( | ... | @@ -1939,9 +1944,6 @@ pub fn ensureNavTypeUpToDate( |
| 1939 | /// `null` is valid only for the "root" analysis, i.e. called from `Compilation.processOneJob`. | 1944 | /// `null` is valid only for the "root" analysis, i.e. called from `Compilation.processOneJob`. |
| 1940 | reason: ?*const Zcu.DependencyReason, | 1945 | reason: ?*const Zcu.DependencyReason, |
| 1941 | ) Zcu.SemaError!void { | 1946 | ) Zcu.SemaError!void { |
| 1942 | const tracy_trace = trace(@src()); | ||
| 1943 | defer tracy_trace.end(); | ||
| 1944 | |||
| 1945 | const zcu = pt.zcu; | 1947 | const zcu = pt.zcu; |
| 1946 | const gpa = zcu.gpa; | 1948 | const gpa = zcu.gpa; |
| 1947 | const ip = &zcu.intern_pool; | 1949 | const ip = &zcu.intern_pool; |
| ... | @@ -2044,6 +2046,11 @@ fn analyzeNavType( | ... | @@ -2044,6 +2046,11 @@ fn analyzeNavType( |
| 2044 | 2046 | ||
| 2045 | log.debug("analyzeNavType {f}", .{zcu.fmtAnalUnit(anal_unit)}); | 2047 | log.debug("analyzeNavType {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 2046 | 2048 | ||
| 2049 | const tracy_trace = trace(@src()); | ||
| 2050 | defer tracy_trace.end(); | ||
| 2051 | tracy_trace.addText(old_nav.fqn.toSlice(ip)); | ||
| 2052 | tracy_trace.addTextFmt("nav_id={d}", .{nav_id}); | ||
| 2053 | |||
| 2047 | const inst_resolved = old_nav.analysis.?.zir_index.resolveFull(ip) orelse return error.AnalysisFail; | 2054 | const inst_resolved = old_nav.analysis.?.zir_index.resolveFull(ip) orelse return error.AnalysisFail; |
| 2048 | const file = zcu.fileByIndex(inst_resolved.file); | 2055 | const file = zcu.fileByIndex(inst_resolved.file); |
| 2049 | const zir = file.zir.?; | 2056 | const zir = file.zir.?; |
| ... | @@ -2183,9 +2190,6 @@ pub fn ensureFuncBodyUpToDate( | ... | @@ -2183,9 +2190,6 @@ pub fn ensureFuncBodyUpToDate( |
| 2183 | ) Zcu.SemaError!void { | 2190 | ) Zcu.SemaError!void { |
| 2184 | dev.check(.sema); | 2191 | dev.check(.sema); |
| 2185 | 2192 | ||
| 2186 | const tracy_trace = trace(@src()); | ||
| 2187 | defer tracy_trace.end(); | ||
| 2188 | |||
| 2189 | const zcu = pt.zcu; | 2193 | const zcu = pt.zcu; |
| 2190 | const gpa = zcu.gpa; | 2194 | const gpa = zcu.gpa; |
| 2191 | const ip = &zcu.intern_pool; | 2195 | const ip = &zcu.intern_pool; |
| ... | @@ -2283,6 +2287,11 @@ fn analyzeFuncBody( | ... | @@ -2283,6 +2287,11 @@ fn analyzeFuncBody( |
| 2283 | 2287 | ||
| 2284 | log.debug("analyzeFuncBody {f}", .{zcu.fmtAnalUnit(anal_unit)}); | 2288 | log.debug("analyzeFuncBody {f}", .{zcu.fmtAnalUnit(anal_unit)}); |
| 2285 | 2289 | ||
| 2290 | const tracy_trace = trace(@src()); | ||
| 2291 | defer tracy_trace.end(); | ||
| 2292 | tracy_trace.addText(ip.getNav(func.owner_nav).fqn.toSlice(ip)); | ||
| 2293 | tracy_trace.addTextFmt("func_ip_index={d}", .{func_index}); | ||
| 2294 | |||
| 2286 | var air = try pt.analyzeFuncBodyInner(func_index, reason); | 2295 | var air = try pt.analyzeFuncBodyInner(func_index, reason); |
| 2287 | var air_owned = true; | 2296 | var air_owned = true; |
| 2288 | defer if (air_owned) air.deinit(gpa); | 2297 | defer if (air_owned) air.deinit(gpa); |
| ... | @@ -2592,6 +2601,9 @@ fn computeAliveFiles(pt: Zcu.PerThread) Allocator.Error!bool { | ... | @@ -2592,6 +2601,9 @@ fn computeAliveFiles(pt: Zcu.PerThread) Allocator.Error!bool { |
| 2592 | const comp = zcu.comp; | 2601 | const comp = zcu.comp; |
| 2593 | const gpa = zcu.gpa; | 2602 | const gpa = zcu.gpa; |
| 2594 | 2603 | ||
| 2604 | const tracy_trace = trace(@src()); | ||
| 2605 | defer tracy_trace.end(); | ||
| 2606 | |||
| 2595 | var any_fatal_files = false; | 2607 | var any_fatal_files = false; |
| 2596 | zcu.multi_module_err = null; | 2608 | zcu.multi_module_err = null; |
| 2597 | zcu.failed_imports.clearRetainingCapacity(); | 2609 | zcu.failed_imports.clearRetainingCapacity(); |
| ... | @@ -3028,14 +3040,16 @@ pub fn scanNamespace( | ... | @@ -3028,14 +3040,16 @@ pub fn scanNamespace( |
| 3028 | namespace_index: Zcu.Namespace.Index, | 3040 | namespace_index: Zcu.Namespace.Index, |
| 3029 | decls: []const Zir.Inst.Index, | 3041 | decls: []const Zir.Inst.Index, |
| 3030 | ) Allocator.Error!void { | 3042 | ) Allocator.Error!void { |
| 3031 | const tracy_trace = trace(@src()); | ||
| 3032 | defer tracy_trace.end(); | ||
| 3033 | |||
| 3034 | const zcu = pt.zcu; | 3043 | const zcu = pt.zcu; |
| 3035 | const ip = &zcu.intern_pool; | 3044 | const ip = &zcu.intern_pool; |
| 3036 | const gpa = zcu.gpa; | 3045 | const gpa = zcu.gpa; |
| 3037 | const namespace = zcu.namespacePtr(namespace_index); | 3046 | const namespace = zcu.namespacePtr(namespace_index); |
| 3038 | 3047 | ||
| 3048 | const tracy_trace = trace(@src()); | ||
| 3049 | defer tracy_trace.end(); | ||
| 3050 | tracy_trace.addText(Type.fromInterned(namespace.owner_type).containerTypeName(ip).toSlice(ip)); | ||
| 3051 | tracy_trace.addTextFmt("type_ip_index={d}", .{namespace.owner_type}); | ||
| 3052 | |||
| 3039 | const tracked_unit = zcu.trackUnitSema( | 3053 | const tracked_unit = zcu.trackUnitSema( |
| 3040 | Type.fromInterned(namespace.owner_type).containerTypeName(ip).toSlice(ip), | 3054 | Type.fromInterned(namespace.owner_type).containerTypeName(ip).toSlice(ip), |
| 3041 | null, | 3055 | null, |
| ... | @@ -3247,9 +3261,6 @@ fn analyzeFuncBodyInner( | ... | @@ -3247,9 +3261,6 @@ fn analyzeFuncBodyInner( |
| 3247 | func_index: InternPool.Index, | 3261 | func_index: InternPool.Index, |
| 3248 | reason: ?*const Zcu.DependencyReason, | 3262 | reason: ?*const Zcu.DependencyReason, |
| 3249 | ) Zcu.SemaError!Air { | 3263 | ) Zcu.SemaError!Air { |
| 3250 | const tracy_trace = trace(@src()); | ||
| 3251 | defer tracy_trace.end(); | ||
| 3252 | |||
| 3253 | const zcu = pt.zcu; | 3264 | const zcu = pt.zcu; |
| 3254 | const comp = zcu.comp; | 3265 | const comp = zcu.comp; |
| 3255 | const gpa = comp.gpa; | 3266 | const gpa = comp.gpa; |
| ... | @@ -4556,6 +4567,11 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e | ... | @@ -4556,6 +4567,11 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e |
| 4556 | const codegen_prog_node = zcu.codegen_prog_node.start(fqn.toSlice(ip), 0); | 4567 | const codegen_prog_node = zcu.codegen_prog_node.start(fqn.toSlice(ip), 0); |
| 4557 | defer codegen_prog_node.end(); | 4568 | defer codegen_prog_node.end(); |
| 4558 | 4569 | ||
| 4570 | const tracy_trace = trace(@src()); | ||
| 4571 | defer tracy_trace.end(); | ||
| 4572 | tracy_trace.addText(fqn.toSlice(ip)); | ||
| 4573 | tracy_trace.addTextFmt("func_ip_index={d}", .{func_index}); | ||
| 4574 | |||
| 4559 | if (codegen.legalizeFeatures(pt, nav)) |features| { | 4575 | if (codegen.legalizeFeatures(pt, nav)) |features| { |
| 4560 | try air.legalize(pt, features); | 4576 | try air.legalize(pt, features); |
| 4561 | } | 4577 | } |
src/codegen.zig+7| ... | @@ -186,6 +186,12 @@ pub fn emitFunction( | ... | @@ -186,6 +186,12 @@ pub fn emitFunction( |
| 186 | const zcu = pt.zcu; | 186 | const zcu = pt.zcu; |
| 187 | const func = zcu.funcInfo(func_index); | 187 | const func = zcu.funcInfo(func_index); |
| 188 | const target = &zcu.navFileScope(func.owner_nav).mod.?.resolved_target.result; | 188 | const target = &zcu.navFileScope(func.owner_nav).mod.?.resolved_target.result; |
| 189 | |||
| 190 | const tracy_trace = trace(@src()); | ||
| 191 | defer tracy_trace.end(); | ||
| 192 | tracy_trace.addText(zcu.intern_pool.getNav(func.owner_nav).fqn.toSlice(&zcu.intern_pool)); | ||
| 193 | tracy_trace.addTextFmt("func_ip_index={d}", .{func_index}); | ||
| 194 | |||
| 189 | switch (target_util.zigBackend(target, zcu.comp.config.use_llvm)) { | 195 | switch (target_util.zigBackend(target, zcu.comp.config.use_llvm)) { |
| 190 | else => unreachable, | 196 | else => unreachable, |
| 191 | inline .stage2_aarch64, | 197 | inline .stage2_aarch64, |
| ... | @@ -236,6 +242,7 @@ pub fn generateLazySymbol( | ... | @@ -236,6 +242,7 @@ pub fn generateLazySymbol( |
| 236 | ) (CodeGenError || std.Io.Writer.Error)!void { | 242 | ) (CodeGenError || std.Io.Writer.Error)!void { |
| 237 | const tracy = trace(@src()); | 243 | const tracy = trace(@src()); |
| 238 | defer tracy.end(); | 244 | defer tracy.end(); |
| 245 | tracy.addTextFmt("{t}, {f}", .{ lazy_sym.kind, Type.fromInterned(lazy_sym.ty).fmt(pt) }); | ||
| 239 | 246 | ||
| 240 | const comp = bin_file.comp; | 247 | const comp = bin_file.comp; |
| 241 | const zcu = pt.zcu; | 248 | const zcu = pt.zcu; |
src/link.zig+71-15| ... | @@ -1205,6 +1205,7 @@ pub const File = struct { | ... | @@ -1205,6 +1205,7 @@ pub const File = struct { |
| 1205 | 1205 | ||
| 1206 | pub fn loadInput(base: *File, input: Input) anyerror!void { | 1206 | pub fn loadInput(base: *File, input: Input) anyerror!void { |
| 1207 | if (base.tag == .lld) return; | 1207 | if (base.tag == .lld) return; |
| 1208 | assert(!base.post_prelink); | ||
| 1208 | switch (base.tag) { | 1209 | switch (base.tag) { |
| 1209 | inline .elf, .elf2, .wasm => |tag| { | 1210 | inline .elf, .elf2, .wasm => |tag| { |
| 1210 | dev.check(tag.devFeature()); | 1211 | dev.check(tag.devFeature()); |
| ... | @@ -1424,6 +1425,8 @@ pub fn doPrelinkTask(comp: *Compilation, task: PrelinkTask) void { | ... | @@ -1424,6 +1425,8 @@ pub fn doPrelinkTask(comp: *Compilation, task: PrelinkTask) void { |
| 1424 | return; | 1425 | return; |
| 1425 | }; | 1426 | }; |
| 1426 | 1427 | ||
| 1428 | assert(!base.post_prelink); | ||
| 1429 | |||
| 1427 | var timer = comp.startTimer(); | 1430 | var timer = comp.startTimer(); |
| 1428 | defer if (timer.finish(io)) |ns| { | 1431 | defer if (timer.finish(io)) |ns| { |
| 1429 | comp.mutex.lockUncancelable(io); | 1432 | comp.mutex.lockUncancelable(io); |
| ... | @@ -1573,7 +1576,7 @@ pub fn doZcuTask(comp: *Compilation, tid: Zcu.PerThread.Id, task: ZcuTask) void | ... | @@ -1573,7 +1576,7 @@ pub fn doZcuTask(comp: *Compilation, tid: Zcu.PerThread.Id, task: ZcuTask) void |
| 1573 | }, | 1576 | }, |
| 1574 | .link_func => |codegen_task| nav: { | 1577 | .link_func => |codegen_task| nav: { |
| 1575 | timer.pause(io); | 1578 | timer.pause(io); |
| 1576 | const func, var mir = codegen_task.wait(&zcu.codegen_task_pool, io) catch |err| switch (err) { | 1579 | const func, var mir = codegen_task.wait(&zcu.codegen_task_pool, zcu) catch |err| switch (err) { |
| 1577 | error.Canceled, error.AlreadyReported => { | 1580 | error.Canceled, error.AlreadyReported => { |
| 1578 | comp.link_prog_node.completeOne(); | 1581 | comp.link_prog_node.completeOne(); |
| 1579 | return; | 1582 | return; |
| ... | @@ -1850,6 +1853,9 @@ pub fn resolveInputs( | ... | @@ -1850,6 +1853,9 @@ pub fn resolveInputs( |
| 1850 | var ld_script_bytes: std.ArrayList(u8) = .empty; | 1853 | var ld_script_bytes: std.ArrayList(u8) = .empty; |
| 1851 | defer ld_script_bytes.deinit(gpa); | 1854 | defer ld_script_bytes.deinit(gpa); |
| 1852 | 1855 | ||
| 1856 | var archive_dedup: ArchiveDedupMap = .empty; | ||
| 1857 | defer archive_dedup.deinit(gpa); | ||
| 1858 | |||
| 1853 | var failed_libs: std.ArrayList(struct { | 1859 | var failed_libs: std.ArrayList(struct { |
| 1854 | name: []const u8, | 1860 | name: []const u8, |
| 1855 | strategy: UnresolvedInput.SearchStrategy, | 1861 | strategy: UnresolvedInput.SearchStrategy, |
| ... | @@ -1889,6 +1895,7 @@ pub fn resolveInputs( | ... | @@ -1889,6 +1895,7 @@ pub fn resolveInputs( |
| 1889 | resolved_inputs, | 1895 | resolved_inputs, |
| 1890 | &checked_paths, | 1896 | &checked_paths, |
| 1891 | &ld_script_bytes, | 1897 | &ld_script_bytes, |
| 1898 | &archive_dedup, | ||
| 1892 | lib_directory, | 1899 | lib_directory, |
| 1893 | name_query, | 1900 | name_query, |
| 1894 | target, | 1901 | target, |
| ... | @@ -1916,6 +1923,7 @@ pub fn resolveInputs( | ... | @@ -1916,6 +1923,7 @@ pub fn resolveInputs( |
| 1916 | resolved_inputs, | 1923 | resolved_inputs, |
| 1917 | &checked_paths, | 1924 | &checked_paths, |
| 1918 | &ld_script_bytes, | 1925 | &ld_script_bytes, |
| 1926 | &archive_dedup, | ||
| 1919 | lib_directory, | 1927 | lib_directory, |
| 1920 | name_query, | 1928 | name_query, |
| 1921 | target, | 1929 | target, |
| ... | @@ -1944,6 +1952,7 @@ pub fn resolveInputs( | ... | @@ -1944,6 +1952,7 @@ pub fn resolveInputs( |
| 1944 | resolved_inputs, | 1952 | resolved_inputs, |
| 1945 | &checked_paths, | 1953 | &checked_paths, |
| 1946 | &ld_script_bytes, | 1954 | &ld_script_bytes, |
| 1955 | &archive_dedup, | ||
| 1947 | lib_directory, | 1956 | lib_directory, |
| 1948 | name_query, | 1957 | name_query, |
| 1949 | target, | 1958 | target, |
| ... | @@ -1963,6 +1972,7 @@ pub fn resolveInputs( | ... | @@ -1963,6 +1972,7 @@ pub fn resolveInputs( |
| 1963 | resolved_inputs, | 1972 | resolved_inputs, |
| 1964 | &checked_paths, | 1973 | &checked_paths, |
| 1965 | &ld_script_bytes, | 1974 | &ld_script_bytes, |
| 1975 | &archive_dedup, | ||
| 1966 | lib_directory, | 1976 | lib_directory, |
| 1967 | name_query, | 1977 | name_query, |
| 1968 | target, | 1978 | target, |
| ... | @@ -1994,6 +2004,7 @@ pub fn resolveInputs( | ... | @@ -1994,6 +2004,7 @@ pub fn resolveInputs( |
| 1994 | unresolved_inputs, | 2004 | unresolved_inputs, |
| 1995 | resolved_inputs, | 2005 | resolved_inputs, |
| 1996 | &ld_script_bytes, | 2006 | &ld_script_bytes, |
| 2007 | &archive_dedup, | ||
| 1997 | target, | 2008 | target, |
| 1998 | .{ | 2009 | .{ |
| 1999 | .path = Path.initCwd(an.name), | 2010 | .path = Path.initCwd(an.name), |
| ... | @@ -2012,6 +2023,7 @@ pub fn resolveInputs( | ... | @@ -2012,6 +2023,7 @@ pub fn resolveInputs( |
| 2012 | unresolved_inputs, | 2023 | unresolved_inputs, |
| 2013 | resolved_inputs, | 2024 | resolved_inputs, |
| 2014 | &ld_script_bytes, | 2025 | &ld_script_bytes, |
| 2026 | &archive_dedup, | ||
| 2015 | target, | 2027 | target, |
| 2016 | .{ | 2028 | .{ |
| 2017 | .path = .{ | 2029 | .path = .{ |
| ... | @@ -2040,6 +2052,7 @@ pub fn resolveInputs( | ... | @@ -2040,6 +2052,7 @@ pub fn resolveInputs( |
| 2040 | unresolved_inputs, | 2052 | unresolved_inputs, |
| 2041 | resolved_inputs, | 2053 | resolved_inputs, |
| 2042 | &ld_script_bytes, | 2054 | &ld_script_bytes, |
| 2055 | &archive_dedup, | ||
| 2043 | target, | 2056 | target, |
| 2044 | pq, | 2057 | pq, |
| 2045 | color, | 2058 | color, |
| ... | @@ -2085,6 +2098,8 @@ fn resolveLibInput( | ... | @@ -2085,6 +2098,8 @@ fn resolveLibInput( |
| 2085 | checked_paths: *std.ArrayList(u8), | 2098 | checked_paths: *std.ArrayList(u8), |
| 2086 | /// Allocated via `gpa`. | 2099 | /// Allocated via `gpa`. |
| 2087 | ld_script_bytes: *std.ArrayList(u8), | 2100 | ld_script_bytes: *std.ArrayList(u8), |
| 2101 | /// Allocated via `gpa`. | ||
| 2102 | archive_dedup: *ArchiveDedupMap, | ||
| 2088 | lib_directory: Directory, | 2103 | lib_directory: Directory, |
| 2089 | name_query: UnresolvedInput.NameQuery, | 2104 | name_query: UnresolvedInput.NameQuery, |
| 2090 | target: *const std.Target, | 2105 | target: *const std.Target, |
| ... | @@ -2092,6 +2107,7 @@ fn resolveLibInput( | ... | @@ -2092,6 +2107,7 @@ fn resolveLibInput( |
| 2092 | color: std.zig.Color, | 2107 | color: std.zig.Color, |
| 2093 | ) Allocator.Error!ResolveLibInputResult { | 2108 | ) Allocator.Error!ResolveLibInputResult { |
| 2094 | try resolved_inputs.ensureUnusedCapacity(gpa, 1); | 2109 | try resolved_inputs.ensureUnusedCapacity(gpa, 1); |
| 2110 | try archive_dedup.ensureUnusedCapacity(gpa, 1); | ||
| 2095 | 2111 | ||
| 2096 | const lib_name = name_query.name; | 2112 | const lib_name = name_query.name; |
| 2097 | 2113 | ||
| ... | @@ -2107,7 +2123,7 @@ fn resolveLibInput( | ... | @@ -2107,7 +2123,7 @@ fn resolveLibInput( |
| 2107 | else => |e| fatal("unable to search for tbd library '{f}': {s}", .{ test_path, @errorName(e) }), | 2123 | else => |e| fatal("unable to search for tbd library '{f}': {s}", .{ test_path, @errorName(e) }), |
| 2108 | }; | 2124 | }; |
| 2109 | errdefer file.close(io); | 2125 | errdefer file.close(io); |
| 2110 | return finishResolveLibInput(resolved_inputs, test_path, file, link_mode, name_query.query); | 2126 | return finishResolveLibInput(io, resolved_inputs, archive_dedup, test_path, file, link_mode, name_query.query); |
| 2111 | } | 2127 | } |
| 2112 | 2128 | ||
| 2113 | { | 2129 | { |
| ... | @@ -2122,7 +2138,7 @@ fn resolveLibInput( | ... | @@ -2122,7 +2138,7 @@ fn resolveLibInput( |
| 2122 | }), | 2138 | }), |
| 2123 | }; | 2139 | }; |
| 2124 | try checked_paths.print(gpa, "\n {f}", .{test_path}); | 2140 | try checked_paths.print(gpa, "\n {f}", .{test_path}); |
| 2125 | switch (try resolvePathInputLib(gpa, arena, io, unresolved_inputs, resolved_inputs, ld_script_bytes, target, .{ | 2141 | switch (try resolvePathInputLib(gpa, arena, io, unresolved_inputs, resolved_inputs, ld_script_bytes, archive_dedup, target, .{ |
| 2126 | .path = test_path, | 2142 | .path = test_path, |
| 2127 | .query = name_query.query, | 2143 | .query = name_query.query, |
| 2128 | }, link_mode, color)) { | 2144 | }, link_mode, color)) { |
| ... | @@ -2146,7 +2162,7 @@ fn resolveLibInput( | ... | @@ -2146,7 +2162,7 @@ fn resolveLibInput( |
| 2146 | }), | 2162 | }), |
| 2147 | }; | 2163 | }; |
| 2148 | errdefer file.close(io); | 2164 | errdefer file.close(io); |
| 2149 | return finishResolveLibInput(resolved_inputs, test_path, file, link_mode, name_query.query); | 2165 | return finishResolveLibInput(io, resolved_inputs, archive_dedup, test_path, file, link_mode, name_query.query); |
| 2150 | } | 2166 | } |
| 2151 | 2167 | ||
| 2152 | // In the case of MinGW, the main check will be .lib but we also need to | 2168 | // In the case of MinGW, the main check will be .lib but we also need to |
| ... | @@ -2162,26 +2178,61 @@ fn resolveLibInput( | ... | @@ -2162,26 +2178,61 @@ fn resolveLibInput( |
| 2162 | else => |e| fatal("unable to search for static library '{f}': {s}", .{ test_path, @errorName(e) }), | 2178 | else => |e| fatal("unable to search for static library '{f}': {s}", .{ test_path, @errorName(e) }), |
| 2163 | }; | 2179 | }; |
| 2164 | errdefer file.close(io); | 2180 | errdefer file.close(io); |
| 2165 | return finishResolveLibInput(resolved_inputs, test_path, file, link_mode, name_query.query); | 2181 | return finishResolveLibInput(io, resolved_inputs, archive_dedup, test_path, file, link_mode, name_query.query); |
| 2166 | } | 2182 | } |
| 2167 | 2183 | ||
| 2168 | return .no_match; | 2184 | return .no_match; |
| 2169 | } | 2185 | } |
| 2170 | 2186 | ||
| 2187 | /// Deduplicates static archive link inputs based on their path. This is done for efficiency, so | ||
| 2188 | /// that linker implementations do not need to open and scan the archive just to determine that they | ||
| 2189 | /// need not extract any objects. At the time of writing, it also helps avoid "multiple definitions | ||
| 2190 | /// of symbol" errors in incomplete linker implementations. | ||
| 2191 | /// | ||
| 2192 | /// Key is index into `resolved_inputs` of an `Input.archive`. | ||
| 2193 | /// | ||
| 2194 | /// Accessed through `ArchiveDedupAdapter`. | ||
| 2195 | /// | ||
| 2196 | const ArchiveDedupMap = std.array_hash_map.Custom(u32, void, void, true); | ||
| 2197 | /// Adapter for accessing `ArchiveDedupMap` with an effective key type of `Path`. | ||
| 2198 | const ArchiveDedupAdapter = struct { | ||
| 2199 | resolved_inputs: []const Input, | ||
| 2200 | pub fn hash(ctx: ArchiveDedupAdapter, path: Path) u32 { | ||
| 2201 | _ = ctx; | ||
| 2202 | return Path.TableAdapter.hash(.{}, path); | ||
| 2203 | } | ||
| 2204 | pub fn eql(ctx: ArchiveDedupAdapter, a_path: Path, b_input_index: u32, _: usize) bool { | ||
| 2205 | const b_path = ctx.resolved_inputs[b_input_index].archive.path; | ||
| 2206 | return a_path.eql(b_path); | ||
| 2207 | } | ||
| 2208 | }; | ||
| 2209 | |||
| 2171 | fn finishResolveLibInput( | 2210 | fn finishResolveLibInput( |
| 2211 | io: Io, | ||
| 2172 | resolved_inputs: *std.ArrayList(Input), | 2212 | resolved_inputs: *std.ArrayList(Input), |
| 2213 | archive_dedup: *ArchiveDedupMap, | ||
| 2173 | path: Path, | 2214 | path: Path, |
| 2174 | file: Io.File, | 2215 | file: Io.File, |
| 2175 | link_mode: std.lang.LinkMode, | 2216 | link_mode: std.lang.LinkMode, |
| 2176 | query: UnresolvedInput.Query, | 2217 | query: UnresolvedInput.Query, |
| 2177 | ) ResolveLibInputResult { | 2218 | ) ResolveLibInputResult { |
| 2178 | switch (link_mode) { | 2219 | switch (link_mode) { |
| 2179 | .static => resolved_inputs.appendAssumeCapacity(.{ .archive = .{ | 2220 | .static => { |
| 2180 | .path = path, | 2221 | const ctx: ArchiveDedupAdapter = .{ .resolved_inputs = resolved_inputs.items }; |
| 2181 | .file = file, | 2222 | const gop = archive_dedup.getOrPutAssumeCapacityAdapted(path, ctx); |
| 2182 | .must_link = query.must_link, | 2223 | if (gop.found_existing) { |
| 2183 | .hidden = query.hidden, | 2224 | // Ignore duplicate archive input |
| 2184 | } }), | 2225 | file.close(io); |
| 2226 | return .ok; | ||
| 2227 | } | ||
| 2228 | gop.key_ptr.* = @intCast(resolved_inputs.items.len); | ||
| 2229 | resolved_inputs.appendAssumeCapacity(.{ .archive = .{ | ||
| 2230 | .path = path, | ||
| 2231 | .file = file, | ||
| 2232 | .must_link = query.must_link, | ||
| 2233 | .hidden = query.hidden, | ||
| 2234 | } }); | ||
| 2235 | }, | ||
| 2185 | .dynamic => resolved_inputs.appendAssumeCapacity(.{ .dso = .{ | 2236 | .dynamic => resolved_inputs.appendAssumeCapacity(.{ .dso = .{ |
| 2186 | .path = path, | 2237 | .path = path, |
| 2187 | .file = file, | 2238 | .file = file, |
| ... | @@ -2203,13 +2254,15 @@ fn resolvePathInput( | ... | @@ -2203,13 +2254,15 @@ fn resolvePathInput( |
| 2203 | resolved_inputs: *std.ArrayList(Input), | 2254 | resolved_inputs: *std.ArrayList(Input), |
| 2204 | /// Allocated via `gpa`. | 2255 | /// Allocated via `gpa`. |
| 2205 | ld_script_bytes: *std.ArrayList(u8), | 2256 | ld_script_bytes: *std.ArrayList(u8), |
| 2257 | /// Allocated via `gpa`. | ||
| 2258 | archive_dedup: *ArchiveDedupMap, | ||
| 2206 | target: *const std.Target, | 2259 | target: *const std.Target, |
| 2207 | pq: UnresolvedInput.PathQuery, | 2260 | pq: UnresolvedInput.PathQuery, |
| 2208 | color: std.zig.Color, | 2261 | color: std.zig.Color, |
| 2209 | ) Allocator.Error!?ResolveLibInputResult { | 2262 | ) Allocator.Error!?ResolveLibInputResult { |
| 2210 | switch (Compilation.classifyFileExt(pq.path.sub_path)) { | 2263 | switch (Compilation.classifyFileExt(pq.path.sub_path)) { |
| 2211 | .static_library => return try resolvePathInputLib(gpa, arena, io, unresolved_inputs, resolved_inputs, ld_script_bytes, target, pq, .static, color), | 2264 | .static_library => return try resolvePathInputLib(gpa, arena, io, unresolved_inputs, resolved_inputs, ld_script_bytes, archive_dedup, target, pq, .static, color), |
| 2212 | .shared_library => return try resolvePathInputLib(gpa, arena, io, unresolved_inputs, resolved_inputs, ld_script_bytes, target, pq, .dynamic, color), | 2265 | .shared_library => return try resolvePathInputLib(gpa, arena, io, unresolved_inputs, resolved_inputs, ld_script_bytes, archive_dedup, target, pq, .dynamic, color), |
| 2213 | .object => { | 2266 | .object => { |
| 2214 | var file = pq.path.root_dir.handle.openFile(io, pq.path.sub_path, .{}) catch |err| | 2267 | var file = pq.path.root_dir.handle.openFile(io, pq.path.sub_path, .{}) catch |err| |
| 2215 | fatal("failed to open object {f}: {s}", .{ pq.path, @errorName(err) }); | 2268 | fatal("failed to open object {f}: {s}", .{ pq.path, @errorName(err) }); |
| ... | @@ -2246,12 +2299,15 @@ fn resolvePathInputLib( | ... | @@ -2246,12 +2299,15 @@ fn resolvePathInputLib( |
| 2246 | resolved_inputs: *std.ArrayList(Input), | 2299 | resolved_inputs: *std.ArrayList(Input), |
| 2247 | /// Allocated via `gpa`. | 2300 | /// Allocated via `gpa`. |
| 2248 | ld_script_bytes: *std.ArrayList(u8), | 2301 | ld_script_bytes: *std.ArrayList(u8), |
| 2302 | /// Allocated via `gpa`. | ||
| 2303 | archive_dedup: *ArchiveDedupMap, | ||
| 2249 | target: *const std.Target, | 2304 | target: *const std.Target, |
| 2250 | pq: UnresolvedInput.PathQuery, | 2305 | pq: UnresolvedInput.PathQuery, |
| 2251 | link_mode: std.lang.LinkMode, | 2306 | link_mode: std.lang.LinkMode, |
| 2252 | color: std.zig.Color, | 2307 | color: std.zig.Color, |
| 2253 | ) Allocator.Error!ResolveLibInputResult { | 2308 | ) Allocator.Error!ResolveLibInputResult { |
| 2254 | try resolved_inputs.ensureUnusedCapacity(gpa, 1); | 2309 | try resolved_inputs.ensureUnusedCapacity(gpa, 1); |
| 2310 | try archive_dedup.ensureUnusedCapacity(gpa, 1); | ||
| 2255 | 2311 | ||
| 2256 | const test_path: Path = pq.path; | 2312 | const test_path: Path = pq.path; |
| 2257 | // In the case of shared libraries, they might actually be "linker scripts" | 2313 | // In the case of shared libraries, they might actually be "linker scripts" |
| ... | @@ -2276,7 +2332,7 @@ fn resolvePathInputLib( | ... | @@ -2276,7 +2332,7 @@ fn resolvePathInputLib( |
| 2276 | mem.startsWith(u8, buf, std.elf.ARMAG_THIN)) | 2332 | mem.startsWith(u8, buf, std.elf.ARMAG_THIN)) |
| 2277 | { | 2333 | { |
| 2278 | // Appears to be an ELF or archive file. | 2334 | // Appears to be an ELF or archive file. |
| 2279 | return finishResolveLibInput(resolved_inputs, test_path, file, link_mode, pq.query); | 2335 | return finishResolveLibInput(io, resolved_inputs, archive_dedup, test_path, file, link_mode, pq.query); |
| 2280 | } | 2336 | } |
| 2281 | const stat = file.stat(io) catch |err| | 2337 | const stat = file.stat(io) catch |err| |
| 2282 | fatal("failed to stat {f}: {t}", .{ test_path, err }); | 2338 | fatal("failed to stat {f}: {t}", .{ test_path, err }); |
| ... | @@ -2346,7 +2402,7 @@ fn resolvePathInputLib( | ... | @@ -2346,7 +2402,7 @@ fn resolvePathInputLib( |
| 2346 | }), | 2402 | }), |
| 2347 | }; | 2403 | }; |
| 2348 | errdefer file.close(io); | 2404 | errdefer file.close(io); |
| 2349 | return finishResolveLibInput(resolved_inputs, test_path, file, link_mode, pq.query); | 2405 | return finishResolveLibInput(io, resolved_inputs, archive_dedup, test_path, file, link_mode, pq.query); |
| 2350 | } | 2406 | } |
| 2351 | 2407 | ||
| 2352 | pub fn openObject(io: Io, path: Path, must_link: bool, hidden: bool) !Input.Object { | 2408 | pub fn openObject(io: Io, path: Path, must_link: bool, hidden: bool) !Input.Object { |
src/link/Elf2.zig+41-25| ... | @@ -14,6 +14,7 @@ const InternPool = @import("../InternPool.zig"); | ... | @@ -14,6 +14,7 @@ const InternPool = @import("../InternPool.zig"); |
| 14 | const link = @import("../link.zig"); | 14 | const link = @import("../link.zig"); |
| 15 | const MappedFile = @import("MappedFile.zig"); | 15 | const MappedFile = @import("MappedFile.zig"); |
| 16 | const target_util = @import("../target.zig"); | 16 | const target_util = @import("../target.zig"); |
| 17 | const tracy = @import("../tracy.zig"); | ||
| 17 | const Type = @import("../Type.zig"); | 18 | const Type = @import("../Type.zig"); |
| 18 | const Value = @import("../Value.zig"); | 19 | const Value = @import("../Value.zig"); |
| 19 | const Zcu = @import("../Zcu.zig"); | 20 | const Zcu = @import("../Zcu.zig"); |
| ... | @@ -127,7 +128,7 @@ section_by_name: std.array_hash_map.Auto(String(.shstrtab), void), | ... | @@ -127,7 +128,7 @@ section_by_name: std.array_hash_map.Auto(String(.shstrtab), void), |
| 127 | changed_symtab_index: std.array_hash_map.Auto(String(.strtab), void), | 128 | changed_symtab_index: std.array_hash_map.Auto(String(.strtab), void), |
| 128 | /// Counts how many relocations are currently in `.rela.dyn` which would require a `DT_TEXTREL` | 129 | /// Counts how many relocations are currently in `.rela.dyn` which would require a `DT_TEXTREL` |
| 129 | /// entry in the `.dynamic` section. This allows adding `DT_TEXTREL` to the output `.dynamic` | 130 | /// entry in the `.dynamic` section. This allows adding `DT_TEXTREL` to the output `.dynamic` |
| 130 | /// section in `flush` only when it is actually necessary. See also `nodeRequiresTextrel`. | 131 | /// section in `flush` only when it is actually necessary. See also `nodeWantsDsoRelocation`. |
| 131 | textrel_count: u32, | 132 | textrel_count: u32, |
| 132 | 133 | ||
| 133 | const_prog_node: std.Progress.Node, | 134 | const_prog_node: std.Progress.Node, |
| ... | @@ -1127,8 +1128,10 @@ const SymbolReloc = struct { | ... | @@ -1127,8 +1128,10 @@ const SymbolReloc = struct { |
| 1127 | } | 1128 | } |
| 1128 | if (reloc.rela_index.unwrap()) |rela_index| { | 1129 | if (reloc.rela_index.unwrap()) |rela_index| { |
| 1129 | reloc.relaSection(elf).relaDeleteOne(elf, rela_index); | 1130 | reloc.relaSection(elf).relaDeleteOne(elf, rela_index); |
| 1130 | if (elf.nodeRequiresTextrel(reloc.node)) { | 1131 | switch (elf.nodeWantsDsoRelocation(reloc.node)) { |
| 1131 | elf.textrel_count -= 1; | 1132 | .no => unreachable, // there *was* a dynamic relocation! |
| 1133 | .yes => {}, | ||
| 1134 | .yes_textrel => elf.textrel_count -= 1, | ||
| 1132 | } | 1135 | } |
| 1133 | } | 1136 | } |
| 1134 | if (reloc.type.dependsOnTlsSize()) { | 1137 | if (reloc.type.dependsOnTlsSize()) { |
| ... | @@ -1671,8 +1674,10 @@ fn setGlobalSymbolValue( | ... | @@ -1671,8 +1674,10 @@ fn setGlobalSymbolValue( |
| 1671 | assert(reloc.target == Symbol.Id.global(global_name)); | 1674 | assert(reloc.target == Symbol.Id.global(global_name)); |
| 1672 | if (reloc.rela_index.unwrap()) |rela_index| { | 1675 | if (reloc.rela_index.unwrap()) |rela_index| { |
| 1673 | reloc.relaSection(elf).relaDeleteOne(elf, rela_index); | 1676 | reloc.relaSection(elf).relaDeleteOne(elf, rela_index); |
| 1674 | if (elf.nodeRequiresTextrel(reloc.node)) { | 1677 | switch (elf.nodeWantsDsoRelocation(reloc.node)) { |
| 1675 | elf.textrel_count -= 1; | 1678 | .no => unreachable, // there *was* a dynamic relocation! |
| 1679 | .yes => {}, | ||
| 1680 | .yes_textrel => elf.textrel_count -= 1, | ||
| 1676 | } | 1681 | } |
| 1677 | reloc.rela_index = .none; | 1682 | reloc.rela_index = .none; |
| 1678 | } | 1683 | } |
| ... | @@ -1966,17 +1971,6 @@ const Symbol = struct { | ... | @@ -1966,17 +1971,6 @@ const Symbol = struct { |
| 1966 | fn ptr(si: Symbol.Index, elf: *Elf) *Symbol { | 1971 | fn ptr(si: Symbol.Index, elf: *Elf) *Symbol { |
| 1967 | return &elf.symtab.items[@intFromEnum(si)]; | 1972 | return &elf.symtab.items[@intFromEnum(si)]; |
| 1968 | } | 1973 | } |
| 1969 | |||
| 1970 | fn applyTargetRelocs(si: Symbol.Index, elf: *Elf) void { | ||
| 1971 | assert(elf.ehdrField(.type) != .REL); | ||
| 1972 | var ri = si.ptr(elf).first_target_reloc; | ||
| 1973 | while (ri != .none) { | ||
| 1974 | const reloc = ri.get(elf); | ||
| 1975 | assert(reloc.target.index(elf) == si); | ||
| 1976 | reloc.apply(elf); | ||
| 1977 | ri = reloc.next; | ||
| 1978 | } | ||
| 1979 | } | ||
| 1980 | }; | 1974 | }; |
| 1981 | 1975 | ||
| 1982 | /// A `LocalIndex` is a raw index into the symtab like `Index`, but it guarantees that the | 1976 | /// A `LocalIndex` is a raw index into the symtab like `Index`, but it guarantees that the |
| ... | @@ -2063,7 +2057,7 @@ const Symbol = struct { | ... | @@ -2063,7 +2057,7 @@ const Symbol = struct { |
| 2063 | 2057 | ||
| 2064 | // Re-apply relocations targeting this symbol | 2058 | // Re-apply relocations targeting this symbol |
| 2065 | if (elf.ehdrField(.type) != .REL) { | 2059 | if (elf.ehdrField(.type) != .REL) { |
| 2066 | sym_index.applyTargetRelocs(elf); | 2060 | sym_id.applyTargetRelocs(elf); |
| 2067 | } | 2061 | } |
| 2068 | 2062 | ||
| 2069 | // Update GOT entries targeting this symbol | 2063 | // Update GOT entries targeting this symbol |
| ... | @@ -2079,6 +2073,17 @@ const Symbol = struct { | ... | @@ -2079,6 +2073,17 @@ const Symbol = struct { |
| 2079 | } | 2073 | } |
| 2080 | } | 2074 | } |
| 2081 | 2075 | ||
| 2076 | fn applyTargetRelocs(sym_id: Symbol.Id, elf: *Elf) void { | ||
| 2077 | assert(elf.ehdrField(.type) != .REL); | ||
| 2078 | var ri = sym_id.index(elf).ptr(elf).first_target_reloc; | ||
| 2079 | while (ri != .none) { | ||
| 2080 | const reloc = ri.get(elf); | ||
| 2081 | assert(reloc.target == sym_id); | ||
| 2082 | reloc.apply(elf); | ||
| 2083 | ri = reloc.next; | ||
| 2084 | } | ||
| 2085 | } | ||
| 2086 | |||
| 2082 | /// Returns `true` if the target of `s` has moved, meaning the symbol's value will change at | 2087 | /// Returns `true` if the target of `s` has moved, meaning the symbol's value will change at |
| 2083 | /// some point due to a call to `flushMoved`. | 2088 | /// some point due to a call to `flushMoved`. |
| 2084 | fn hasMoved(s: Symbol.Id, elf: *Elf) bool { | 2089 | fn hasMoved(s: Symbol.Id, elf: *Elf) bool { |
| ... | @@ -4441,7 +4446,7 @@ fn loadDso(elf: *Elf, path: std.Build.Cache.Path, fr: *Io.File.Reader) !void { | ... | @@ -4441,7 +4446,7 @@ fn loadDso(elf: *Elf, path: std.Build.Cache.Path, fr: *Io.File.Reader) !void { |
| 4441 | elf.addPltEntry(name, global_ptr.dynsym_index); | 4446 | elf.addPltEntry(name, global_ptr.dynsym_index); |
| 4442 | // ...and therefore, we need to re-apply that symbol's relocations, as | 4447 | // ...and therefore, we need to re-apply that symbol's relocations, as |
| 4443 | // some might be targeting its PLT entry. | 4448 | // some might be targeting its PLT entry. |
| 4444 | global_ptr.symtab_index.applyTargetRelocs(elf); | 4449 | Symbol.Id.global(name).applyTargetRelocs(elf); |
| 4445 | } | 4450 | } |
| 4446 | } | 4451 | } |
| 4447 | } | 4452 | } |
| ... | @@ -5107,8 +5112,10 @@ fn addSymbolRelocAssumeCapacity( | ... | @@ -5107,8 +5112,10 @@ fn addSymbolRelocAssumeCapacity( |
| 5107 | } else elf.globalByName(name).?.dynsym_index, | 5112 | } else elf.globalByName(name).?.dynsym_index, |
| 5108 | }; | 5113 | }; |
| 5109 | 5114 | ||
| 5110 | if (elf.nodeRequiresTextrel(node)) { | 5115 | switch (elf.nodeWantsDsoRelocation(node)) { |
| 5111 | elf.textrel_count += 1; | 5116 | .no => break :r .none, |
| 5117 | .yes => {}, | ||
| 5118 | .yes_textrel => elf.textrel_count += 1, | ||
| 5112 | } | 5119 | } |
| 5113 | 5120 | ||
| 5114 | // It currently looks like we need a runtime relocation for this. | 5121 | // It currently looks like we need a runtime relocation for this. |
| ... | @@ -5382,13 +5389,18 @@ fn updateGotEntry(elf: *Elf, got_index: usize) void { | ... | @@ -5382,13 +5389,18 @@ fn updateGotEntry(elf: *Elf, got_index: usize) void { |
| 5382 | }; | 5389 | }; |
| 5383 | } | 5390 | } |
| 5384 | 5391 | ||
| 5385 | /// Returns whether a `DT_TEXTREL` dynamic entry is needed to have a runtime relocation in `node`. | 5392 | /// If `node` cannot contain runtime relocations, returns `.no`. |
| 5386 | fn nodeRequiresTextrel(elf: *Elf, node: MappedFile.Node.Index) bool { | 5393 | /// |
| 5394 | /// If `node` can contain runtime relocations, `returns `.yes_textrel` if such a relocation requires | ||
| 5395 | /// the presence of a `DT_TEXTREL` dynamic entry, or `.yes` otherwise. | ||
| 5396 | fn nodeWantsDsoRelocation(elf: *Elf, node: MappedFile.Node.Index) enum { yes, yes_textrel, no } { | ||
| 5387 | const shndx = elf.getNodeShndx(node); | 5397 | const shndx = elf.getNodeShndx(node); |
| 5388 | const shf: std.elf.SHF = switch (elf.shdrPtr(shndx)) { | 5398 | const shf: std.elf.SHF = switch (elf.shdrPtr(shndx)) { |
| 5389 | inline else => |shdr| elf.targetLoad(&shdr.flags).shf, | 5399 | inline else => |shdr| elf.targetLoad(&shdr.flags).shf, |
| 5390 | }; | 5400 | }; |
| 5391 | return shf.ALLOC and !shf.WRITE; | 5401 | if (!shf.ALLOC) return .no; |
| 5402 | if (!shf.WRITE) return .yes_textrel; | ||
| 5403 | return .yes; | ||
| 5392 | } | 5404 | } |
| 5393 | 5405 | ||
| 5394 | pub fn updateNav(elf: *Elf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) !void { | 5406 | pub fn updateNav(elf: *Elf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) !void { |
| ... | @@ -5668,7 +5680,7 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) !bool { | ... | @@ -5668,7 +5680,7 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) !bool { |
| 5668 | }; | 5680 | }; |
| 5669 | break :task; | 5681 | break :task; |
| 5670 | } | 5682 | } |
| 5671 | if (elf.changed_symtab_index.pop()) |kv| { | 5683 | while (elf.changed_symtab_index.pop()) |kv| { |
| 5672 | // We only need to do work in relocatables, because in ELF modules (non-relocatables) | 5684 | // We only need to do work in relocatables, because in ELF modules (non-relocatables) |
| 5673 | // our `ElfN.Rela` entries use `.dynsym` indices rather than `.symtab` indices, and | 5685 | // our `ElfN.Rela` entries use `.dynsym` indices rather than `.symtab` indices, and |
| 5674 | // `.dynsym` indices are (at the time of writing) always immutable. | 5686 | // `.dynsym` indices are (at the time of writing) always immutable. |
| ... | @@ -5865,6 +5877,8 @@ fn flushFileOffset(elf: *Elf, ni: MappedFile.Node.Index) !void { | ... | @@ -5865,6 +5877,8 @@ fn flushFileOffset(elf: *Elf, ni: MappedFile.Node.Index) !void { |
| 5865 | } | 5877 | } |
| 5866 | 5878 | ||
| 5867 | fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) !void { | 5879 | fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) !void { |
| 5880 | const trace = tracy.trace(@src()); | ||
| 5881 | defer trace.end(); | ||
| 5868 | switch (elf.getNode(ni)) { | 5882 | switch (elf.getNode(ni)) { |
| 5869 | .file => unreachable, | 5883 | .file => unreachable, |
| 5870 | .ehdr, .shdr => try elf.flushFileOffset(ni), | 5884 | .ehdr, .shdr => try elf.flushFileOffset(ni), |
| ... | @@ -6019,6 +6033,8 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) !void { | ... | @@ -6019,6 +6033,8 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) !void { |
| 6019 | } | 6033 | } |
| 6020 | 6034 | ||
| 6021 | fn flushResized(elf: *Elf, ni: MappedFile.Node.Index) !void { | 6035 | fn flushResized(elf: *Elf, ni: MappedFile.Node.Index) !void { |
| 6036 | const trace = tracy.trace(@src()); | ||
| 6037 | defer trace.end(); | ||
| 6022 | _, const size = ni.location(&elf.mf).resolve(&elf.mf); | 6038 | _, const size = ni.location(&elf.mf).resolve(&elf.mf); |
| 6023 | switch (elf.getNode(ni)) { | 6039 | switch (elf.getNode(ni)) { |
| 6024 | .file => {}, | 6040 | .file => {}, |
| ... | @@ -6152,7 +6168,7 @@ fn flushMovedPltSection(elf: *Elf, which: enum { plt, plt_sec, got_plt }, old_ad | ... | @@ -6152,7 +6168,7 @@ fn flushMovedPltSection(elf: *Elf, which: enum { plt, plt_sec, got_plt }, old_ad |
| 6152 | // specific tracking for PLT relocations---instead just re-apply all relocations | 6168 | // specific tracking for PLT relocations---instead just re-apply all relocations |
| 6153 | // targeting symbols with PLT entries. | 6169 | // targeting symbols with PLT entries. |
| 6154 | for (elf.plt.keys()) |sym| { | 6170 | for (elf.plt.keys()) |sym| { |
| 6155 | sym.index(elf).applyTargetRelocs(elf); | 6171 | sym.applyTargetRelocs(elf); |
| 6156 | } | 6172 | } |
| 6157 | // We also need to update all of the references from `.plt.sec` to `.got.plt`. | 6173 | // We also need to update all of the references from `.plt.sec` to `.got.plt`. |
| 6158 | // However, if there's also a flush pending for `.got.plt`, don't bother doing | 6174 | // However, if there's also a flush pending for `.got.plt`, don't bother doing |
src/main.zig+2-4| ... | @@ -218,8 +218,8 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void { | ... | @@ -218,8 +218,8 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void { |
| 218 | var environ_map = init.environ.createMap(arena) catch |err| fatal("failed to parse environment: {t}", .{err}); | 218 | var environ_map = init.environ.createMap(arena) catch |err| fatal("failed to parse environment: {t}", .{err}); |
| 219 | 219 | ||
| 220 | if (tracy.enable_allocation) { | 220 | if (tracy.enable_allocation) { |
| 221 | var gpa_tracy = tracy.tracyAllocator(gpa); | 221 | var tracy_allocator: tracy.Allocator = .{ .parent_allocator = gpa }; |
| 222 | return mainArgs(gpa_tracy.allocator(), arena, io, args, &environ_map); | 222 | return mainArgs(tracy_allocator.interface(), arena, io, args, &environ_map); |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | if (native_os == .wasi) { | 225 | if (native_os == .wasi) { |
| ... | @@ -4239,7 +4239,6 @@ fn serve( | ... | @@ -4239,7 +4239,6 @@ fn serve( |
| 4239 | switch (hdr.tag) { | 4239 | switch (hdr.tag) { |
| 4240 | .exit => return cleanExit(io), | 4240 | .exit => return cleanExit(io), |
| 4241 | .update => { | 4241 | .update => { |
| 4242 | tracy.frameMark(); | ||
| 4243 | file_system_inputs.clearRetainingCapacity(); | 4242 | file_system_inputs.clearRetainingCapacity(); |
| 4244 | 4243 | ||
| 4245 | if (arg_mode == .translate_c) { | 4244 | if (arg_mode == .translate_c) { |
| ... | @@ -4296,7 +4295,6 @@ fn serve( | ... | @@ -4296,7 +4295,6 @@ fn serve( |
| 4296 | //); | 4295 | //); |
| 4297 | }, | 4296 | }, |
| 4298 | .hot_update => { | 4297 | .hot_update => { |
| 4299 | tracy.frameMark(); | ||
| 4300 | file_system_inputs.clearRetainingCapacity(); | 4298 | file_system_inputs.clearRetainingCapacity(); |
| 4301 | if (child_pid) |pid| { | 4299 | if (child_pid) |pid| { |
| 4302 | try comp.hotCodeSwap(main_progress_node, pid); | 4300 | try comp.hotCodeSwap(main_progress_node, pid); |
src/tracy.zig+133-176| ... | @@ -1,11 +1,13 @@ | ... | @@ -1,11 +1,13 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const assert = std.debug.assert; | ||
| 3 | |||
| 2 | const builtin = @import("builtin"); | 4 | const builtin = @import("builtin"); |
| 3 | const build_options = @import("build_options"); | 5 | const build_options = @import("build_options"); |
| 4 | 6 | ||
| 5 | pub const enable = if (builtin.is_test) false else build_options.enable_tracy; | 7 | pub const enable = if (builtin.is_test) false else build_options.enable_tracy; |
| 6 | pub const enable_allocation = enable and build_options.enable_tracy_allocation; | 8 | pub const enable_allocation = enable and build_options.enable_tracy_allocation; |
| 7 | pub const enable_callstack = enable and build_options.enable_tracy_callstack; | 9 | pub const enable_callstack = enable and build_options.enable_tracy_callstack; |
| 8 | pub const callstack_depth = if (enable_callstack and build_options.tracy_callstack_depth > 0) build_options.tracy_callstack_depth else 10; | 10 | pub const callstack_depth = if (enable_callstack) build_options.tracy_callstack_depth else 0; |
| 9 | 11 | ||
| 10 | const ___tracy_c_zone_context = extern struct { | 12 | const ___tracy_c_zone_context = extern struct { |
| 11 | id: u32, | 13 | id: u32, |
| ... | @@ -19,6 +21,12 @@ const ___tracy_c_zone_context = extern struct { | ... | @@ -19,6 +21,12 @@ const ___tracy_c_zone_context = extern struct { |
| 19 | ___tracy_emit_zone_text(self, text.ptr, text.len); | 21 | ___tracy_emit_zone_text(self, text.ptr, text.len); |
| 20 | } | 22 | } |
| 21 | 23 | ||
| 24 | pub inline fn addTextFmt(self: @This(), comptime fmt: []const u8, args: anytype) void { | ||
| 25 | var buf: [512]u8 = undefined; | ||
| 26 | const slice = std.fmt.bufPrint(&buf, fmt, args) catch &buf; | ||
| 27 | self.addText(slice); | ||
| 28 | } | ||
| 29 | |||
| 22 | pub inline fn setName(self: @This(), name: []const u8) void { | 30 | pub inline fn setName(self: @This(), name: []const u8) void { |
| 23 | ___tracy_emit_zone_name(self, name.ptr, name.len); | 31 | ___tracy_emit_zone_name(self, name.ptr, name.len); |
| 24 | } | 32 | } |
| ... | @@ -42,6 +50,12 @@ pub const Ctx = if (enable) ___tracy_c_zone_context else struct { | ... | @@ -42,6 +50,12 @@ pub const Ctx = if (enable) ___tracy_c_zone_context else struct { |
| 42 | _ = text; | 50 | _ = text; |
| 43 | } | 51 | } |
| 44 | 52 | ||
| 53 | pub inline fn addTextFmt(self: @This(), comptime fmt: []const u8, args: anytype) void { | ||
| 54 | _ = self; | ||
| 55 | _ = fmt; | ||
| 56 | _ = args; | ||
| 57 | } | ||
| 58 | |||
| 45 | pub inline fn setName(self: @This(), name: []const u8) void { | 59 | pub inline fn setName(self: @This(), name: []const u8) void { |
| 46 | _ = self; | 60 | _ = self; |
| 47 | _ = name; | 61 | _ = name; |
| ... | @@ -71,11 +85,7 @@ pub inline fn trace(comptime src: std.lang.SourceLocation) Ctx { | ... | @@ -71,11 +85,7 @@ pub inline fn trace(comptime src: std.lang.SourceLocation) Ctx { |
| 71 | }; | 85 | }; |
| 72 | }; | 86 | }; |
| 73 | 87 | ||
| 74 | if (enable_callstack) { | 88 | return ___tracy_emit_zone_begin_callstack(&global.loc, callstack_depth, 1); |
| 75 | return ___tracy_emit_zone_begin_callstack(&global.loc, callstack_depth, 1); | ||
| 76 | } else { | ||
| 77 | return ___tracy_emit_zone_begin(&global.loc, 1); | ||
| 78 | } | ||
| 79 | } | 89 | } |
| 80 | 90 | ||
| 81 | pub inline fn traceNamed(comptime src: std.lang.SourceLocation, comptime name: [:0]const u8) Ctx { | 91 | pub inline fn traceNamed(comptime src: std.lang.SourceLocation, comptime name: [:0]const u8) Ctx { |
| ... | @@ -91,11 +101,7 @@ pub inline fn traceNamed(comptime src: std.lang.SourceLocation, comptime name: [ | ... | @@ -91,11 +101,7 @@ pub inline fn traceNamed(comptime src: std.lang.SourceLocation, comptime name: [ |
| 91 | }; | 101 | }; |
| 92 | }; | 102 | }; |
| 93 | 103 | ||
| 94 | if (enable_callstack) { | 104 | return ___tracy_emit_zone_begin_callstack(&global.loc, callstack_depth, 1); |
| 95 | return ___tracy_emit_zone_begin_callstack(&global.loc, callstack_depth, 1); | ||
| 96 | } else { | ||
| 97 | return ___tracy_emit_zone_begin(&global.loc, 1); | ||
| 98 | } | ||
| 99 | } | 105 | } |
| 100 | 106 | ||
| 101 | pub inline fn fiberEnter(fiber: [*:0]const u8) void { | 107 | pub inline fn fiberEnter(fiber: [*:0]const u8) void { |
| ... | @@ -108,102 +114,93 @@ pub inline fn fiberLeave() void { | ... | @@ -108,102 +114,93 @@ pub inline fn fiberLeave() void { |
| 108 | ___tracy_fiber_leave(); | 114 | ___tracy_fiber_leave(); |
| 109 | } | 115 | } |
| 110 | 116 | ||
| 111 | pub fn tracyAllocator(allocator: std.mem.Allocator) TracyAllocator(null) { | 117 | pub inline fn plotConfig(comptime name: [*:0]const u8, config: PlotConfig) void { |
| 112 | return TracyAllocator(null).init(allocator); | 118 | if (!enable) return; |
| 119 | ___tracy_emit_plot_config( | ||
| 120 | name, | ||
| 121 | config.format, | ||
| 122 | config.mode, | ||
| 123 | @intFromBool(config.fill), | ||
| 124 | // https://github.com/wolfpld/tracy/issues/1232 | ||
| 125 | @byteSwap(config.color), | ||
| 126 | ); | ||
| 113 | } | 127 | } |
| 114 | 128 | ||
| 115 | pub fn TracyAllocator(comptime name: ?[:0]const u8) type { | 129 | pub inline fn plotInt(comptime name: [*:0]const u8, val: i64) void { |
| 116 | return struct { | 130 | if (!enable) return; |
| 117 | parent_allocator: std.mem.Allocator, | 131 | ___tracy_emit_plot_int(name, val); |
| 132 | } | ||
| 118 | 133 | ||
| 119 | const Self = @This(); | 134 | pub const Allocator = struct { |
| 135 | parent_allocator: std.mem.Allocator, | ||
| 120 | 136 | ||
| 121 | pub fn init(parent_allocator: std.mem.Allocator) Self { | 137 | comptime { |
| 122 | return .{ | 138 | assert(enable); // used `tracy.Allocator` with Tracy disabled |
| 123 | .parent_allocator = parent_allocator, | 139 | } |
| 124 | }; | ||
| 125 | } | ||
| 126 | 140 | ||
| 127 | pub fn allocator(self: *Self) std.mem.Allocator { | 141 | pub fn interface(self: *Allocator) std.mem.Allocator { |
| 128 | return .{ | 142 | return .{ |
| 129 | .ptr = self, | 143 | .ptr = self, |
| 130 | .vtable = &.{ | 144 | .vtable = &.{ |
| 131 | .alloc = allocFn, | 145 | .alloc = allocFn, |
| 132 | .resize = resizeFn, | 146 | .resize = resizeFn, |
| 133 | .remap = remapFn, | 147 | .remap = remapFn, |
| 134 | .free = freeFn, | 148 | .free = freeFn, |
| 135 | }, | 149 | }, |
| 136 | }; | 150 | }; |
| 137 | } | 151 | } |
| 138 | 152 | ||
| 139 | fn allocFn(ptr: *anyopaque, len: usize, alignment: std.mem.Alignment, ret_addr: usize) ?[*]u8 { | 153 | fn allocFn(ptr: *anyopaque, len: usize, alignment: std.mem.Alignment, ret_addr: usize) ?[*]u8 { |
| 140 | const self: *Self = @ptrCast(@alignCast(ptr)); | 154 | const self: *Allocator = @ptrCast(@alignCast(ptr)); |
| 141 | const result = self.parent_allocator.rawAlloc(len, alignment, ret_addr); | 155 | assert(len > 0); |
| 142 | if (result) |memory| { | 156 | if (self.parent_allocator.rawAlloc(len, alignment, ret_addr)) |memory| { |
| 143 | if (len != 0) { | 157 | ___tracy_emit_memory_alloc_callstack(memory, len, callstack_depth, 0); |
| 144 | if (name) |n| { | 158 | return memory; |
| 145 | allocNamed(memory, len, n); | 159 | } else { |
| 146 | } else { | 160 | messageColor("allocation failed", 0xFF0000); |
| 147 | alloc(memory, len); | 161 | return null; |
| 148 | } | ||
| 149 | } | ||
| 150 | } else { | ||
| 151 | messageColor("allocation failed", 0xFF0000); | ||
| 152 | } | ||
| 153 | return result; | ||
| 154 | } | 162 | } |
| 163 | } | ||
| 155 | 164 | ||
| 156 | fn resizeFn(ptr: *anyopaque, memory: []u8, alignment: std.mem.Alignment, new_len: usize, ret_addr: usize) bool { | 165 | fn resizeFn(ptr: *anyopaque, memory: []u8, alignment: std.mem.Alignment, new_len: usize, ret_addr: usize) bool { |
| 157 | const self: *Self = @ptrCast(@alignCast(ptr)); | 166 | const self: *Allocator = @ptrCast(@alignCast(ptr)); |
| 158 | if (self.parent_allocator.rawResize(memory, alignment, new_len, ret_addr)) { | 167 | assert(memory.len > 0); |
| 159 | if (name) |n| { | 168 | assert(new_len > 0); |
| 160 | freeNamed(memory.ptr, n); | 169 | // We need to mark the free before calling the implementation to avoid a race. |
| 161 | allocNamed(memory.ptr, new_len, n); | 170 | ___tracy_emit_memory_free_callstack(memory.ptr, callstack_depth, 0); |
| 162 | } else { | 171 | if (self.parent_allocator.rawResize(memory, alignment, new_len, ret_addr)) { |
| 163 | free(memory.ptr); | 172 | ___tracy_emit_memory_alloc_callstack(memory.ptr, new_len, callstack_depth, 0); |
| 164 | alloc(memory.ptr, new_len); | 173 | return true; |
| 165 | } | 174 | } else { |
| 166 | 175 | // No `messageColor` call here because this case is hit frequently in normal operation. | |
| 167 | return true; | 176 | ___tracy_emit_memory_alloc_callstack(memory.ptr, memory.len, callstack_depth, 0); |
| 168 | } | ||
| 169 | |||
| 170 | // during normal operation the compiler hits this case thousands of times due to this | ||
| 171 | // emitting messages for it is both slow and causes clutter | ||
| 172 | return false; | 177 | return false; |
| 173 | } | 178 | } |
| 179 | } | ||
| 174 | 180 | ||
| 175 | fn remapFn(ptr: *anyopaque, memory: []u8, alignment: std.mem.Alignment, new_len: usize, ret_addr: usize) ?[*]u8 { | 181 | fn remapFn(ptr: *anyopaque, memory: []u8, alignment: std.mem.Alignment, new_len: usize, ret_addr: usize) ?[*]u8 { |
| 176 | const self: *Self = @ptrCast(@alignCast(ptr)); | 182 | const self: *Allocator = @ptrCast(@alignCast(ptr)); |
| 177 | if (self.parent_allocator.rawRemap(memory, alignment, new_len, ret_addr)) |new_memory| { | 183 | assert(memory.len > 0); |
| 178 | if (name) |n| { | 184 | assert(new_len > 0); |
| 179 | freeNamed(memory.ptr, n); | 185 | // We need to mark the free before calling the implementation to avoid a race. |
| 180 | allocNamed(new_memory, new_len, n); | 186 | ___tracy_emit_memory_free_callstack(memory.ptr, callstack_depth, 0); |
| 181 | } else { | 187 | if (self.parent_allocator.rawRemap(memory, alignment, new_len, ret_addr)) |new_memory| { |
| 182 | free(memory.ptr); | 188 | ___tracy_emit_memory_alloc_callstack(new_memory, new_len, callstack_depth, 0); |
| 183 | alloc(new_memory, new_len); | 189 | return new_memory; |
| 184 | } | 190 | } else { |
| 185 | return new_memory; | 191 | // No `messageColor` call here because this case is hit frequently in normal operation. |
| 186 | } else { | 192 | ___tracy_emit_memory_alloc_callstack(memory.ptr, memory.len, callstack_depth, 0); |
| 187 | messageColor("reallocation failed", 0xFF0000); | 193 | return null; |
| 188 | return null; | ||
| 189 | } | ||
| 190 | } | 194 | } |
| 195 | } | ||
| 191 | 196 | ||
| 192 | fn freeFn(ptr: *anyopaque, memory: []u8, alignment: std.mem.Alignment, ret_addr: usize) void { | 197 | fn freeFn(ptr: *anyopaque, memory: []u8, alignment: std.mem.Alignment, ret_addr: usize) void { |
| 193 | const self: *Self = @ptrCast(@alignCast(ptr)); | 198 | const self: *Allocator = @ptrCast(@alignCast(ptr)); |
| 194 | self.parent_allocator.rawFree(memory, alignment, ret_addr); | 199 | assert(memory.len > 0); |
| 195 | // this condition is to handle free being called on an empty slice that was never even allocated | 200 | ___tracy_emit_memory_free_callstack(memory.ptr, callstack_depth, 0); |
| 196 | // example case: `std.process.getSelfExeSharedLibPaths` can return `&[_][:0]u8{}` | 201 | self.parent_allocator.rawFree(memory, alignment, ret_addr); |
| 197 | if (memory.len != 0) { | 202 | } |
| 198 | if (name) |n| { | 203 | }; |
| 199 | freeNamed(memory.ptr, n); | ||
| 200 | } else { | ||
| 201 | free(memory.ptr); | ||
| 202 | } | ||
| 203 | } | ||
| 204 | } | ||
| 205 | }; | ||
| 206 | } | ||
| 207 | 204 | ||
| 208 | // This function only accepts comptime-known strings, see `messageCopy` for runtime strings | 205 | // This function only accepts comptime-known strings, see `messageCopy` for runtime strings |
| 209 | pub inline fn message(comptime msg: [:0]const u8) void { | 206 | pub inline fn message(comptime msg: [:0]const u8) void { |
| ... | @@ -213,7 +210,7 @@ pub inline fn message(comptime msg: [:0]const u8) void { | ... | @@ -213,7 +210,7 @@ pub inline fn message(comptime msg: [:0]const u8) void { |
| 213 | // This function only accepts comptime-known strings, see `messageColorCopy` for runtime strings | 210 | // This function only accepts comptime-known strings, see `messageColorCopy` for runtime strings |
| 214 | pub inline fn messageColor(comptime msg: [:0]const u8, color: u24) void { | 211 | pub inline fn messageColor(comptime msg: [:0]const u8, color: u24) void { |
| 215 | if (!enable) return; | 212 | if (!enable) return; |
| 216 | ___tracy_emit_logStringL(.Info, color, if (enable_callstack) callstack_depth else 0, msg.ptr); | 213 | ___tracy_emit_logStringL(.Info, color, callstack_depth, msg.ptr); |
| 217 | } | 214 | } |
| 218 | 215 | ||
| 219 | pub inline fn messageCopy(msg: []const u8) void { | 216 | pub inline fn messageCopy(msg: []const u8) void { |
| ... | @@ -222,84 +219,29 @@ pub inline fn messageCopy(msg: []const u8) void { | ... | @@ -222,84 +219,29 @@ pub inline fn messageCopy(msg: []const u8) void { |
| 222 | 219 | ||
| 223 | pub inline fn messageColorCopy(msg: []const u8, color: u24) void { | 220 | pub inline fn messageColorCopy(msg: []const u8, color: u24) void { |
| 224 | if (!enable) return; | 221 | if (!enable) return; |
| 225 | ___tracy_emit_logString(.Info, color, if (enable_callstack) callstack_depth else 0, msg.len, msg.ptr); | 222 | ___tracy_emit_logString(.Info, color, callstack_depth, msg.len, msg.ptr); |
| 226 | } | 223 | } |
| 227 | 224 | ||
| 228 | pub inline fn frameMark() void { | 225 | /// Used to store strings which Tracy requires to have stable pointers for the program's entire |
| 229 | if (!enable) return; | 226 | /// lifetime. All such strings will be leaked. |
| 230 | ___tracy_emit_frame_mark(null); | 227 | /// |
| 228 | /// The `enable` check ensures that this is not referenced if Tracy is disabled. | ||
| 229 | var tracy_arena: std.heap.ArenaAllocator = if (enable) .init(std.heap.page_allocator); | ||
| 230 | |||
| 231 | pub inline fn namedFrame(name: []const u8) Frame { | ||
| 232 | if (!enable) return .{ .name = {} }; | ||
| 233 | const stable_name = tracy_arena.allocator().dupeSentinel(u8, name, 0) catch @panic("tracy arena OOM"); | ||
| 234 | ___tracy_emit_frame_mark_start(stable_name.ptr); | ||
| 235 | return .{ .name = stable_name.ptr }; | ||
| 231 | } | 236 | } |
| 232 | 237 | ||
| 233 | pub inline fn frameMarkNamed(comptime name: [:0]const u8) void { | 238 | pub const Frame = struct { |
| 234 | if (!enable) return; | 239 | name: if (enable) [*:0]const u8 else void, |
| 235 | ___tracy_emit_frame_mark(name.ptr); | 240 | pub inline fn end(frame: Frame) void { |
| 236 | } | 241 | if (!enable) return; |
| 237 | 242 | ___tracy_emit_frame_mark_end(frame.name); | |
| 238 | pub inline fn namedFrame(comptime name: [:0]const u8) Frame(name) { | ||
| 239 | frameMarkStart(name); | ||
| 240 | return .{}; | ||
| 241 | } | ||
| 242 | |||
| 243 | pub fn Frame(comptime name: [:0]const u8) type { | ||
| 244 | return struct { | ||
| 245 | pub fn end(_: @This()) void { | ||
| 246 | frameMarkEnd(name); | ||
| 247 | } | ||
| 248 | }; | ||
| 249 | } | ||
| 250 | |||
| 251 | inline fn frameMarkStart(comptime name: [:0]const u8) void { | ||
| 252 | if (!enable) return; | ||
| 253 | ___tracy_emit_frame_mark_start(name.ptr); | ||
| 254 | } | ||
| 255 | |||
| 256 | inline fn frameMarkEnd(comptime name: [:0]const u8) void { | ||
| 257 | if (!enable) return; | ||
| 258 | ___tracy_emit_frame_mark_end(name.ptr); | ||
| 259 | } | ||
| 260 | |||
| 261 | extern fn ___tracy_emit_frame_mark_start(name: [*:0]const u8) void; | ||
| 262 | extern fn ___tracy_emit_frame_mark_end(name: [*:0]const u8) void; | ||
| 263 | |||
| 264 | inline fn alloc(ptr: [*]u8, len: usize) void { | ||
| 265 | if (!enable) return; | ||
| 266 | |||
| 267 | if (enable_callstack) { | ||
| 268 | ___tracy_emit_memory_alloc_callstack(ptr, len, callstack_depth, 0); | ||
| 269 | } else { | ||
| 270 | ___tracy_emit_memory_alloc(ptr, len, 0); | ||
| 271 | } | ||
| 272 | } | ||
| 273 | |||
| 274 | inline fn allocNamed(ptr: [*]u8, len: usize, comptime name: [:0]const u8) void { | ||
| 275 | if (!enable) return; | ||
| 276 | |||
| 277 | if (enable_callstack) { | ||
| 278 | ___tracy_emit_memory_alloc_callstack_named(ptr, len, callstack_depth, 0, name.ptr); | ||
| 279 | } else { | ||
| 280 | ___tracy_emit_memory_alloc_named(ptr, len, 0, name.ptr); | ||
| 281 | } | ||
| 282 | } | ||
| 283 | |||
| 284 | inline fn free(ptr: [*]u8) void { | ||
| 285 | if (!enable) return; | ||
| 286 | |||
| 287 | if (enable_callstack) { | ||
| 288 | ___tracy_emit_memory_free_callstack(ptr, callstack_depth, 0); | ||
| 289 | } else { | ||
| 290 | ___tracy_emit_memory_free(ptr, 0); | ||
| 291 | } | 243 | } |
| 292 | } | 244 | }; |
| 293 | |||
| 294 | inline fn freeNamed(ptr: [*]u8, comptime name: [:0]const u8) void { | ||
| 295 | if (!enable) return; | ||
| 296 | |||
| 297 | if (enable_callstack) { | ||
| 298 | ___tracy_emit_memory_free_callstack_named(ptr, callstack_depth, 0, name.ptr); | ||
| 299 | } else { | ||
| 300 | ___tracy_emit_memory_free_named(ptr, 0, name.ptr); | ||
| 301 | } | ||
| 302 | } | ||
| 303 | 245 | ||
| 304 | pub const MessageSeverity = enum(i8) { | 246 | pub const MessageSeverity = enum(i8) { |
| 305 | Trace, // Broadly track variable states and events in the software program. | 247 | Trace, // Broadly track variable states and events in the software program. |
| ... | @@ -310,24 +252,39 @@ pub const MessageSeverity = enum(i8) { | ... | @@ -310,24 +252,39 @@ pub const MessageSeverity = enum(i8) { |
| 310 | Fatal, // Describes a critical event that will lead to a software failure/crash. | 252 | Fatal, // Describes a critical event that will lead to a software failure/crash. |
| 311 | }; | 253 | }; |
| 312 | 254 | ||
| 313 | extern fn ___tracy_emit_zone_begin(srcloc: *const ___tracy_source_location_data, active: i32) ___tracy_c_zone_context; | 255 | pub const PlotConfig = struct { |
| 256 | format: Format, | ||
| 257 | mode: Mode, | ||
| 258 | fill: bool = true, | ||
| 259 | color: u24 = 0, | ||
| 260 | |||
| 261 | pub const Format = enum(i32) { | ||
| 262 | number = 0, | ||
| 263 | memory = 1, | ||
| 264 | percentage = 2, | ||
| 265 | watt = 3, | ||
| 266 | }; | ||
| 267 | |||
| 268 | pub const Mode = enum(i32) { | ||
| 269 | line = 0, | ||
| 270 | step = 1, | ||
| 271 | }; | ||
| 272 | }; | ||
| 273 | |||
| 274 | extern fn ___tracy_emit_frame_mark_start(name: [*:0]const u8) void; | ||
| 275 | extern fn ___tracy_emit_frame_mark_end(name: [*:0]const u8) void; | ||
| 314 | extern fn ___tracy_emit_zone_begin_callstack(srcloc: *const ___tracy_source_location_data, depth: i32, active: i32) ___tracy_c_zone_context; | 276 | extern fn ___tracy_emit_zone_begin_callstack(srcloc: *const ___tracy_source_location_data, depth: i32, active: i32) ___tracy_c_zone_context; |
| 315 | extern fn ___tracy_emit_zone_text(ctx: ___tracy_c_zone_context, txt: [*]const u8, size: usize) void; | 277 | extern fn ___tracy_emit_zone_text(ctx: ___tracy_c_zone_context, txt: [*]const u8, size: usize) void; |
| 316 | extern fn ___tracy_emit_zone_name(ctx: ___tracy_c_zone_context, txt: [*]const u8, size: usize) void; | 278 | extern fn ___tracy_emit_zone_name(ctx: ___tracy_c_zone_context, txt: [*]const u8, size: usize) void; |
| 317 | extern fn ___tracy_emit_zone_color(ctx: ___tracy_c_zone_context, color: u32) void; | 279 | extern fn ___tracy_emit_zone_color(ctx: ___tracy_c_zone_context, color: u32) void; |
| 318 | extern fn ___tracy_emit_zone_value(ctx: ___tracy_c_zone_context, value: u64) void; | 280 | extern fn ___tracy_emit_zone_value(ctx: ___tracy_c_zone_context, value: u64) void; |
| 319 | extern fn ___tracy_emit_zone_end(ctx: ___tracy_c_zone_context) void; | 281 | extern fn ___tracy_emit_zone_end(ctx: ___tracy_c_zone_context) void; |
| 320 | extern fn ___tracy_emit_memory_alloc(ptr: *const anyopaque, size: usize, secure: i32) void; | ||
| 321 | extern fn ___tracy_emit_memory_alloc_callstack(ptr: *const anyopaque, size: usize, depth: i32, secure: i32) void; | 282 | extern fn ___tracy_emit_memory_alloc_callstack(ptr: *const anyopaque, size: usize, depth: i32, secure: i32) void; |
| 322 | extern fn ___tracy_emit_memory_free(ptr: *const anyopaque, secure: i32) void; | ||
| 323 | extern fn ___tracy_emit_memory_free_callstack(ptr: *const anyopaque, depth: i32, secure: i32) void; | 283 | extern fn ___tracy_emit_memory_free_callstack(ptr: *const anyopaque, depth: i32, secure: i32) void; |
| 324 | extern fn ___tracy_emit_memory_alloc_named(ptr: *const anyopaque, size: usize, secure: i32, name: [*:0]const u8) void; | ||
| 325 | extern fn ___tracy_emit_memory_alloc_callstack_named(ptr: *const anyopaque, size: usize, depth: i32, secure: i32, name: [*:0]const u8) void; | ||
| 326 | extern fn ___tracy_emit_memory_free_named(ptr: *const anyopaque, secure: i32, name: [*:0]const u8) void; | ||
| 327 | extern fn ___tracy_emit_memory_free_callstack_named(ptr: *const anyopaque, depth: i32, secure: i32, name: [*:0]const u8) void; | ||
| 328 | extern fn ___tracy_emit_logString(severity: MessageSeverity, color: i32, callstack_depth: i32, size: usize, txt: [*]const u8) void; | 284 | extern fn ___tracy_emit_logString(severity: MessageSeverity, color: i32, callstack_depth: i32, size: usize, txt: [*]const u8) void; |
| 329 | extern fn ___tracy_emit_logStringL(severity: MessageSeverity, color: i32, callstack_depth: i32, txt: [*:0]const u8) void; | 285 | extern fn ___tracy_emit_logStringL(severity: MessageSeverity, color: i32, callstack_depth: i32, txt: [*:0]const u8) void; |
| 330 | extern fn ___tracy_emit_frame_mark(name: ?[*:0]const u8) void; | 286 | extern fn ___tracy_emit_plot_int(name: [*:0]const u8, val: i64) void; |
| 287 | extern fn ___tracy_emit_plot_config(name: [*:0]const u8, format: PlotConfig.Format, mode: PlotConfig.Mode, fill: i32, color: u32) void; | ||
| 331 | extern fn ___tracy_fiber_enter(fiber: [*:0]const u8) void; | 288 | extern fn ___tracy_fiber_enter(fiber: [*:0]const u8) void; |
| 332 | extern fn ___tracy_fiber_leave() void; | 289 | extern fn ___tracy_fiber_leave() void; |
| 333 | 290 |