From 72e4ea38216aab7e7ed05978d04c5d32de44b5ce Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Thu, 25 May 2023 07:08:48 -0400 Subject: InternPool: fix crashes up to in progress comptime mutation --- src/codegen/llvm.zig | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/codegen') diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index e54b951aa6..0c12faf751 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -3208,7 +3208,8 @@ pub const DeclGen = struct { return llvm_type.getUndef(); } - switch (mod.intern_pool.indexToKey(tv.val.toIntern())) { + const val_key = mod.intern_pool.indexToKey(tv.val.toIntern()); + switch (val_key) { .int_type, .ptr_type, .array_type, @@ -3242,10 +3243,18 @@ pub const DeclGen = struct { }, }, .variable, - .extern_func, - .func, .enum_literal, => unreachable, // non-runtime values + .extern_func, .func => { + const fn_decl_index = switch (val_key) { + .extern_func => |extern_func| extern_func.decl, + .func => |func| mod.funcPtr(func.index).owner_decl, + else => unreachable, + }; + const fn_decl = dg.module.declPtr(fn_decl_index); + dg.module.markDeclAlive(fn_decl); + return dg.resolveLlvmFunction(fn_decl_index); + }, .int => |int| { var bigint_space: Value.BigIntSpace = undefined; const bigint = int.storage.toBigInt(&bigint_space); -- cgit v1.2.3