From 3cd19b8884a48097bccc25d7b6cc8835bbc7cdd5 Mon Sep 17 00:00:00 2001 From: Robin Voetter Date: Sun, 13 Oct 2024 01:56:33 +0200 Subject: spirv: don't try to lower types which have no runtime bits --- src/codegen/spirv.zig | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/codegen/spirv.zig') diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index 164367207a..229ff5cb87 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -190,6 +190,7 @@ pub const Object = struct { nav_index: InternPool.Nav.Index, air: Air, liveness: Liveness, + do_codegen: bool, ) !void { const zcu = pt.zcu; const gpa = zcu.gpa; @@ -214,7 +215,7 @@ pub const Object = struct { }; defer nav_gen.deinit(); - nav_gen.genNav() catch |err| switch (err) { + nav_gen.genNav(do_codegen) catch |err| switch (err) { error.CodegenFail => { try zcu.failed_codegen.put(gpa, nav_index, nav_gen.error_msg.?); }, @@ -239,7 +240,7 @@ pub const Object = struct { ) !void { const nav = pt.zcu.funcInfo(func_index).owner_nav; // TODO: Separate types for generating decls and functions? - try self.genNav(pt, nav, air, liveness); + try self.genNav(pt, nav, air, liveness, true); } pub fn updateNav( @@ -247,7 +248,7 @@ pub const Object = struct { pt: Zcu.PerThread, nav: InternPool.Nav.Index, ) !void { - try self.genNav(pt, nav, undefined, undefined); + try self.genNav(pt, nav, undefined, undefined, false); } /// Fetch or allocate a result id for nav index. This function also marks the nav as alive. @@ -2943,16 +2944,22 @@ const NavGen = struct { try self.spv.declareEntryPoint(spv_decl_index, test_name, .Kernel); } - fn genNav(self: *NavGen) !void { + fn genNav(self: *NavGen, do_codegen: bool) !void { const pt = self.pt; const zcu = pt.zcu; const ip = &zcu.intern_pool; - const spv_decl_index = try self.object.resolveNav(zcu, self.owner_nav); - const result_id = self.spv.declPtr(spv_decl_index).result_id; const nav = ip.getNav(self.owner_nav); const val = zcu.navValue(self.owner_nav); const ty = val.typeOf(zcu); + + if (!do_codegen and !ty.hasRuntimeBits(zcu)) { + return; + } + + const spv_decl_index = try self.object.resolveNav(zcu, self.owner_nav); + const result_id = self.spv.declPtr(spv_decl_index).result_id; + switch (self.spv.declPtr(spv_decl_index).kind) { .func => { const fn_info = zcu.typeToFunc(ty).?; -- cgit v1.2.3