aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Module.zig26
-rw-r--r--src/Sema.zig1
-rw-r--r--src/link.zig35
-rw-r--r--src/link/Plan9.zig9
4 files changed, 5 insertions, 66 deletions
diff --git a/src/Module.zig b/src/Module.zig
index 713680c5fa..dcdbeec322 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -4585,7 +4585,6 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !bool {
// We don't fully codegen the decl until later, but we do need to reserve a global
// offset table index for it. This allows us to codegen decls out of dependency
// order, increasing how many computations can be done in parallel.
- try mod.comp.bin_file.allocateDeclIndexes(decl_index);
try mod.comp.work_queue.writeItem(.{ .codegen_func = func });
if (type_changed and mod.emit_h != null) {
try mod.comp.work_queue.writeItem(.{ .emit_h_decl = decl_index });
@@ -4697,7 +4696,6 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !bool {
// codegen backend wants full access to the Decl Type.
try sema.resolveTypeFully(decl.ty);
- try mod.comp.bin_file.allocateDeclIndexes(decl_index);
try mod.comp.work_queue.writeItem(.{ .codegen_decl = decl_index });
if (type_changed and mod.emit_h != null) {
@@ -5315,29 +5313,6 @@ pub fn deleteUnusedDecl(mod: *Module, decl_index: Decl.Index) void {
const decl = mod.declPtr(decl_index);
log.debug("deleteUnusedDecl {d} ({s})", .{ decl_index, decl.name });
- // TODO: remove `allocateDeclIndexes` and make the API that the linker backends
- // are required to notice the first time `updateDecl` happens and keep track
- // of it themselves. However they can rely on getting a `freeDecl` call if any
- // `updateDecl` or `updateFunc` calls happen. This will allow us to avoid any call
- // into the linker backend here, since the linker backend will never have been told
- // about the Decl in the first place.
- // Until then, we did call `allocateDeclIndexes` on this anonymous Decl and so we
- // must call `freeDecl` in the linker backend now.
- switch (mod.comp.bin_file.tag) {
- .coff,
- .elf,
- .macho,
- .c,
- .wasm,
- => {}, // this linker backend has already migrated to the new API
-
- else => if (decl.has_tv) {
- if (decl.ty.isFnOrHasRuntimeBits()) {
- mod.comp.bin_file.freeDecl(decl_index);
- }
- },
- }
-
assert(!mod.declIsRoot(decl_index));
assert(decl.src_namespace.anon_decls.swapRemove(decl_index));
@@ -5822,7 +5797,6 @@ pub fn initNewAnonDecl(
// the Decl will be garbage collected by the `codegen_decl` task instead of sent
// to the linker.
if (typed_value.ty.isFnOrHasRuntimeBits()) {
- try mod.comp.bin_file.allocateDeclIndexes(new_decl_index);
try mod.comp.anon_work_queue.writeItem(.{ .codegen_decl = new_decl_index });
}
}
diff --git a/src/Sema.zig b/src/Sema.zig
index 2e57de2406..9c553a0092 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -7510,7 +7510,6 @@ fn resolveGenericInstantiationType(
// Queue up a `codegen_func` work item for the new Fn. The `comptime_args` field
// will be populated, ensuring it will have `analyzeBody` called with the ZIR
// parameters mapped appropriately.
- try mod.comp.bin_file.allocateDeclIndexes(new_decl_index);
try mod.comp.work_queue.writeItem(.{ .codegen_func = new_func });
return new_func;
}
diff --git a/src/link.zig b/src/link.zig
index f9081499a8..668c5b72e3 100644
--- a/src/link.zig
+++ b/src/link.zig
@@ -533,8 +533,7 @@ pub const File = struct {
}
}
- /// May be called before or after updateDeclExports but must be called
- /// after allocateDeclIndexes for any given Decl.
+ /// May be called before or after updateDeclExports for any given Decl.
pub fn updateDecl(base: *File, module: *Module, decl_index: Module.Decl.Index) UpdateDeclError!void {
const decl = module.declPtr(decl_index);
log.debug("updateDecl {*} ({s}), type={}", .{ decl, decl.name, decl.ty.fmtDebug() });
@@ -557,8 +556,7 @@ pub const File = struct {
}
}
- /// May be called before or after updateDeclExports but must be called
- /// after allocateDeclIndexes for any given Decl.
+ /// May be called before or after updateDeclExports for any given Decl.
pub fn updateFunc(base: *File, module: *Module, func: *Module.Fn, air: Air, liveness: Liveness) UpdateDeclError!void {
const owner_decl = module.declPtr(func.owner_decl);
log.debug("updateFunc {*} ({s}), type={}", .{
@@ -602,32 +600,6 @@ pub const File = struct {
}
}
- /// Must be called before any call to updateDecl or updateDeclExports for
- /// any given Decl.
- /// TODO we're transitioning to deleting this function and instead having
- /// each linker backend notice the first time updateDecl or updateFunc is called, or
- /// a callee referenced from AIR.
- pub fn allocateDeclIndexes(base: *File, decl_index: Module.Decl.Index) error{OutOfMemory}!void {
- const decl = base.options.module.?.declPtr(decl_index);
- log.debug("allocateDeclIndexes {*} ({s})", .{ decl, decl.name });
- if (build_options.only_c) {
- assert(base.tag == .c);
- return;
- }
- switch (base.tag) {
- .plan9 => return @fieldParentPtr(Plan9, "base", base).allocateDeclIndexes(decl_index),
-
- .coff,
- .elf,
- .macho,
- .c,
- .spirv,
- .nvptx,
- .wasm,
- => {},
- }
- }
-
pub fn releaseLock(self: *File) void {
if (self.lock) |*lock| {
lock.release();
@@ -878,8 +850,7 @@ pub const File = struct {
AnalysisFail,
};
- /// May be called before or after updateDecl, but must be called after
- /// allocateDeclIndexes for any given Decl.
+ /// May be called before or after updateDecl for any given Decl.
pub fn updateDeclExports(
base: *File,
module: *Module,
diff --git a/src/link/Plan9.zig b/src/link/Plan9.zig
index e412c78f7f..a8b8caafab 100644
--- a/src/link/Plan9.zig
+++ b/src/link/Plan9.zig
@@ -424,7 +424,7 @@ fn updateFinish(self: *Plan9, decl: *Module.Decl) !void {
// write the internal linker metadata
decl.link.plan9.type = sym_t;
// write the symbol
- // we already have the got index because that got allocated in allocateDeclIndexes
+ // we already have the got index
const sym: aout.Sym = .{
.value = undefined, // the value of stuff gets filled in in flushModule
.type = decl.link.plan9.type,
@@ -737,7 +737,7 @@ fn addDeclExports(
pub fn freeDecl(self: *Plan9, decl_index: Module.Decl.Index) void {
// TODO audit the lifetimes of decls table entries. It's possible to get
- // allocateDeclIndexes and then freeDecl without any updateDecl in between.
+ // freeDecl without any updateDecl in between.
// However that is planned to change, see the TODO comment in Module.zig
// in the deleteUnusedDecl function.
const mod = self.base.options.module.?;
@@ -959,11 +959,6 @@ pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void {
}
}
-/// this will be removed, moved to updateFinish
-pub fn allocateDeclIndexes(self: *Plan9, decl_index: Module.Decl.Index) !void {
- _ = self;
- _ = decl_index;
-}
/// Must be called only after a successful call to `updateDecl`.
pub fn updateDeclLineNumber(self: *Plan9, mod: *Module, decl: *const Module.Decl) !void {
_ = self;