Skip to content

Commit edc6073

Browse files
committed
Only run kernel state passes for kernels.
1 parent 59ff5f4 commit edc6073

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/irgen.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -726,11 +726,6 @@ function lower_kernel_state!(fun::LLVM.Function)
726726
changed = false
727727

728728
# check if we even need a kernel state argument
729-
if !job.source.kernel
730-
# only kernels have had a kernel state argument added
731-
# XXX: for consistency, also add the state to non-kernel compilation jobs?
732-
return false
733-
end
734729
state = kernel_state_type(job)
735730
if state === Nothing
736731
return false

src/optim.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,12 @@ function optimize!(@nospecialize(job::CompilerJob), mod::LLVM.Module)
182182

183183
add!(pm, FunctionPass("LowerGCFrame", lower_gc_frame!))
184184

185-
# GC lowering is the last pass that may introduce calls to the runtime library,
186-
# and thus additional uses of the kernel state.
187-
add!(pm, FunctionPass("LowerKernelState", lower_kernel_state!))
188-
add!(pm, ModulePass("CleanupKernelState", cleanup_kernel_state!))
185+
if job.source.kernel
186+
# GC lowering is the last pass that may introduce calls to the runtime library,
187+
# and thus additional uses of the kernel state intrinsic.
188+
add!(pm, FunctionPass("LowerKernelState", lower_kernel_state!))
189+
add!(pm, ModulePass("CleanupKernelState", cleanup_kernel_state!))
190+
end
189191

190192
# remove dead uses of ptls
191193
aggressive_dce!(pm)
@@ -222,7 +224,9 @@ function optimize!(@nospecialize(job::CompilerJob), mod::LLVM.Module)
222224
ModulePassManager() do pm
223225
addTargetPasses!(pm, tm, triple)
224226

225-
dead_arg_elimination!(pm) # parent doesn't use return value --> ret void
227+
# - remove unused kernel state arguments
228+
# - simplify function calls that don't use the returned value
229+
dead_arg_elimination!(pm)
226230

227231
run!(pm, mod)
228232
end

0 commit comments

Comments
 (0)