Skip to content

Commit 99bda02

Browse files
improve inference of CPU_THREADS in Sys.__init__ (JuliaLang#54384)
Without this change, the compiler fails to notice that `env_threads isa Int` in the fall-through case, leading to a union-split with a branch that is in fact unreachable: ``` 43 ┄ %109 = φ (mmtk#41 => %105, mmtk#42 => %108)::Union{Nothing, Int64} │ %110 = (%109 isa Int64)::Bool └─── goto mmtk#45 if not %110 ... 45 ─ %126 = π (%109, Nothing) │ Base.convert(Int64, %126)::Union{} └─── unreachable ``` After this change, the union-split is eliminated. Co-authored-by: Jeff Bezanson <[email protected]>
1 parent e47fedd commit 99bda02

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

base/sysinfo.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function __init__()
147147
end
148148
global CPU_THREADS = if env_threads !== nothing
149149
env_threads = tryparse(Int, env_threads)
150-
if !(env_threads isa Int && env_threads > 0)
150+
if env_threads === nothing || env_threads <= 0
151151
env_threads = Int(ccall(:jl_cpu_threads, Int32, ()))
152152
Core.print(Core.stderr, "WARNING: couldn't parse `JULIA_CPU_THREADS` environment variable. Defaulting Sys.CPU_THREADS to $env_threads.\n")
153153
end

0 commit comments

Comments
 (0)