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 {...@@ -1108,11 +1108,9 @@ pub fn ensureDeclAnalyzed(self: *Module, decl: *Decl) InnerError!void {
1108 .codegen_failure_retryable,1108 .codegen_failure_retryable,
1109 => return error.AnalysisFail,1109 => return error.AnalysisFail,
11101110
1111 .complete, .outdated => blk: {1111 .complete => return,
1112 if (decl.generation == self.generation) {1112
1113 assert(decl.analysis == .complete);1113 .outdated => blk: {
1114 return;
1115 }
1116 log.debug(.module, "re-analyzing {}\n", .{decl.name});1114 log.debug(.module, "re-analyzing {}\n", .{decl.name});
11171115
1118 // The exports this Decl performs will be re-discovered, so we remove them here1116 // 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 {...@@ -1324,7 +1324,7 @@ pub const File = struct {
1324 shstrtab_sect.sh_offset = self.findFreeSpace(needed_size, 1);1324 shstrtab_sect.sh_offset = self.findFreeSpace(needed_size, 1);
1325 }1325 }
1326 shstrtab_sect.sh_size = needed_size;1326 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
1329 try self.file.?.pwriteAll(self.shstrtab.items, shstrtab_sect.sh_offset);1329 try self.file.?.pwriteAll(self.shstrtab.items, shstrtab_sect.sh_offset);
1330 if (!self.shdr_table_dirty) {1330 if (!self.shdr_table_dirty) {
...@@ -1980,11 +1980,17 @@ pub const File = struct {...@@ -1980,11 +1980,17 @@ pub const File = struct {
1980 src_fn.off = self.dbgLineNeededHeaderBytes() * alloc_num / alloc_den;1980 src_fn.off = self.dbgLineNeededHeaderBytes() * alloc_num / alloc_den;
1981 }1981 }
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;
1984 if (needed_size != debug_line_sect.sh_size) {1985 if (needed_size != debug_line_sect.sh_size) {
1985 if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) {1986 if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) {
1986 const new_offset = self.findFreeSpace(needed_size, 1);1987 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 });
1988 const amt = try self.file.?.copyRangeAll(debug_line_sect.sh_offset, self.file.?, new_offset, existing_size);1994 const amt = try self.file.?.copyRangeAll(debug_line_sect.sh_offset, self.file.?, new_offset, existing_size);
1989 if (amt != existing_size) return error.InputOutput;1995 if (amt != existing_size) return error.InputOutput;
1990 debug_line_sect.sh_offset = new_offset;1996 debug_line_sect.sh_offset = new_offset;
...@@ -2112,7 +2118,6 @@ pub const File = struct {...@@ -2112,7 +2118,6 @@ pub const File = struct {
21122118
2113 fn writeSectHeader(self: *Elf, index: usize) !void {2119 fn writeSectHeader(self: *Elf, index: usize) !void {
2114 const foreign_endian = self.base.options.target.cpu.arch.endian() != std.Target.current.cpu.arch.endian();2120 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;
2116 switch (self.base.options.target.cpu.arch.ptrBitWidth()) {2121 switch (self.base.options.target.cpu.arch.ptrBitWidth()) {
2117 32 => {2122 32 => {
2118 var shdr: [1]elf.Elf32_Shdr = undefined;2123 var shdr: [1]elf.Elf32_Shdr = undefined;
...@@ -2120,6 +2125,7 @@ pub const File = struct {...@@ -2120,6 +2125,7 @@ pub const File = struct {
2120 if (foreign_endian) {2125 if (foreign_endian) {
2121 bswapAllFields(elf.Elf32_Shdr, &shdr[0]);2126 bswapAllFields(elf.Elf32_Shdr, &shdr[0]);
2122 }2127 }
2128 const offset = self.shdr_table_offset.? + index * @sizeOf(elf.Elf32_Shdr);
2123 return self.file.?.pwriteAll(mem.sliceAsBytes(&shdr), offset);2129 return self.file.?.pwriteAll(mem.sliceAsBytes(&shdr), offset);
2124 },2130 },
2125 64 => {2131 64 => {
...@@ -2127,6 +2133,7 @@ pub const File = struct {...@@ -2127,6 +2133,7 @@ pub const File = struct {
2127 if (foreign_endian) {2133 if (foreign_endian) {
2128 bswapAllFields(elf.Elf64_Shdr, &shdr[0]);2134 bswapAllFields(elf.Elf64_Shdr, &shdr[0]);
2129 }2135 }
2136 const offset = self.shdr_table_offset.? + index * @sizeOf(elf.Elf64_Shdr);
2130 return self.file.?.pwriteAll(mem.sliceAsBytes(&shdr), offset);2137 return self.file.?.pwriteAll(mem.sliceAsBytes(&shdr), offset);
2131 },2138 },
2132 else => return error.UnsupportedArchitecture,2139 else => return error.UnsupportedArchitecture,