diff --git a/src/compiler.jl b/src/compiler.jl index 5eccd1e80d..b72a507b96 100644 --- a/src/compiler.jl +++ b/src/compiler.jl @@ -4047,11 +4047,7 @@ end ) end - if primal_job.config.target isa GPUCompiler.NativeCompilerTarget - target_machine = JIT.get_tm() - else - target_machine = GPUCompiler.llvm_machine(primal_job.config.target) - end + target_machine = GPUCompiler.llvm_machine(primal_job.config.target) parallel = parent_job === nothing ? Threads.nthreads() > 1 : false process_module = false diff --git a/src/compiler/optimize.jl b/src/compiler/optimize.jl index b8fc02bdba..de26378f36 100644 --- a/src/compiler/optimize.jl +++ b/src/compiler/optimize.jl @@ -463,19 +463,19 @@ function optimize!(mod::LLVM.Module, tm::LLVM.TargetMachine) ModulePassManager() do pm add_library_info!(pm, triple(mod)) if tm.ref != C_NULL - add_transform_info!(pm, tm) + #add_transform_info!(pm, tm) end - propagate_julia_addrsp_tm!(pm, tm) + #propagate_julia_addrsp_tm!(pm, tm) scoped_no_alias_aa!(pm) type_based_alias_analysis!(pm) basic_alias_analysis!(pm) cfgsimplification!(pm) dce!(pm) - cpu_features_tm!(pm, tm) + #cpu_features_tm!(pm, tm) scalar_repl_aggregates_ssa!(pm) # SSA variant? mem_cpy_opt!(pm) always_inliner!(pm) - alloc_opt_tm!(pm, tm) + #alloc_opt_tm!(pm, tm) LLVM.run!(pm, mod) end diff --git a/src/compiler/orcv2.jl b/src/compiler/orcv2.jl index c3f4d86b5e..4734f7b398 100644 --- a/src/compiler/orcv2.jl +++ b/src/compiler/orcv2.jl @@ -83,7 +83,7 @@ function define_absolute_symbol(jd, name) return false end -function __init__() +function setup_globals() opt_level = Base.JLOptions().opt_level if opt_level < 2 optlevel = LLVM.API.LLVMCodeGenLevelNone @@ -96,7 +96,6 @@ function __init__() tempTM = LLVM.JITTargetMachine(LLVM.triple(), cpu_name(), cpu_features(); optlevel) LLVM.asm_verbosity!(tempTM, true) tm[] = tempTM - @show tm, tempTM lljit = JuliaOJIT() @@ -106,11 +105,6 @@ function __init__() dg = LLVM.CreateDynamicLibrarySearchGeneratorForProcess(prefix) LLVM.add!(jd_main, dg) - if Sys.iswindows() && Int === Int64 - # TODO can we check isGNU? - define_absolute_symbol(jd_main, mangle(lljit, "___chkstk_ms")) - end - es = ExecutionSession(lljit) try lctm = LLVM.LocalLazyCallThroughManager(triple(lljit), es) @@ -120,6 +114,15 @@ function __init__() @warn "OrcV2 initialization failed with" err jit[] = CompilerInstance(lljit, nothing, nothing) end +end + +function __init__() + setup_globals() + + if Sys.iswindows() && Int === Int64 + # TODO can we check isGNU? + define_absolute_symbol(jd_main, mangle(lljit, "___chkstk_ms")) + end hnd = unsafe_load(cglobal(:jl_libjulia_handle, Ptr{Cvoid})) for (k, v) in Compiler.JuliaGlobalNameMap diff --git a/src/precompile.jl b/src/precompile.jl index 6a8cdba7e0..c20eaac149 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -4,10 +4,10 @@ using PrecompileTools: @setup_workload, @compile_workload precompile_module = @eval module $(gensym()) f(x) = x^2 end - - kernel() = nothing + + Compiler.JIT.setup_globals() @compile_workload begin Enzyme.autodiff(Reverse, precompile_module.f, Active(2.0)) end -end \ No newline at end of file +end