aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-06-20 13:42:25 -0400
committerJacob Young <jacobly0@users.noreply.github.com>2023-06-20 14:02:09 -0400
commit6b56f4ff0bf9ac9c5e0b4a11cf0536472447bc4a (patch)
tree033edcdf8ec8f2570d874f15040d4fc9258df71e /src/value.zig
parentd69e324eae6d245a4b0c75c0a8ce91275dfcc938 (diff)
downloadzig-6b56f4ff0bf9ac9c5e0b4a11cf0536472447bc4a.tar.gz
zig-6b56f4ff0bf9ac9c5e0b4a11cf0536472447bc4a.zip
Value: optimize `isPtrToThreadLocal`
Diffstat (limited to 'src/value.zig')
-rw-r--r--src/value.zig30
1 files changed, 3 insertions, 27 deletions
diff --git a/src/value.zig b/src/value.zig
index 00c8fa924c..0a5131d3f8 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -1851,33 +1851,9 @@ pub const Value = struct {
}
pub fn isPtrToThreadLocal(val: Value, mod: *Module) bool {
- return val.ip_index != .none and switch (mod.intern_pool.indexToKey(val.toIntern())) {
- .variable => false,
- else => val.isPtrToThreadLocalInner(mod),
- };
- }
-
- pub fn isPtrToThreadLocalInner(val: Value, mod: *Module) bool {
- return val.ip_index != .none and switch (mod.intern_pool.indexToKey(val.toIntern())) {
- .variable => |variable| variable.is_threadlocal,
- .ptr => |ptr| switch (ptr.addr) {
- .decl => |decl_index| {
- const decl = mod.declPtr(decl_index);
- assert(decl.has_tv);
- return decl.val.isPtrToThreadLocalInner(mod);
- },
- .mut_decl => |mut_decl| {
- const decl = mod.declPtr(mut_decl.decl);
- assert(decl.has_tv);
- return decl.val.isPtrToThreadLocalInner(mod);
- },
- .int => false,
- .eu_payload, .opt_payload => |base_ptr| base_ptr.toValue().isPtrToThreadLocalInner(mod),
- .comptime_field => |comptime_field| comptime_field.toValue().isPtrToThreadLocalInner(mod),
- .elem, .field => |base_index| base_index.base.toValue().isPtrToThreadLocalInner(mod),
- },
- else => false,
- };
+ const backing_decl = mod.intern_pool.getBackingDecl(val.toIntern()).unwrap() orelse return false;
+ const variable = mod.declPtr(backing_decl).getOwnedVariable(mod) orelse return false;
+ return variable.is_threadlocal;
}
// Asserts that the provided start/end are in-bounds.