@@ -182,10 +182,12 @@ function optimize!(@nospecialize(job::CompilerJob), mod::LLVM.Module)
182
182
183
183
add! (pm, FunctionPass (" LowerGCFrame" , lower_gc_frame!))
184
184
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
189
191
190
192
# remove dead uses of ptls
191
193
aggressive_dce! (pm)
@@ -222,7 +224,9 @@ function optimize!(@nospecialize(job::CompilerJob), mod::LLVM.Module)
222
224
ModulePassManager () do pm
223
225
addTargetPasses! (pm, tm, triple)
224
226
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)
226
230
227
231
run! (pm, mod)
228
232
end
0 commit comments