authorgravatar for timonkruiper@gmail.comTimon Kruiper <timonkruiper@gmail.com> 2020-12-24 11:40:54+01:00
committergravatar for timonkruiper@gmail.comTimon Kruiper <timonkruiper@gmail.com> 2020-12-28 21:20:49+01:00
log09cf043efd5966e328e4454bc30bc756f439938b
treebce231f261ec7a240aab48ffbd7fc65e89084811
parent6b8d28312ccca56d652af32bad360e9a5394fb8e

stage2: add missing asserts and early returns for LLVM backend


2 files changed, 7 insertions(+), 1 deletions(-)

src/link/Coff.zig+5
......@@ -413,6 +413,8 @@ pub fn createEmpty(gpa: *Allocator, options: link.Options) !*Coff {
413413}
414414
415415pub fn allocateDeclIndexes(self: *Coff, decl: *Module.Decl) !void {
416 if (self.llvm_ir_module) |_| return;
417
416418 try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1);
417419
418420 if (self.offset_table_free_list.popOrNull()) |i| {
......@@ -710,6 +712,8 @@ pub fn updateDecl(self: *Coff, module: *Module, decl: *Module.Decl) !void {
710712}
711713
712714pub fn freeDecl(self: *Coff, decl: *Module.Decl) void {
715 if (self.llvm_ir_module) |_| return;
716
713717 // Appending to free lists is allowed to fail because the free lists are heuristics based anyway.
714718 self.freeTextBlock(&decl.link.coff);
715719 self.offset_table_free_list.append(self.base.allocator, decl.link.coff.offset_table_index) catch {};
......@@ -1245,6 +1249,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {
12451249}
12461250
12471251pub fn getDeclVAddr(self: *Coff, decl: *const Module.Decl) u64 {
1252 assert(self.llvm_ir_module == null);
12481253 return self.text_section_virtual_address + decl.link.coff.text_offset;
12491254}
12501255
src/link/Elf.zig+2-1
......@@ -318,6 +318,7 @@ pub fn deinit(self: *Elf) void {
318318}
319319
320320pub fn getDeclVAddr(self: *Elf, decl: *const Module.Decl) u64 {
321 assert(self.llvm_ir_module == null);
321322 assert(decl.link.elf.local_sym_index != 0);
322323 return self.local_symbols.items[decl.link.elf.local_sym_index].st_value;
323324}
......@@ -437,7 +438,7 @@ fn updateString(self: *Elf, old_str_off: u32, new_name: []const u8) !u32 {
437438}
438439
439440pub fn populateMissingMetadata(self: *Elf) !void {
440 if (self.llvm_ir_module) |_| return;
441 assert(self.llvm_ir_module == null);
441442
442443 const small_ptr = switch (self.ptr_width) {
443444 .p32 => true,