| ... | ... | @@ -131,6 +131,8 @@ pub fn updateFunc(self: *Plan9, module: *Module, func: *Module.Fn, air: Air, liv |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | const decl = func.owner_decl; |
| 134 | |
| 135 | try self.seeDecl(decl); |
| 134 | 136 | log.debug("codegen decl {*} ({s})", .{ decl, decl.name }); |
| 135 | 137 | |
| 136 | 138 | var code_buffer = std.ArrayList(u8).init(self.base.allocator); |
| ... | ... | @@ -176,6 +178,8 @@ pub fn updateDecl(self: *Plan9, module: *Module, decl: *Module.Decl) !void { |
| 176 | 178 | } |
| 177 | 179 | } |
| 178 | 180 | |
| 181 | try self.seeDecl(decl); |
| 182 | |
| 179 | 183 | log.debug("codegen decl {*} ({s})", .{ decl, decl.name }); |
| 180 | 184 | |
| 181 | 185 | var code_buffer = std.ArrayList(u8).init(self.base.allocator); |
| ... | ... | @@ -407,12 +411,24 @@ pub fn freeDecl(self: *Plan9, decl: *Module.Decl) void { |
| 407 | 411 | } |
| 408 | 412 | } |
| 409 | 413 | |
| 414 | pub fn seeDecl(self: *Plan9, decl: *Module.Decl) !void { |
| 415 | if (decl.link.plan9.got_index == null) { |
| 416 | if (self.got_index_free_list.popOrNull()) |i| { |
| 417 | decl.link.plan9.got_index = i; |
| 418 | } else { |
| 419 | self.got_len += 1; |
| 420 | decl.link.plan9.got_index = self.got_len - 1; |
| 421 | } |
| 422 | } |
| 423 | } |
| 424 | |
| 410 | 425 | pub fn updateDeclExports( |
| 411 | 426 | self: *Plan9, |
| 412 | 427 | module: *Module, |
| 413 | 428 | decl: *Module.Decl, |
| 414 | 429 | exports: []const *Module.Export, |
| 415 | 430 | ) !void { |
| 431 | try self.seeDecl(decl); |
| 416 | 432 | // we do all the things in flush |
| 417 | 433 | _ = self; |
| 418 | 434 | _ = module; |
| ... | ... | @@ -494,13 +510,8 @@ pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void { |
| 494 | 510 | } |
| 495 | 511 | } |
| 496 | 512 | |
| 513 | /// this will be removed, moved to updateFinish |
| 497 | 514 | pub fn allocateDeclIndexes(self: *Plan9, decl: *Module.Decl) !void { |
| 498 | | if (decl.link.plan9.got_index == null) { |
| 499 | | if (self.got_index_free_list.popOrNull()) |i| { |
| 500 | | decl.link.plan9.got_index = i; |
| 501 | | } else { |
| 502 | | self.got_len += 1; |
| 503 | | decl.link.plan9.got_index = self.got_len - 1; |
| 504 | | } |
| 505 | | } |
| 515 | _ = self; |
| 516 | _ = decl; |
| 506 | 517 | } |