authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-12-31 04:58:00-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 13:38:30-08:00
log3f2a65594e1d3c0a4f4943a4ea522e8405db81e0
treed93d69c0a60cf7d8c695f9d434b114c57005257f
parent4129996211edd30b25c23454520fd78b2a70394b

Compilation: cleanup hashmap usage


5 files changed, 105 insertions(+), 152 deletions(-)

src/Compilation.zig+80-120
...@@ -410,22 +410,15 @@ pub const CObject = struct {...@@ -410,22 +410,15 @@ pub const CObject = struct {
410 }410 }
411411
412 pub const Bundle = struct {412 pub const Bundle = struct {
413 file_names: std.AutoHashMapUnmanaged(u32, []const u8) = .{},413 file_names: std.AutoArrayHashMapUnmanaged(u32, []const u8) = .{},
414 category_names: std.AutoHashMapUnmanaged(u32, []const u8) = .{},414 category_names: std.AutoArrayHashMapUnmanaged(u32, []const u8) = .{},
415 diags: []Diag = &.{},415 diags: []Diag = &.{},
416416
417 pub fn destroy(bundle: *Bundle, gpa: Allocator) void {417 pub fn destroy(bundle: *Bundle, gpa: Allocator) void {
418 var file_name_it = bundle.file_names.valueIterator();418 for (bundle.file_names.values()) |file_name| gpa.free(file_name);
419 while (file_name_it.next()) |file_name| gpa.free(file_name.*);419 for (bundle.category_names.values()) |category_name| gpa.free(category_name);
420 bundle.file_names.deinit(gpa);
421
422 var category_name_it = bundle.category_names.valueIterator();
423 while (category_name_it.next()) |category_name| gpa.free(category_name.*);
424 bundle.category_names.deinit(gpa);
425
426 for (bundle.diags) |*diag| diag.deinit(gpa);420 for (bundle.diags) |*diag| diag.deinit(gpa);
427 gpa.free(bundle.diags);421 gpa.free(bundle.diags);
428
429 gpa.destroy(bundle);422 gpa.destroy(bundle);
430 }423 }
431424
...@@ -470,17 +463,15 @@ pub const CObject = struct {...@@ -470,17 +463,15 @@ pub const CObject = struct {
470 var bc = BitcodeReader.init(gpa, .{ .reader = reader.any() });463 var bc = BitcodeReader.init(gpa, .{ .reader = reader.any() });
471 defer bc.deinit();464 defer bc.deinit();
472465
473 var file_names: std.AutoHashMapUnmanaged(u32, []const u8) = .{};466 var file_names: std.AutoArrayHashMapUnmanaged(u32, []const u8) = .{};
474 errdefer {467 errdefer {
475 var file_name_it = file_names.valueIterator();468 for (file_names.values()) |file_name| gpa.free(file_name);
476 while (file_name_it.next()) |file_name| gpa.free(file_name.*);
477 file_names.deinit(gpa);469 file_names.deinit(gpa);
478 }470 }
479471
480 var category_names: std.AutoHashMapUnmanaged(u32, []const u8) = .{};472 var category_names: std.AutoArrayHashMapUnmanaged(u32, []const u8) = .{};
481 errdefer {473 errdefer {
482 var category_name_it = category_names.valueIterator();474 for (category_names.values()) |category_name| gpa.free(category_name);
483 while (category_name_it.next()) |category_name| gpa.free(category_name.*);
484 category_names.deinit(gpa);475 category_names.deinit(gpa);
485 }476 }
486477
...@@ -1014,46 +1005,39 @@ fn addModuleTableToCacheHash(...@@ -1014,46 +1005,39 @@ fn addModuleTableToCacheHash(
1014) (error{OutOfMemory} || std.os.GetCwdError)!void {1005) (error{OutOfMemory} || std.os.GetCwdError)!void {
1015 const allocator = arena.allocator();1006 const allocator = arena.allocator();
10161007
1017 const modules = try allocator.alloc(Package.Module.Deps.KV, mod_table.count());1008 const module_indices = try allocator.alloc(u32, mod_table.count());
1018 {1009 // Copy over the hashmap entries to our slice
1019 // Copy over the hashmap entries to our slice1010 for (module_indices, 0..) |*module_index, index| module_index.* = @intCast(index);
1020 var table_it = mod_table.iterator();
1021 var idx: usize = 0;
1022 while (table_it.next()) |entry| : (idx += 1) {
1023 modules[idx] = .{
1024 .key = entry.key_ptr.*,
1025 .value = entry.value_ptr.*,
1026 };
1027 }
1028 }
1029 // Sort the slice by package name1011 // Sort the slice by package name
1030 mem.sortUnstable(Package.Module.Deps.KV, modules, {}, struct {1012 mem.sortUnstable(u32, module_indices, &mod_table, struct {
1031 fn lessThan(_: void, lhs: Package.Module.Deps.KV, rhs: Package.Module.Deps.KV) bool {1013 fn lessThan(deps: *const Package.Module.Deps, lhs: u32, rhs: u32) bool {
1032 return std.mem.lessThan(u8, lhs.key, rhs.key);1014 const keys = deps.keys();
1015 return std.mem.lessThan(u8, keys[lhs], keys[rhs]);
1033 }1016 }
1034 }.lessThan);1017 }.lessThan);
10351018
1036 for (modules) |mod| {1019 for (module_indices) |module_index| {
1037 if ((try seen_table.getOrPut(mod.value)).found_existing) continue;1020 const module = mod_table.values()[module_index];
1021 if ((try seen_table.getOrPut(module)).found_existing) continue;
10381022
1039 // Finally insert the package name and path to the cache hash.1023 // Finally insert the package name and path to the cache hash.
1040 hash.addBytes(mod.key);1024 hash.addBytes(mod_table.keys()[module_index]);
1041 switch (hash_type) {1025 switch (hash_type) {
1042 .path_bytes => {1026 .path_bytes => {
1043 hash.addBytes(mod.value.root_src_path);1027 hash.addBytes(module.root_src_path);
1044 hash.addOptionalBytes(mod.value.root.root_dir.path);1028 hash.addOptionalBytes(module.root.root_dir.path);
1045 hash.addBytes(mod.value.root.sub_path);1029 hash.addBytes(module.root.sub_path);
1046 },1030 },
1047 .files => |man| {1031 .files => |man| {
1048 const pkg_zig_file = try mod.value.root.joinString(1032 const pkg_zig_file = try module.root.joinString(
1049 allocator,1033 allocator,
1050 mod.value.root_src_path,1034 module.root_src_path,
1051 );1035 );
1052 _ = try man.addFile(pkg_zig_file, null);1036 _ = try man.addFile(pkg_zig_file, null);
1053 },1037 },
1054 }1038 }
1055 // Recurse to handle the module's dependencies1039 // Recurse to handle the module's dependencies
1056 try addModuleTableToCacheHash(hash, arena, mod.value.deps, seen_table, hash_type);1040 try addModuleTableToCacheHash(hash, arena, module.deps, seen_table, hash_type);
1057 }1041 }
1058}1042}
10591043
...@@ -2260,8 +2244,8 @@ pub fn destroy(self: *Compilation) void {...@@ -2260,8 +2244,8 @@ pub fn destroy(self: *Compilation) void {
2260 }2244 }
2261 self.c_object_table.deinit(gpa);2245 self.c_object_table.deinit(gpa);
22622246
2263 for (self.failed_c_objects.values()) |value| {2247 for (self.failed_c_objects.values()) |bundle| {
2264 value.destroy(gpa);2248 bundle.destroy(gpa);
2265 }2249 }
2266 self.failed_c_objects.deinit(gpa);2250 self.failed_c_objects.deinit(gpa);
22672251
...@@ -2483,13 +2467,9 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void...@@ -2483,13 +2467,9 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
2483 }2467 }
24842468
2485 // Put a work item in for checking if any files used with `@embedFile` changed.2469 // Put a work item in for checking if any files used with `@embedFile` changed.
2486 {2470 try comp.embed_file_work_queue.ensureUnusedCapacity(module.embed_table.count());
2487 try comp.embed_file_work_queue.ensureUnusedCapacity(module.embed_table.count());2471 for (module.embed_table.values()) |embed_file| {
2488 var it = module.embed_table.iterator();2472 comp.embed_file_work_queue.writeItemAssumeCapacity(embed_file);
2489 while (it.next()) |entry| {
2490 const embed_file = entry.value_ptr.*;
2491 comp.embed_file_work_queue.writeItemAssumeCapacity(embed_file);
2492 }
2493 }2473 }
24942474
2495 try comp.work_queue.writeItem(.{ .analyze_mod = std_mod });2475 try comp.work_queue.writeItem(.{ .analyze_mod = std_mod });
...@@ -3083,9 +3063,8 @@ pub fn totalErrorCount(self: *Compilation) u32 {...@@ -3083,9 +3063,8 @@ pub fn totalErrorCount(self: *Compilation) u32 {
3083 @intFromBool(self.alloc_failure_occurred) +3063 @intFromBool(self.alloc_failure_occurred) +
3084 self.lld_errors.items.len;3064 self.lld_errors.items.len;
30853065
3086 {3066 for (self.failed_c_objects.values()) |bundle| {
3087 var it = self.failed_c_objects.iterator();3067 total += bundle.diags.len;
3088 while (it.next()) |entry| total += entry.value_ptr.*.diags.len;
3089 }3068 }
30903069
3091 if (!build_options.only_core_functionality) {3070 if (!build_options.only_core_functionality) {
...@@ -3098,19 +3077,15 @@ pub fn totalErrorCount(self: *Compilation) u32 {...@@ -3098,19 +3077,15 @@ pub fn totalErrorCount(self: *Compilation) u32 {
3098 total += module.failed_exports.count();3077 total += module.failed_exports.count();
3099 total += module.failed_embed_files.count();3078 total += module.failed_embed_files.count();
31003079
3101 {3080 for (module.failed_files.keys(), module.failed_files.values()) |file, error_msg| {
3102 var it = module.failed_files.iterator();3081 if (error_msg) |_| {
3103 while (it.next()) |entry| {3082 total += 1;
3104 if (entry.value_ptr.*) |_| {3083 } else {
3105 total += 1;3084 assert(file.zir_loaded);
3106 } else {3085 const payload_index = file.zir.extra[@intFromEnum(Zir.ExtraIndex.compile_errors)];
3107 const file = entry.key_ptr.*;3086 assert(payload_index != 0);
3108 assert(file.zir_loaded);3087 const header = file.zir.extraData(Zir.Inst.CompileErrors, payload_index);
3109 const payload_index = file.zir.extra[@intFromEnum(Zir.ExtraIndex.compile_errors)];3088 total += header.data.items_len;
3110 assert(payload_index != 0);
3111 const header = file.zir.extraData(Zir.Inst.CompileErrors, payload_index);
3112 total += header.data.items_len;
3113 }
3114 }3089 }
3115 }3090 }
31163091
...@@ -3166,15 +3141,13 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {...@@ -3166,15 +3141,13 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {
3166 try bundle.init(gpa);3141 try bundle.init(gpa);
3167 defer bundle.deinit();3142 defer bundle.deinit();
31683143
3169 {3144 for (self.failed_c_objects.values()) |diag_bundle| {
3170 var it = self.failed_c_objects.iterator();3145 try diag_bundle.addToErrorBundle(&bundle);
3171 while (it.next()) |entry| try entry.value_ptr.*.addToErrorBundle(&bundle);
3172 }3146 }
31733147
3174 if (!build_options.only_core_functionality) {3148 if (!build_options.only_core_functionality) {
3175 var it = self.failed_win32_resources.iterator();3149 for (self.failed_win32_resources.values()) |error_bundle| {
3176 while (it.next()) |entry| {3150 try bundle.addBundleAsRoots(error_bundle);
3177 try bundle.addBundleAsRoots(entry.value_ptr.*);
3178 }3151 }
3179 }3152 }
31803153
...@@ -3205,65 +3178,52 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {...@@ -3205,65 +3178,52 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle {
3205 });3178 });
3206 }3179 }
3207 if (self.bin_file.options.module) |module| {3180 if (self.bin_file.options.module) |module| {
3208 {3181 for (module.failed_files.keys(), module.failed_files.values()) |file, error_msg| {
3209 var it = module.failed_files.iterator();3182 if (error_msg) |msg| {
3210 while (it.next()) |entry| {
3211 if (entry.value_ptr.*) |msg| {
3212 try addModuleErrorMsg(module, &bundle, msg.*);
3213 } else {
3214 // Must be ZIR errors. Note that this may include AST errors.
3215 // addZirErrorMessages asserts that the tree is loaded.
3216 _ = try entry.key_ptr.*.getTree(gpa);
3217 try addZirErrorMessages(&bundle, entry.key_ptr.*);
3218 }
3219 }
3220 }
3221 {
3222 var it = module.failed_embed_files.iterator();
3223 while (it.next()) |entry| {
3224 const msg = entry.value_ptr.*;
3225 try addModuleErrorMsg(module, &bundle, msg.*);3183 try addModuleErrorMsg(module, &bundle, msg.*);
3184 } else {
3185 // Must be ZIR errors. Note that this may include AST errors.
3186 // addZirErrorMessages asserts that the tree is loaded.
3187 _ = try file.getTree(gpa);
3188 try addZirErrorMessages(&bundle, file);
3226 }3189 }
3227 }3190 }
3228 {3191 for (module.failed_embed_files.values()) |error_msg| {
3229 var it = module.failed_decls.iterator();3192 try addModuleErrorMsg(module, &bundle, error_msg.*);
3230 while (it.next()) |entry| {3193 }
3231 const decl_index = entry.key_ptr.*;3194 for (module.failed_decls.keys(), module.failed_decls.values()) |decl_index, error_msg| {
3232 // Skip errors for Decls within files that had a parse failure.3195 // Skip errors for Decls within files that had a parse failure.
3233 // We'll try again once parsing succeeds.3196 // We'll try again once parsing succeeds.
3234 if (module.declFileScope(decl_index).okToReportErrors()) {3197 if (module.declFileScope(decl_index).okToReportErrors()) {
3235 try addModuleErrorMsg(module, &bundle, entry.value_ptr.*.*);3198 try addModuleErrorMsg(module, &bundle, error_msg.*);
3236 if (module.cimport_errors.get(entry.key_ptr.*)) |errors| {3199 if (module.cimport_errors.get(decl_index)) |errors| {
3237 for (errors.getMessages()) |err_msg_index| {3200 for (errors.getMessages()) |err_msg_index| {
3238 const err_msg = errors.getErrorMessage(err_msg_index);3201 const err_msg = errors.getErrorMessage(err_msg_index);
3239 try bundle.addRootErrorMessage(.{3202 try bundle.addRootErrorMessage(.{
3240 .msg = try bundle.addString(errors.nullTerminatedString(err_msg.msg)),3203 .msg = try bundle.addString(errors.nullTerminatedString(err_msg.msg)),
3241 .src_loc = if (err_msg.src_loc != .none) blk: {3204 .src_loc = if (err_msg.src_loc != .none) blk: {
3242 const src_loc = errors.getSourceLocation(err_msg.src_loc);3205 const src_loc = errors.getSourceLocation(err_msg.src_loc);
3243 break :blk try bundle.addSourceLocation(.{3206 break :blk try bundle.addSourceLocation(.{
3244 .src_path = try bundle.addString(errors.nullTerminatedString(src_loc.src_path)),3207 .src_path = try bundle.addString(errors.nullTerminatedString(src_loc.src_path)),
3245 .span_start = src_loc.span_start,3208 .span_start = src_loc.span_start,
3246 .span_main = src_loc.span_main,3209 .span_main = src_loc.span_main,
3247 .span_end = src_loc.span_end,3210 .span_end = src_loc.span_end,
3248 .line = src_loc.line,3211 .line = src_loc.line,
3249 .column = src_loc.column,3212 .column = src_loc.column,
3250 .source_line = if (src_loc.source_line != 0) try bundle.addString(errors.nullTerminatedString(src_loc.source_line)) else 0,3213 .source_line = if (src_loc.source_line != 0) try bundle.addString(errors.nullTerminatedString(src_loc.source_line)) else 0,
3251 });3214 });
3252 } else .none,3215 } else .none,
3253 });3216 });
3254 }
3255 }3217 }
3256 }3218 }
3257 }3219 }
3258 }3220 }
3259 if (module.emit_h) |emit_h| {3221 if (module.emit_h) |emit_h| {
3260 var it = emit_h.failed_decls.iterator();3222 for (emit_h.failed_decls.keys(), emit_h.failed_decls.values()) |decl_index, error_msg| {
3261 while (it.next()) |entry| {
3262 const decl_index = entry.key_ptr.*;
3263 // Skip errors for Decls within files that had a parse failure.3223 // Skip errors for Decls within files that had a parse failure.
3264 // We'll try again once parsing succeeds.3224 // We'll try again once parsing succeeds.
3265 if (module.declFileScope(decl_index).okToReportErrors()) {3225 if (module.declFileScope(decl_index).okToReportErrors()) {
3266 try addModuleErrorMsg(module, &bundle, entry.value_ptr.*.*);3226 try addModuleErrorMsg(module, &bundle, error_msg.*);
3267 }3227 }
3268 }3228 }
3269 }3229 }
src/Module.zig+18-25
...@@ -87,7 +87,7 @@ import_table: std.StringArrayHashMapUnmanaged(*File) = .{},...@@ -87,7 +87,7 @@ import_table: std.StringArrayHashMapUnmanaged(*File) = .{},
87/// modified on the file system when an update is requested, as well as to cache87/// modified on the file system when an update is requested, as well as to cache
88/// `@embedFile` results.88/// `@embedFile` results.
89/// Keys are fully resolved file paths. This table owns the keys and values.89/// Keys are fully resolved file paths. This table owns the keys and values.
90embed_table: std.StringHashMapUnmanaged(*EmbedFile) = .{},90embed_table: std.StringArrayHashMapUnmanaged(*EmbedFile) = .{},
9191
92/// Stores all Type and Value objects.92/// Stores all Type and Value objects.
93/// The idea is that this will be periodically garbage-collected, but such logic93/// The idea is that this will be periodically garbage-collected, but such logic
...@@ -2482,15 +2482,11 @@ pub fn deinit(mod: *Module) void {...@@ -2482,15 +2482,11 @@ pub fn deinit(mod: *Module) void {
2482 }2482 }
2483 mod.import_table.deinit(gpa);2483 mod.import_table.deinit(gpa);
24842484
2485 {2485 for (mod.embed_table.keys(), mod.embed_table.values()) |path, embed_file| {
2486 var it = mod.embed_table.iterator();2486 gpa.free(path);
2487 while (it.next()) |entry| {2487 gpa.destroy(embed_file);
2488 gpa.free(entry.key_ptr.*);
2489 const ef: *EmbedFile = entry.value_ptr.*;
2490 gpa.destroy(ef);
2491 }
2492 mod.embed_table.deinit(gpa);
2493 }2488 }
2489 mod.embed_table.deinit(gpa);
24942490
2495 mod.compile_log_text.deinit(gpa);2491 mod.compile_log_text.deinit(gpa);
24962492
...@@ -4035,7 +4031,7 @@ pub fn embedFile(...@@ -4035,7 +4031,7 @@ pub fn embedFile(
40354031
4036 const gop = try mod.embed_table.getOrPut(gpa, resolved_path);4032 const gop = try mod.embed_table.getOrPut(gpa, resolved_path);
4037 errdefer {4033 errdefer {
4038 assert(mod.embed_table.remove(resolved_path));4034 assert(std.mem.eql(u8, mod.embed_table.pop().key, resolved_path));
4039 keep_resolved_path = false;4035 keep_resolved_path = false;
4040 }4036 }
4041 if (gop.found_existing) return gop.value_ptr.*.val;4037 if (gop.found_existing) return gop.value_ptr.*.val;
...@@ -4044,7 +4040,7 @@ pub fn embedFile(...@@ -4044,7 +4040,7 @@ pub fn embedFile(
4044 const sub_file_path = try gpa.dupe(u8, pkg.root_src_path);4040 const sub_file_path = try gpa.dupe(u8, pkg.root_src_path);
4045 errdefer gpa.free(sub_file_path);4041 errdefer gpa.free(sub_file_path);
40464042
4047 return newEmbedFile(mod, pkg, sub_file_path, resolved_path, gop, src_loc);4043 return newEmbedFile(mod, pkg, sub_file_path, resolved_path, gop.value_ptr, src_loc);
4048 }4044 }
40494045
4050 // The resolved path is used as the key in the table, to detect if a file4046 // The resolved path is used as the key in the table, to detect if a file
...@@ -4062,7 +4058,7 @@ pub fn embedFile(...@@ -4062,7 +4058,7 @@ pub fn embedFile(
40624058
4063 const gop = try mod.embed_table.getOrPut(gpa, resolved_path);4059 const gop = try mod.embed_table.getOrPut(gpa, resolved_path);
4064 errdefer {4060 errdefer {
4065 assert(mod.embed_table.remove(resolved_path));4061 assert(std.mem.eql(u8, mod.embed_table.pop().key, resolved_path));
4066 keep_resolved_path = false;4062 keep_resolved_path = false;
4067 }4063 }
4068 if (gop.found_existing) return gop.value_ptr.*.val;4064 if (gop.found_existing) return gop.value_ptr.*.val;
...@@ -4089,7 +4085,7 @@ pub fn embedFile(...@@ -4089,7 +4085,7 @@ pub fn embedFile(
4089 };4085 };
4090 defer gpa.free(sub_file_path);4086 defer gpa.free(sub_file_path);
40914087
4092 return newEmbedFile(mod, cur_file.mod, sub_file_path, resolved_path, gop, src_loc);4088 return newEmbedFile(mod, cur_file.mod, sub_file_path, resolved_path, gop.value_ptr, src_loc);
4093}4089}
40944090
4095/// https://github.com/ziglang/zig/issues/143074091/// https://github.com/ziglang/zig/issues/14307
...@@ -4098,7 +4094,7 @@ fn newEmbedFile(...@@ -4098,7 +4094,7 @@ fn newEmbedFile(
4098 pkg: *Package.Module,4094 pkg: *Package.Module,
4099 sub_file_path: []const u8,4095 sub_file_path: []const u8,
4100 resolved_path: []const u8,4096 resolved_path: []const u8,
4101 gop: std.StringHashMapUnmanaged(*EmbedFile).GetOrPutResult,4097 result: **EmbedFile,
4102 src_loc: SrcLoc,4098 src_loc: SrcLoc,
4103) !InternPool.Index {4099) !InternPool.Index {
4104 const gpa = mod.gpa;4100 const gpa = mod.gpa;
...@@ -4154,7 +4150,7 @@ fn newEmbedFile(...@@ -4154,7 +4150,7 @@ fn newEmbedFile(
4154 } },4150 } },
4155 } });4151 } });
41564152
4157 gop.value_ptr.* = new_file;4153 result.* = new_file;
4158 new_file.* = .{4154 new_file.* = .{
4159 .sub_file_path = try ip.getOrPutString(gpa, sub_file_path),4155 .sub_file_path = try ip.getOrPutString(gpa, sub_file_path),
4160 .owner = pkg,4156 .owner = pkg,
...@@ -4621,16 +4617,13 @@ pub fn analyzeFnBody(mod: *Module, func_index: InternPool.Index, arena: Allocato...@@ -4621,16 +4617,13 @@ pub fn analyzeFnBody(mod: *Module, func_index: InternPool.Index, arena: Allocato
4621 else => |e| return e,4617 else => |e| return e,
4622 };4618 };
46234619
4624 {4620 for (sema.unresolved_inferred_allocs.keys()) |ptr_inst| {
4625 var it = sema.unresolved_inferred_allocs.keyIterator();4621 // The lack of a resolve_inferred_alloc means that this instruction
4626 while (it.next()) |ptr_inst| {4622 // is unused so it just has to be a no-op.
4627 // The lack of a resolve_inferred_alloc means that this instruction4623 sema.air_instructions.set(@intFromEnum(ptr_inst), .{
4628 // is unused so it just has to be a no-op.4624 .tag = .alloc,
4629 sema.air_instructions.set(@intFromEnum(ptr_inst.*), .{4625 .data = .{ .ty = Type.single_const_pointer_to_comptime_int },
4630 .tag = .alloc,4626 });
4631 .data = .{ .ty = Type.single_const_pointer_to_comptime_int },
4632 });
4633 }
4634 }4627 }
46354628
4636 // If we don't get an error return trace from a caller, create our own.4629 // If we don't get an error return trace from a caller, create our own.
src/Package/Module.zig+1-1
...@@ -14,7 +14,7 @@ fully_qualified_name: []const u8,...@@ -14,7 +14,7 @@ fully_qualified_name: []const u8,
14/// responsible for detecting these names and using the correct package.14/// responsible for detecting these names and using the correct package.
15deps: Deps = .{},15deps: Deps = .{},
1616
17pub const Deps = std.StringHashMapUnmanaged(*Module);17pub const Deps = std.StringArrayHashMapUnmanaged(*Module);
1818
19pub const Tree = struct {19pub const Tree = struct {
20 /// Each `Package` exposes a `Module` with build.zig as its root source file.20 /// Each `Package` exposes a `Module` with build.zig as its root source file.
src/Sema.zig+2-2
...@@ -93,7 +93,7 @@ no_partial_func_ty: bool = false,...@@ -93,7 +93,7 @@ no_partial_func_ty: bool = false,
9393
94/// The temporary arena is used for the memory of the `InferredAlloc` values94/// The temporary arena is used for the memory of the `InferredAlloc` values
95/// here so the values can be dropped without any cleanup.95/// here so the values can be dropped without any cleanup.
96unresolved_inferred_allocs: std.AutoHashMapUnmanaged(Air.Inst.Index, InferredAlloc) = .{},96unresolved_inferred_allocs: std.AutoArrayHashMapUnmanaged(Air.Inst.Index, InferredAlloc) = .{},
9797
98/// Indices of comptime-mutable decls created by this Sema. These decls' values98/// Indices of comptime-mutable decls created by this Sema. These decls' values
99/// should be interned after analysis completes, as they may refer to memory in99/// should be interned after analysis completes, as they may refer to memory in
...@@ -4040,7 +4040,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com...@@ -4040,7 +4040,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
4040 },4040 },
4041 .inferred_alloc => {4041 .inferred_alloc => {
4042 const ia1 = sema.air_instructions.items(.data)[@intFromEnum(ptr_inst)].inferred_alloc;4042 const ia1 = sema.air_instructions.items(.data)[@intFromEnum(ptr_inst)].inferred_alloc;
4043 const ia2 = sema.unresolved_inferred_allocs.fetchRemove(ptr_inst).?.value;4043 const ia2 = sema.unresolved_inferred_allocs.fetchSwapRemove(ptr_inst).?.value;
4044 const peer_vals = try sema.arena.alloc(Air.Inst.Ref, ia2.prongs.items.len);4044 const peer_vals = try sema.arena.alloc(Air.Inst.Ref, ia2.prongs.items.len);
4045 for (peer_vals, ia2.prongs.items) |*peer_val, store_inst| {4045 for (peer_vals, ia2.prongs.items) |*peer_val, store_inst| {
4046 assert(sema.air_instructions.items(.tag)[@intFromEnum(store_inst)] == .store);4046 assert(sema.air_instructions.items(.tag)[@intFromEnum(store_inst)] == .store);
src/codegen/llvm.zig+4-4
...@@ -9597,9 +9597,9 @@ pub const FuncGen = struct {...@@ -9597,9 +9597,9 @@ pub const FuncGen = struct {
9597 try wip.@"switch"(tag_int_value, bad_value_block, @intCast(enum_type.names.len));9597 try wip.@"switch"(tag_int_value, bad_value_block, @intCast(enum_type.names.len));
9598 defer wip_switch.finish(&wip);9598 defer wip_switch.finish(&wip);
95999599
9600 for (enum_type.names.get(ip), 0..) |name, field_index| {9600 for (0..enum_type.names.len) |field_index| {
9601 const name_string = try o.builder.string(ip.stringToSlice(name));9601 const name = try o.builder.string(ip.stringToSlice(enum_type.names.get(ip)[field_index]));
9602 const name_init = try o.builder.stringNullConst(name_string);9602 const name_init = try o.builder.stringNullConst(name);
9603 const name_variable_index =9603 const name_variable_index =
9604 try o.builder.addVariable(.empty, name_init.typeOf(&o.builder), .default);9604 try o.builder.addVariable(.empty, name_init.typeOf(&o.builder), .default);
9605 try name_variable_index.setInitializer(name_init, &o.builder);9605 try name_variable_index.setInitializer(name_init, &o.builder);
...@@ -9610,7 +9610,7 @@ pub const FuncGen = struct {...@@ -9610,7 +9610,7 @@ pub const FuncGen = struct {
96109610
9611 const name_val = try o.builder.structValue(ret_ty, &.{9611 const name_val = try o.builder.structValue(ret_ty, &.{
9612 name_variable_index.toConst(&o.builder),9612 name_variable_index.toConst(&o.builder),
9613 try o.builder.intConst(usize_ty, name_string.slice(&o.builder).?.len),9613 try o.builder.intConst(usize_ty, name.slice(&o.builder).?.len),
9614 });9614 });
96159615
9616 const return_block = try wip.block(1, "Name");9616 const return_block = try wip.block(1, "Name");