| ... | @@ -190,6 +190,7 @@ pub const Object = struct { | ... | @@ -190,6 +190,7 @@ pub const Object = struct { |
| 190 | nav_index: InternPool.Nav.Index, | 190 | nav_index: InternPool.Nav.Index, |
| 191 | air: Air, | 191 | air: Air, |
| 192 | liveness: Liveness, | 192 | liveness: Liveness, |
| | 193 | do_codegen: bool, |
| 193 | ) !void { | 194 | ) !void { |
| 194 | const zcu = pt.zcu; | 195 | const zcu = pt.zcu; |
| 195 | const gpa = zcu.gpa; | 196 | const gpa = zcu.gpa; |
| ... | @@ -214,7 +215,7 @@ pub const Object = struct { | ... | @@ -214,7 +215,7 @@ pub const Object = struct { |
| 214 | }; | 215 | }; |
| 215 | defer nav_gen.deinit(); | 216 | defer nav_gen.deinit(); |
| 216 | | 217 | |
| 217 | nav_gen.genNav() catch |err| switch (err) { | 218 | nav_gen.genNav(do_codegen) catch |err| switch (err) { |
| 218 | error.CodegenFail => { | 219 | error.CodegenFail => { |
| 219 | try zcu.failed_codegen.put(gpa, nav_index, nav_gen.error_msg.?); | 220 | try zcu.failed_codegen.put(gpa, nav_index, nav_gen.error_msg.?); |
| 220 | }, | 221 | }, |
| ... | @@ -239,7 +240,7 @@ pub const Object = struct { | ... | @@ -239,7 +240,7 @@ pub const Object = struct { |
| 239 | ) !void { | 240 | ) !void { |
| 240 | const nav = pt.zcu.funcInfo(func_index).owner_nav; | 241 | const nav = pt.zcu.funcInfo(func_index).owner_nav; |
| 241 | // TODO: Separate types for generating decls and functions? | 242 | // TODO: Separate types for generating decls and functions? |
| 242 | try self.genNav(pt, nav, air, liveness); | 243 | try self.genNav(pt, nav, air, liveness, true); |
| 243 | } | 244 | } |
| 244 | | 245 | |
| 245 | pub fn updateNav( | 246 | pub fn updateNav( |
| ... | @@ -247,7 +248,7 @@ pub const Object = struct { | ... | @@ -247,7 +248,7 @@ pub const Object = struct { |
| 247 | pt: Zcu.PerThread, | 248 | pt: Zcu.PerThread, |
| 248 | nav: InternPool.Nav.Index, | 249 | nav: InternPool.Nav.Index, |
| 249 | ) !void { | 250 | ) !void { |
| 250 | try self.genNav(pt, nav, undefined, undefined); | 251 | try self.genNav(pt, nav, undefined, undefined, false); |
| 251 | } | 252 | } |
| 252 | | 253 | |
| 253 | /// Fetch or allocate a result id for nav index. This function also marks the nav as alive. | 254 | /// Fetch or allocate a result id for nav index. This function also marks the nav as alive. |
| ... | @@ -2943,16 +2944,22 @@ const NavGen = struct { | ... | @@ -2943,16 +2944,22 @@ const NavGen = struct { |
| 2943 | try self.spv.declareEntryPoint(spv_decl_index, test_name, .Kernel); | 2944 | try self.spv.declareEntryPoint(spv_decl_index, test_name, .Kernel); |
| 2944 | } | 2945 | } |
| 2945 | | 2946 | |
| 2946 | fn genNav(self: *NavGen) !void { | 2947 | fn genNav(self: *NavGen, do_codegen: bool) !void { |
| 2947 | const pt = self.pt; | 2948 | const pt = self.pt; |
| 2948 | const zcu = pt.zcu; | 2949 | const zcu = pt.zcu; |
| 2949 | const ip = &zcu.intern_pool; | 2950 | const ip = &zcu.intern_pool; |
| 2950 | const spv_decl_index = try self.object.resolveNav(zcu, self.owner_nav); | | |
| 2951 | const result_id = self.spv.declPtr(spv_decl_index).result_id; | | |
| 2952 | | 2951 | |
| 2953 | const nav = ip.getNav(self.owner_nav); | 2952 | const nav = ip.getNav(self.owner_nav); |
| 2954 | const val = zcu.navValue(self.owner_nav); | 2953 | const val = zcu.navValue(self.owner_nav); |
| 2955 | const ty = val.typeOf(zcu); | 2954 | const ty = val.typeOf(zcu); |
| | 2955 | |
| | 2956 | if (!do_codegen and !ty.hasRuntimeBits(zcu)) { |
| | 2957 | return; |
| | 2958 | } |
| | 2959 | |
| | 2960 | const spv_decl_index = try self.object.resolveNav(zcu, self.owner_nav); |
| | 2961 | const result_id = self.spv.declPtr(spv_decl_index).result_id; |
| | 2962 | |
| 2956 | switch (self.spv.declPtr(spv_decl_index).kind) { | 2963 | switch (self.spv.declPtr(spv_decl_index).kind) { |
| 2957 | .func => { | 2964 | .func => { |
| 2958 | const fn_info = zcu.typeToFunc(ty).?; | 2965 | const fn_info = zcu.typeToFunc(ty).?; |