11# LLVM IR optimization
22
3- function optimize! (@nospecialize (job:: CompilerJob ), mod:: LLVM.Module ; opt_level= 1 )
3+ function optimize! (@nospecialize (job:: CompilerJob ), mod:: LLVM.Module ; opt_level= 2 )
44 tm = llvm_machine (job. config. target)
55
66 global current_job
77 current_job = job
88
99 @dispose pb= NewPMPassBuilder () begin
10- register! (pb, CPUFeaturesPass ())
11- register! (pb, LowerPTLSPass ())
12- register! (pb, LowerGCFramePass ())
10+ register! (pb, GPULowerCPUFeaturesPass ())
11+ register! (pb, GPULowerPTLSPass ())
12+ register! (pb, GPULowerGCFramePass ())
1313 register! (pb, AddKernelStatePass ())
1414 register! (pb, LowerKernelStatePass ())
1515 register! (pb, CleanupKernelStatePass ())
@@ -94,7 +94,7 @@ function buildEarlyOptimizerPipeline(mpm, @nospecialize(job::CompilerJob), opt_l
9494 add! (fpm, LowerConstantIntrinsicsPass ())
9595 end
9696 end
97- add! (mpm, CPUFeaturesPass ())
97+ add! (mpm, GPULowerCPUFeaturesPass ())
9898 if opt_level >= 1
9999 add! (mpm, NewPMFunctionPassManager ()) do fpm
100100 if opt_level >= 2
@@ -196,7 +196,7 @@ function buildIntrinsicLoweringPipeline(mpm, @nospecialize(job::CompilerJob), op
196196 # lower GC intrinsics
197197 if ! uses_julia_runtime (job)
198198 add! (mpm, NewPMFunctionPassManager ()) do fpm
199- add! (fpm, LowerGCFramePass ())
199+ add! (fpm, GPULowerGCFramePass ())
200200 end
201201 end
202202
@@ -217,7 +217,7 @@ function buildIntrinsicLoweringPipeline(mpm, @nospecialize(job::CompilerJob), op
217217 add! (mpm, NewPMFunctionPassManager ()) do fpm
218218 add! (fpm, ADCEPass ())
219219 end
220- add! (mpm, LowerPTLSPass ())
220+ add! (mpm, GPULowerPTLSPass ())
221221 end
222222
223223 add! (mpm, NewPMFunctionPassManager ()) do fpm
@@ -332,7 +332,7 @@ function cpu_features!(mod::LLVM.Module)
332332
333333 return changed
334334end
335- CPUFeaturesPass () = NewPMModulePass (" GPULowerCPUFeatures" , cpu_features!)
335+ GPULowerCPUFeaturesPass () = NewPMModulePass (" GPULowerCPUFeatures" , cpu_features!)
336336
337337# lower object allocations to to PTX malloc
338338#
@@ -391,7 +391,7 @@ function lower_gc_frame!(fun::LLVM.Function)
391391
392392 return changed
393393end
394- LowerGCFramePass () = NewPMFunctionPass (" GPULowerGCFrame" , lower_gc_frame!)
394+ GPULowerGCFramePass () = NewPMFunctionPass (" GPULowerGCFrame" , lower_gc_frame!)
395395
396396# lower the `julia.ptls_states` intrinsic by removing it, since it is GPU incompatible.
397397#
@@ -422,4 +422,4 @@ function lower_ptls!(mod::LLVM.Module)
422422
423423 return changed
424424end
425- LowerPTLSPass () = NewPMModulePass (" GPULowerPTLS" , lower_ptls!)
425+ GPULowerPTLSPass () = NewPMModulePass (" GPULowerPTLS" , lower_ptls!)
0 commit comments