diff --git a/build.zig b/build.zig index a20d81d..cd24748 100644 --- a/build.zig +++ b/build.zig @@ -7,7 +7,7 @@ pub fn build(b: *Builder) void { exe.install(); exe.linkSystemLibrary("c"); - exe.linkSystemLibrary("LLVM-10"); + exe.linkSystemLibrary("LLVM-9"); exe.linkSystemLibrary("stdc++"); const run_cmd = exe.run(); diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 0b931e0..f0894fb 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -176,14 +176,12 @@ pub const Codegen = struct { .Call => |call| { const name = call.callee.*.Variable.lexeme; - var llvm_func_entry = self.llvm_table.getEntry(name); - if (llvm_func_entry == null) { + var llvm_func = self.llvm_table.get(name); + if (llvm_func == null) { std.debug.warn("Function '{}' not found\n", .{name}); return CompileError.EmitError; } - const llvm_func = llvm_func_entry.?.value; - var args = LLVMValueList.init(self.allocator); errdefer args.deinit(); @@ -196,7 +194,7 @@ pub const Codegen = struct { return llvm.LLVMBuildCall( builder, - llvm_func, + llvm_func.?, args_slice.ptr, @intCast(c_uint, args_slice.len), "call", @@ -434,8 +432,7 @@ pub const Codegen = struct { ); var func = llvm.LLVMAddFunction(mod, name_cstr.ptr, llvm_ret_type); - std.debug.warn("inserting function '{}' to llvm table\n", .{name}); - try self.llvm_table.put(name, func); + _ = try self.llvm_table.put(name, func); var buf = try self.allocator.alloc(u8, 512); var entry_lbl = try std.fmt.bufPrint(buf, "fn_{}_entry", .{name});