aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-05-03 19:12:53 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:40:04 -0700
commitca3cf93b21bc77535fbaa7ca6aa411654dcfe069 (patch)
tree2bec1cb13da757280595ef217556c1eeddf77414 /src/Module.zig
parent836d8a1f64cb811641e621799429c54f222717eb (diff)
downloadzig-ca3cf93b21bc77535fbaa7ca6aa411654dcfe069.tar.gz
zig-ca3cf93b21bc77535fbaa7ca6aa411654dcfe069.zip
stage2: move most simple values to InternPool
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig50
1 files changed, 28 insertions, 22 deletions
diff --git a/src/Module.zig b/src/Module.zig
index 77c20fbcc6..5c84b123c1 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -4847,31 +4847,37 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !bool {
decl.owns_tv = false;
var queue_linker_work = false;
var is_extern = false;
- switch (decl_tv.val.tag()) {
- .variable => {
- const variable = decl_tv.val.castTag(.variable).?.data;
- if (variable.owner_decl == decl_index) {
- decl.owns_tv = true;
- queue_linker_work = true;
-
- const copied_init = try variable.init.copy(decl_arena_allocator);
- variable.init = copied_init;
- }
- },
- .extern_fn => {
- const extern_fn = decl_tv.val.castTag(.extern_fn).?.data;
- if (extern_fn.owner_decl == decl_index) {
- decl.owns_tv = true;
- queue_linker_work = true;
- is_extern = true;
- }
- },
-
+ switch (decl_tv.val.ip_index) {
.generic_poison => unreachable,
- .unreachable_value => unreachable,
+ .none => switch (decl_tv.val.tag()) {
+ .variable => {
+ const variable = decl_tv.val.castTag(.variable).?.data;
+ if (variable.owner_decl == decl_index) {
+ decl.owns_tv = true;
+ queue_linker_work = true;
+
+ const copied_init = try variable.init.copy(decl_arena_allocator);
+ variable.init = copied_init;
+ }
+ },
+ .extern_fn => {
+ const extern_fn = decl_tv.val.castTag(.extern_fn).?.data;
+ if (extern_fn.owner_decl == decl_index) {
+ decl.owns_tv = true;
+ queue_linker_work = true;
+ is_extern = true;
+ }
+ },
+
+ .unreachable_value => unreachable,
- .function => {},
+ .function => {},
+ else => {
+ log.debug("send global const to linker: {*} ({s})", .{ decl, decl.name });
+ queue_linker_work = true;
+ },
+ },
else => {
log.debug("send global const to linker: {*} ({s})", .{ decl, decl.name });
queue_linker_work = true;