aboutsummaryrefslogtreecommitdiff
path: root/src/link/Coff.zig
diff options
context:
space:
mode:
authorTimon Kruiper <timonkruiper@gmail.com>2020-12-24 11:40:54 +0100
committerTimon Kruiper <timonkruiper@gmail.com>2020-12-28 21:20:49 +0100
commit09cf043efd5966e328e4454bc30bc756f439938b (patch)
treebce231f261ec7a240aab48ffbd7fc65e89084811 /src/link/Coff.zig
parent6b8d28312ccca56d652af32bad360e9a5394fb8e (diff)
downloadzig-09cf043efd5966e328e4454bc30bc756f439938b.tar.gz
zig-09cf043efd5966e328e4454bc30bc756f439938b.zip
stage2: add missing asserts and early returns for LLVM backend
Diffstat (limited to 'src/link/Coff.zig')
-rw-r--r--src/link/Coff.zig5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/link/Coff.zig b/src/link/Coff.zig
index 8c60086010..096fa2cd0b 100644
--- a/src/link/Coff.zig
+++ b/src/link/Coff.zig
@@ -413,6 +413,8 @@ pub fn createEmpty(gpa: *Allocator, options: link.Options) !*Coff {
}
pub fn allocateDeclIndexes(self: *Coff, decl: *Module.Decl) !void {
+ if (self.llvm_ir_module) |_| return;
+
try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1);
if (self.offset_table_free_list.popOrNull()) |i| {
@@ -710,6 +712,8 @@ pub fn updateDecl(self: *Coff, module: *Module, decl: *Module.Decl) !void {
}
pub fn freeDecl(self: *Coff, decl: *Module.Decl) void {
+ if (self.llvm_ir_module) |_| return;
+
// Appending to free lists is allowed to fail because the free lists are heuristics based anyway.
self.freeTextBlock(&decl.link.coff);
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 {
}
pub fn getDeclVAddr(self: *Coff, decl: *const Module.Decl) u64 {
+ assert(self.llvm_ir_module == null);
return self.text_section_virtual_address + decl.link.coff.text_offset;
}