authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-03 23:47:54-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-03 23:47:54-07:00
log30ee08dfc2236a9c25826dbde82f9865bae5cf30
treec5bebd3c52412abf20f8520e0284f4f61dd303e3
parentcb25d8e4bc78d6fe21e0cb0b979aa8250a086c2e

stage2: stop needlessly re-analyzing unchanged functions


2 files changed, 14 insertions(+), 9 deletions(-)

src-self-hosted/Module.zig+3-5
......@@ -1108,11 +1108,9 @@ pub fn ensureDeclAnalyzed(self: *Module, decl: *Decl) InnerError!void {
11081108 .codegen_failure_retryable,
11091109 => return error.AnalysisFail,
11101110
1111 .complete, .outdated => blk: {
1112 if (decl.generation == self.generation) {
1113 assert(decl.analysis == .complete);
1114 return;
1115 }
1111 .complete => return,
1112
1113 .outdated => blk: {
11161114 log.debug(.module, "re-analyzing {}\n", .{decl.name});
11171115
11181116 // The exports this Decl performs will be re-discovered, so we remove them here
src-self-hosted/link.zig+11-4
......@@ -1324,7 +1324,7 @@ pub const File = struct {
13241324 shstrtab_sect.sh_offset = self.findFreeSpace(needed_size, 1);
13251325 }
13261326 shstrtab_sect.sh_size = needed_size;
1327 log.debug(.link, "shstrtab start=0x{x} end=0x{x}\n", .{ shstrtab_sect.sh_offset, shstrtab_sect.sh_offset + needed_size });
1327 log.debug(.link, "writing shstrtab start=0x{x} end=0x{x}\n", .{ shstrtab_sect.sh_offset, shstrtab_sect.sh_offset + needed_size });
13281328
13291329 try self.file.?.pwriteAll(self.shstrtab.items, shstrtab_sect.sh_offset);
13301330 if (!self.shdr_table_dirty) {
......@@ -1980,11 +1980,17 @@ pub const File = struct {
19801980 src_fn.off = self.dbgLineNeededHeaderBytes() * alloc_num / alloc_den;
19811981 }
19821982
1983 const needed_size = src_fn.off + src_fn.len;
1983 const last_src_fn = self.dbg_line_fn_last.?;
1984 const needed_size = last_src_fn.off + last_src_fn.len;
19841985 if (needed_size != debug_line_sect.sh_size) {
19851986 if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) {
19861987 const new_offset = self.findFreeSpace(needed_size, 1);
1987 const existing_size = src_fn.off;
1988 const existing_size = last_src_fn.off;
1989 log.debug(.link, "moving .debug_line section: {} bytes from 0x{x} to 0x{x}\n", .{
1990 existing_size,
1991 debug_line_sect.sh_offset,
1992 new_offset,
1993 });
19881994 const amt = try self.file.?.copyRangeAll(debug_line_sect.sh_offset, self.file.?, new_offset, existing_size);
19891995 if (amt != existing_size) return error.InputOutput;
19901996 debug_line_sect.sh_offset = new_offset;
......@@ -2112,7 +2118,6 @@ pub const File = struct {
21122118
21132119 fn writeSectHeader(self: *Elf, index: usize) !void {
21142120 const foreign_endian = self.base.options.target.cpu.arch.endian() != std.Target.current.cpu.arch.endian();
2115 const offset = self.sections.items[index].sh_offset;
21162121 switch (self.base.options.target.cpu.arch.ptrBitWidth()) {
21172122 32 => {
21182123 var shdr: [1]elf.Elf32_Shdr = undefined;
......@@ -2120,6 +2125,7 @@ pub const File = struct {
21202125 if (foreign_endian) {
21212126 bswapAllFields(elf.Elf32_Shdr, &shdr[0]);
21222127 }
2128 const offset = self.shdr_table_offset.? + index * @sizeOf(elf.Elf32_Shdr);
21232129 return self.file.?.pwriteAll(mem.sliceAsBytes(&shdr), offset);
21242130 },
21252131 64 => {
......@@ -2127,6 +2133,7 @@ pub const File = struct {
21272133 if (foreign_endian) {
21282134 bswapAllFields(elf.Elf64_Shdr, &shdr[0]);
21292135 }
2136 const offset = self.shdr_table_offset.? + index * @sizeOf(elf.Elf64_Shdr);
21302137 return self.file.?.pwriteAll(mem.sliceAsBytes(&shdr), offset);
21312138 },
21322139 else => return error.UnsupportedArchitecture,