diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index dc5a50ac..3ab6732d 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -2,7 +2,7 @@ steps: - label: "CUDA.jl" plugins: - JuliaCI/julia#v1: - version: 1.8 + version: "1.10" - JuliaCI/julia-coverage#v1: codecov: true command: | @@ -25,7 +25,7 @@ steps: - label: "oneAPI.jl" plugins: - JuliaCI/julia#v1: - version: 1.8 + version: "1.10" - JuliaCI/julia-coverage#v1: codecov: true command: | @@ -52,7 +52,7 @@ steps: - label: "Metal.jl" plugins: - JuliaCI/julia#v1: - version: 1.8 + version: "1.10" - JuliaCI/julia-coverage#v1: codecov: true command: | @@ -73,33 +73,33 @@ steps: soft_fail: - exit_status: 3 -# - label: "AMDGPU.jl" -# plugins: -# - JuliaCI/julia#v1: -# version: 1.8 -# - JuliaCI/julia-coverage#v1: -# codecov: true -# command: | -# julia -e 'println("--- :julia: Instantiating project") -# using Pkg -# Pkg.develop(; path=pwd()) -# Pkg.develop(; name="AMDGPU")' || exit 3 -# -# julia -e 'println("+++ :julia: Running tests") -# using Pkg -# Pkg.test("AMDGPU"; coverage=true)' -# agents: -# queue: "juliagpu" -# rocm: "*" -# if: build.message !~ /\[skip tests\]/ && !build.pull_request.draft -# timeout_in_minutes: 120 -# soft_fail: -# - exit_status: 3 + - label: "AMDGPU.jl" + plugins: + - JuliaCI/julia#v1: + version: "1.10" + - JuliaCI/julia-coverage#v1: + codecov: true + command: | + julia -e 'println("--- :julia: Instantiating project") + using Pkg + Pkg.develop(; path=pwd()) + Pkg.develop(; name="AMDGPU")' || exit 3 + + julia -e 'println("+++ :julia: Running tests") + using Pkg + Pkg.test("AMDGPU"; coverage=true)' + agents: + queue: "juliagpu" + rocm: "*" + if: build.message !~ /\[skip tests\]/ && !build.pull_request.draft + timeout_in_minutes: 120 + soft_fail: + - exit_status: 3 - label: "Enzyme.jl" plugins: - JuliaCI/julia#v1: - version: 1.8 + version: "1.10" - JuliaCI/julia-coverage#v1: codecov: true command: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9df2ad02..507a14c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - version: ['1.8', '1.9', '1.10', 'pre'] # 'nightly' + version: ['1.10', 'pre'] # 'nightly' os: [ubuntu-latest, macOS-latest, windows-latest] arch: [x64] llvm_args: [''] diff --git a/Project.toml b/Project.toml index a0b24da3..3315c3ac 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "GPUCompiler" uuid = "61eb1bfa-7361-4325-ad38-22787b887f55" authors = ["Tim Besard "] -version = "0.26.7" +version = "0.27.0" [deps] ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04" @@ -28,4 +28,4 @@ Scratch = "1" Serialization = "1" TOML = "1" TimerOutputs = "0.5" -julia = "1.8" +julia = "1.10" diff --git a/src/GPUCompiler.jl b/src/GPUCompiler.jl index a51b6c19..bfcd3ef9 100644 --- a/src/GPUCompiler.jl +++ b/src/GPUCompiler.jl @@ -53,7 +53,7 @@ _precompile_() compile_cache = "" # defined in __init__() -const pkgver = @static VERSION > v"1.9" ? Base.pkgversion(GPUCompiler) : nothing +const pkgver = Base.pkgversion(GPUCompiler) function __init__() STDERR_HAS_COLOR[] = get(stderr, :color, false) diff --git a/src/driver.jl b/src/driver.jl index fb8b5f43..0bfdec31 100644 --- a/src/driver.jl +++ b/src/driver.jl @@ -19,52 +19,22 @@ export JuliaContext # unique context on all other versions. Once we only support Julia 1.9, we'll deprecate # this helper to a regular `Context()` call. function JuliaContext(; opaque_pointers=nothing) - if VERSION >= v"1.9.0-DEV.516" - # Julia 1.9 knows how to deal with arbitrary contexts, - # and uses ORC's thread safe versions. - ctx = ThreadSafeContext(; opaque_pointers) - elseif VERSION >= v"1.9.0-DEV.115" - # Julia 1.9 knows how to deal with arbitrary contexts - ctx = Context(; opaque_pointers) - else - # earlier versions of Julia claim so, but actually use a global context - isboxed_ref = Ref{Bool}() - typ = LLVMType(ccall(:jl_type_to_llvm, LLVM.API.LLVMTypeRef, - (Any, Ptr{Bool}), Any, isboxed_ref)) - ctx = context(typ) - if opaque_pointers !== nothing && supports_typed_pointers(ctx) !== !opaque_pointers - error("Cannot use $(opaque_pointers ? "opaque" : "typed") pointers, as the context has already been configured to use $(supports_typed_pointers(ctx) ? "typed" : "opaque") pointers, and this version of Julia does not support changing that.") - end - end - - ctx + # XXX: remove + ThreadSafeContext(; opaque_pointers) end function JuliaContext(f; kwargs...) - if VERSION >= v"1.9.0-DEV.516" - ts_ctx = JuliaContext(; kwargs...) - # for now, also activate the underlying context - # XXX: this is wrong; we can't expose the underlying LLVM context, but should - # instead always go through the callback in order to unlock it properly. - # rework this once we depend on Julia 1.9 or later. - ctx = context(ts_ctx) - activate(ctx) - try - f(ctx) - finally - deactivate(ctx) - dispose(ts_ctx) - end - elseif VERSION >= v"1.9.0-DEV.115" - Context(f) - else - ctx = JuliaContext() - activate(ctx) - try - f(ctx) - finally - deactivate(ctx) - # we cannot dispose of the global unique context - end + ts_ctx = JuliaContext(; kwargs...) + # for now, also activate the underlying context + # XXX: this is wrong; we can't expose the underlying LLVM context, but should + # instead always go through the callback in order to unlock it properly. + # rework this once we depend on Julia 1.9 or later. + ctx = context(ts_ctx) + activate(ctx) + try + f(ctx) + finally + deactivate(ctx) + dispose(ts_ctx) end end @@ -118,9 +88,6 @@ function codegen(output::Symbol, @nospecialize(job::CompilerJob); only_entry::Bool=false, parent_job::Union{Nothing, CompilerJob}=nothing) if context(; throw_error=false) === nothing error("No active LLVM context. Use `JuliaContext()` do-block syntax to create one.") - elseif VERSION < v"1.9.0-DEV.115" && context() != JuliaContext() - error("""Julia <1.9 does not suppport generating code in an arbitrary LLVM context. - Use `JuliaContext()` do-block syntax to get an appropriate one.""") end @timeit_debug to "Validation" begin diff --git a/src/gcn.jl b/src/gcn.jl index 40d262b7..d262db8d 100644 --- a/src/gcn.jl +++ b/src/gcn.jl @@ -50,43 +50,6 @@ function finish_module!(@nospecialize(job::CompilerJob{GCNCompilerTarget}), return entry end -function optimize!(job::CompilerJob{GCNCompilerTarget}, mod::LLVM.Module) - @static if VERSION < v"1.9.0-DEV.1018" - # we have to fake our target early in the pipeline because Julia's - # optimization passes weren't designed for a non-0 stack addrspace, and the - # AMDGPU target is very strict about which addrspaces are permitted for - # various code patterns - triple!(mod, llvm_triple(NativeCompilerTarget())) - datalayout!(mod, julia_datalayout(NativeCompilerTarget())) - end - - invoke(optimize!, Tuple{CompilerJob, LLVM.Module}, job, mod) -end - -# We need to do alloca rewriting (from 0 to 5) after Julia's optimization -# passes because of two reasons: -# 1. Debug builds call the target verifier first, which would trip if AMDGPU -# was the target at that time -# 2. We don't want any chance of messing with Julia's optimizations, since they -# eliminate target-unsafe IR patterns -function optimize_module!(job::CompilerJob{GCNCompilerTarget}, mod::LLVM.Module) - @static if VERSION < v"1.9.0-DEV.1018" - # revert back to the AMDGPU target - triple!(mod, llvm_triple(job.config.target)) - datalayout!(mod, julia_datalayout(job.config.target)) - - tm = llvm_machine(job.config.target) - @dispose pm=ModulePassManager() begin - add_library_info!(pm, triple(mod)) - add_transform_info!(pm, tm) - - add!(pm, FunctionPass("FixAllocaAddrspace", fix_alloca_addrspace!)) - - run!(pm, mod) - end - end -end - ## LLVM passes diff --git a/src/irgen.jl b/src/irgen.jl index 123ca58b..8b9ae2f1 100644 --- a/src/irgen.jl +++ b/src/irgen.jl @@ -13,7 +13,7 @@ function irgen(@nospecialize(job::CompilerJob)) # clean up incompatibilities @timeit_debug to "clean-up" begin for llvmf in functions(mod) - if VERSION < v"1.9" || Base.isdebugbuild() + if Base.isdebugbuild() # only occurs in debug builds delete!(function_attributes(llvmf), EnumAttribute("sspstrong", 0)) diff --git a/src/jlgen.jl b/src/jlgen.jl index 38150356..a34bd42e 100644 --- a/src/jlgen.jl +++ b/src/jlgen.jl @@ -39,11 +39,7 @@ MethodError(ft, tt, world=typemax(UInt)) = Base.MethodError(ft, tt, world) # generate a LineInfoNode for the current source code location macro LineInfoNode(method) - if VERSION >= v"1.9.0-DEV.502" - Core.LineInfoNode(__module__, method, __source__.file, Int32(__source__.line), Int32(0)) - else - Core.LineInfoNode(__module__, method, __source__.file, __source__.line, 0) - end + Core.LineInfoNode(__module__, method, __source__.file, Int32(__source__.line), Int32(0)) end """ @@ -104,11 +100,6 @@ else const methodinstance = generic_methodinstance -# on 1.10 (JuliaLang/julia#48611) generated functions know which world to generate code for. -# we can use this to cache and automatically invalidate method instance look-ups. -# this isn't perfect, see e.g. JuliaGPU/GPUCompiler.jl#530. -if VERSION >= v"1.10.0-DEV.873" - function methodinstance_generator(world::UInt, source, self, ft::Type, tt::Type) @nospecialize @assert CC.isType(ft) && CC.isType(tt) @@ -166,8 +157,6 @@ end end -end - ## code instance cache const HAS_INTEGRATED_CACHE = VERSION >= v"1.11.0-DEV.1552" @@ -310,7 +299,7 @@ Base.Experimental.@MethodTable(GLOBAL_METHOD_TABLE) ## interpreter -@static if VERSION ≥ v"1.11.0-DEV.1498" +@static if VERSION >= v"1.11.0-DEV.1498" import Core.Compiler: get_inference_world using Base: get_world_counter else @@ -424,33 +413,20 @@ CC.may_optimize(interp::GPUInterpreter) = true CC.may_compress(interp::GPUInterpreter) = true CC.may_discard_trees(interp::GPUInterpreter) = true CC.verbose_stmt_info(interp::GPUInterpreter) = false - -if v"1.8-beta2" <= VERSION < v"1.9-" || VERSION >= v"1.9.0-DEV.120" CC.method_table(interp::GPUInterpreter) = interp.method_table -else -CC.method_table(interp::GPUInterpreter, sv::CC.InferenceState) = interp.method_table -end # semi-concrete interepretation is broken with overlays (JuliaLang/julia#47349) -@static if VERSION >= v"1.9.0-beta3" function CC.concrete_eval_eligible(interp::GPUInterpreter, @nospecialize(f), result::CC.MethodCallResult, arginfo::CC.ArgInfo, sv::CC.InferenceState) # NOTE it's fine to skip overloading with `sv::IRInterpretationState` since we disables # semi-concrete interpretation anyway. ret = @invoke CC.concrete_eval_eligible(interp::CC.AbstractInterpreter, f::Any, result::CC.MethodCallResult, arginfo::CC.ArgInfo, sv::CC.InferenceState) - @static if VERSION ≥ v"1.10.0-DEV.1345" - if ret === :semi_concrete_eval - return :none - end - else - if ret === false - return nothing - end + if ret === :semi_concrete_eval + return :none end return ret end -elseif VERSION >= v"1.9.0-DEV.1248" function CC.concrete_eval_eligible(interp::GPUInterpreter, @nospecialize(f), result::CC.MethodCallResult, arginfo::CC.ArgInfo) ret = @invoke CC.concrete_eval_eligible(interp::CC.AbstractInterpreter, @@ -458,7 +434,6 @@ function CC.concrete_eval_eligible(interp::GPUInterpreter, ret === false && return nothing return ret end -end ## world view of the cache @@ -531,11 +506,7 @@ function ci_cache_populate(interp, cache, mi, min_world, max_world) # (because it is normally not supposed to be used ever again). # to avoid the need to re-infer, set that field here. if ci.inferred === nothing - @static if VERSION >= v"1.9.0-DEV.1115" - @atomic ci.inferred = src - else - ci.inferred = src - end + @atomic ci.inferred = src end end @@ -644,80 +615,43 @@ function compile_method_instance(@nospecialize(job::CompilerJob)) prefer_specsig = true, gnu_pubnames = false, debug_info_kind = Cint(debug_info_kind), - lookup = Base.unsafe_convert(Ptr{Nothing}, lookup_cb)) - @static if v"1.9.0-DEV.1660" <= VERSION < v"1.9.0-beta1" || VERSION >= v"1.10-" - cgparams = merge(cgparams, (;safepoint_on_entry = can_safepoint(job))) - end - @static if VERSION >= v"1.10.0-DEV.1499" - cgparams = merge(cgparams, (;gcstack_arg = false)) - end + lookup = Base.unsafe_convert(Ptr{Nothing}, lookup_cb), + safepoint_on_entry = can_safepoint(job), + gcstack_arg = false) params = Base.CodegenParams(; cgparams...) # generate IR GC.@preserve lookup_cb begin - native_code = if VERSION >= v"1.9.0-DEV.516" - ts_mod = ThreadSafeModule("start") - - # configure the module - ts_mod() do mod - triple!(mod, llvm_triple(job.config.target)) - if julia_datalayout(job.config.target) !== nothing - datalayout!(mod, julia_datalayout(job.config.target)) - end - flags(mod)["Dwarf Version", LLVM.API.LLVMModuleFlagBehaviorWarning] = - Metadata(ConstantInt(dwarf_version(job.config.target))) - flags(mod)["Debug Info Version", LLVM.API.LLVMModuleFlagBehaviorWarning] = - Metadata(ConstantInt(DEBUG_METADATA_VERSION())) + # create and configure the module + ts_mod = ThreadSafeModule("start") + ts_mod() do mod + triple!(mod, llvm_triple(job.config.target)) + if julia_datalayout(job.config.target) !== nothing + datalayout!(mod, julia_datalayout(job.config.target)) end - - if VERSION >= v"1.10.0-DEV.645" || v"1.9.0-beta4.23" <= VERSION < v"1.10-" - ccall(:jl_create_native, Ptr{Cvoid}, - (Vector{MethodInstance}, LLVM.API.LLVMOrcThreadSafeModuleRef, Ptr{Base.CodegenParams}, Cint, Cint, Cint, Csize_t), - [job.source], ts_mod, Ref(params), CompilationPolicyExtern, #=imaging mode=# 0, #=external linkage=# 0, job.world) - elseif VERSION >= v"1.10.0-DEV.204" || v"1.9.0-alpha1.55" <= VERSION < v"1.10-" - @in_world job.world ccall(:jl_create_native, Ptr{Cvoid}, - (Vector{MethodInstance}, LLVM.API.LLVMOrcThreadSafeModuleRef, Ptr{Base.CodegenParams}, Cint, Cint, Cint), - [job.source], ts_mod, Ref(params), CompilationPolicyExtern, #=imaging mode=# 0, #=external linkage=# 0) - elseif VERSION >= v"1.10.0-DEV.75" - @in_world job.world ccall(:jl_create_native, Ptr{Cvoid}, - (Vector{MethodInstance}, LLVM.API.LLVMOrcThreadSafeModuleRef, Ptr{Base.CodegenParams}, Cint, Cint), - [job.source], ts_mod, Ref(params), CompilationPolicyExtern, #=imaging mode=# 0) - else - @in_world job.world ccall(:jl_create_native, Ptr{Cvoid}, - (Vector{MethodInstance}, LLVM.API.LLVMOrcThreadSafeModuleRef, Ptr{Base.CodegenParams}, Cint), - [job.source], ts_mod, Ref(params), CompilationPolicyExtern) - - end - elseif VERSION >= v"1.9.0-DEV.115" - @in_world job.world ccall(:jl_create_native, Ptr{Cvoid}, - (Vector{MethodInstance}, LLVM.API.LLVMContextRef, Ptr{Base.CodegenParams}, Cint), - [job.source], context(), Ref(params), CompilationPolicyExtern) - else - @assert context() == JuliaContext() - @in_world job.world ccall(:jl_create_native, Ptr{Cvoid}, - (Vector{MethodInstance}, Ptr{Base.CodegenParams}, Cint), - [job.source], Ref(params), CompilationPolicyExtern) + flags(mod)["Dwarf Version", LLVM.API.LLVMModuleFlagBehaviorWarning] = + Metadata(ConstantInt(dwarf_version(job.config.target))) + flags(mod)["Debug Info Version", LLVM.API.LLVMModuleFlagBehaviorWarning] = + Metadata(ConstantInt(DEBUG_METADATA_VERSION())) end + + native_code = ccall(:jl_create_native, Ptr{Cvoid}, + (Vector{MethodInstance}, LLVM.API.LLVMOrcThreadSafeModuleRef, Ptr{Base.CodegenParams}, Cint, Cint, Cint, Csize_t), + [job.source], ts_mod, Ref(params), CompilationPolicyExtern, #=imaging mode=# 0, #=external linkage=# 0, job.world) @assert native_code != C_NULL - llvm_mod_ref = if VERSION >= v"1.9.0-DEV.516" + + llvm_mod_ref = ccall(:jl_get_llvm_module, LLVM.API.LLVMOrcThreadSafeModuleRef, (Ptr{Cvoid},), native_code) - else - ccall(:jl_get_llvm_module, LLVM.API.LLVMModuleRef, - (Ptr{Cvoid},), native_code) - end @assert llvm_mod_ref != C_NULL - if VERSION >= v"1.9.0-DEV.516" - # XXX: this is wrong; we can't expose the underlying LLVM module, but should - # instead always go through the callback in order to unlock it properly. - # rework this once we depend on Julia 1.9 or later. - llvm_ts_mod = LLVM.ThreadSafeModule(llvm_mod_ref) - llvm_mod = nothing - llvm_ts_mod() do mod - llvm_mod = mod - end - else - llvm_mod = LLVM.Module(llvm_mod_ref) + + # XXX: this is wrong; we can't expose the underlying LLVM module, but should + # instead always go through the callback in order to unlock it properly. + # rework this once we depend on Julia 1.9 or later. + llvm_ts_mod = LLVM.ThreadSafeModule(llvm_mod_ref) + llvm_mod = nothing + llvm_ts_mod() do mod + llvm_mod = mod end end if !(Sys.ARCH == :x86 || Sys.ARCH == :x86_64) @@ -765,19 +699,12 @@ function compile_method_instance(@nospecialize(job::CompilerJob)) # ensure that the requested method instance was compiled @assert haskey(compiled, job.source) - if VERSION < v"1.9.0-DEV.516" - # configure the module - triple!(llvm_mod, llvm_triple(job.config.target)) - if julia_datalayout(job.config.target) !== nothing - datalayout!(llvm_mod, julia_datalayout(job.config.target)) - end - end - return llvm_mod, compiled end -# Narrow this if JuliaLang/julia#54069 get's backported to 1.11 -@static if v"1.11.0-DEV.1603" <= VERSION < v"1.12.0-DEV.347" +# partially revert JuliaLangjulia#49391 +@static if v"1.11.0-DEV.1603" <= VERSION < v"1.12.0-DEV.347" && # reverted on master + !(v"1.11-beta2" <= VERSION < v"1.12") # reverted on 1.11-beta2 function CC.typeinf(interp::GPUInterpreter, frame::CC.InferenceState) if CC.__measure_typeinf__[] CC.Timings.enter_new_timer(frame) diff --git a/src/optim.jl b/src/optim.jl index 1ae4689b..80033a2b 100644 --- a/src/optim.jl +++ b/src/optim.jl @@ -40,9 +40,6 @@ function buildNewPMPipeline!(mpm, @nospecialize(job::CompilerJob), opt_level) buildEarlySimplificationPipeline(mpm, job, opt_level) add!(mpm, AlwaysInlinerPass()) buildEarlyOptimizerPipeline(mpm, job, opt_level) - if VERSION < v"1.10" - add!(mpm, LowerSIMDLoopPass()) - end add!(mpm, NewPMFunctionPassManager()) do fpm buildLoopOptimizerPipeline(fpm, job, opt_level) buildScalarOptimizerPipeline(fpm, job, opt_level) @@ -133,9 +130,7 @@ end function buildLoopOptimizerPipeline(fpm, @nospecialize(job::CompilerJob), opt_level) add!(fpm, NewPMLoopPassManager()) do lpm - if VERSION >= v"1.10" - add!(lpm, LowerSIMDLoopPass()) - end + add!(lpm, LowerSIMDLoopPass()) if opt_level >= 2 add!(lpm, LoopRotatePass()) end @@ -378,31 +373,7 @@ function optimize_legacypm!(@nospecialize(job::CompilerJob), mod::LLVM.Module; o combine_mul_add!(pm) div_rem_pairs!(pm) - if VERSION < v"1.10.0-DEV.1144" - # save function attributes to work around JuliaGPU/GPUCompiler#437 - current_attrs = Dict{String,Any}() - for f in functions(mod) - attrs = function_attributes(f) - length(attrs) == 0 && continue - current_attrs[LLVM.name(f)] = collect(attrs) - end - end - run!(pm, mod) - - if VERSION < v"1.10.0-DEV.1144" - # restore function attributes - for (fn, attrs) in current_attrs - haskey(functions(mod), fn) || continue - f = functions(mod)[fn] - - for attr in attrs - # NOTE: there's no function attributes that contain a type, - # so we can just blindly add them back - push!(function_attributes(f), attr) - end - end - end end # target-specific optimizations diff --git a/src/reflection.jl b/src/reflection.jl index e421e82a..26ee62bd 100644 --- a/src/reflection.jl +++ b/src/reflection.jl @@ -95,11 +95,9 @@ InteractiveUtils.code_lowered(err::KernelError; kwargs...) = code_lowered(err.jo InteractiveUtils.code_typed(err::KernelError; kwargs...) = code_typed(err.job; kwargs...) InteractiveUtils.code_warntype(err::KernelError; kwargs...) = code_warntype(err.job; kwargs...) -@static if VERSION >= v"1.9.0-DEV.516" - struct jl_llvmf_dump - TSM::LLVM.API.LLVMOrcThreadSafeModuleRef - F::LLVM.API.LLVMValueRef - end +struct jl_llvmf_dump + TSM::LLVM.API.LLVMOrcThreadSafeModuleRef + F::LLVM.API.LLVMValueRef end """ @@ -121,32 +119,13 @@ function code_llvm(io::IO, @nospecialize(job::CompilerJob); optimize::Bool=true, # NOTE: jl_dump_function_ir supports stripping metadata, so don't do it in the driver str = JuliaContext() do ctx ir, meta = compile(:llvm, job; optimize=optimize, strip=false, validate=false, kwargs...) - @static if VERSION >= v"1.9.0-DEV.516" - ts_mod = ThreadSafeModule(ir) - if VERSION >= v"1.9.0-DEV.672" - entry_fn = meta.entry - GC.@preserve ts_mod entry_fn begin - value = Ref(jl_llvmf_dump(ts_mod.ref, entry_fn.ref)) - ccall(:jl_dump_function_ir, Ref{String}, - (Ptr{jl_llvmf_dump}, Bool, Bool, Ptr{UInt8}), - value, !raw, dump_module, debuginfo) - end - else - entry_fn = meta.entry - GC.@preserve ts_mod entry_fn begin - # N.B. jl_dump_function_ir will `Libc.free` the passed-in pointer - value_ptr = reinterpret(Ptr{jl_llvmf_dump}, - Libc.malloc(sizeof(jl_llvmf_dump))) - unsafe_store!(value_ptr, jl_llvmf_dump(ts_mod.ref, entry_fn.ref)) - ccall(:jl_dump_function_ir, Ref{String}, - (Ptr{jl_llvmf_dump}, Bool, Bool, Ptr{UInt8}), - value_ptr, !raw, dump_module, debuginfo) - end - end - else + ts_mod = ThreadSafeModule(ir) + entry_fn = meta.entry + GC.@preserve ts_mod entry_fn begin + value = Ref(jl_llvmf_dump(ts_mod.ref, entry_fn.ref)) ccall(:jl_dump_function_ir, Ref{String}, - (LLVM.API.LLVMValueRef, Bool, Bool, Ptr{UInt8}), - meta.entry, !raw, dump_module, debuginfo) + (Ptr{jl_llvmf_dump}, Bool, Bool, Ptr{UInt8}), + value, !raw, dump_module, debuginfo) end end highlight(io, str, "llvm") diff --git a/src/reflection_compat.jl b/src/reflection_compat.jl index dc578ee1..92467a3d 100644 --- a/src/reflection_compat.jl +++ b/src/reflection_compat.jl @@ -97,23 +97,13 @@ function code_warntype_by_type(io::IO, @nospecialize(tt); end print(io, " ", slotnames[i]) if isa(slottypes, Vector{Any}) - @static if VERSION >= v"1.9.0-DEV.1297" - # https://github.com/JuliaLang/julia/pull/46574 - InteractiveUtils.warntype_type_printer(io; type=slottypes[i], used=true) - else - InteractiveUtils.warntype_type_printer(io, slottypes[i], true) - end + InteractiveUtils.warntype_type_printer(io; type=slottypes[i], used=true) end println(io) end end print(io, "Body") - @static if VERSION >= v"1.9.0-DEV.1297" - # https://github.com/JuliaLang/julia/pull/46574 - InteractiveUtils.warntype_type_printer(io; type=rettype, used=true) - else - InteractiveUtils.warntype_type_printer(io, rettype, true) - end + InteractiveUtils.warntype_type_printer(io; type=rettype, used=true) println(io) irshow_config = Base.IRShow.IRShowConfig(lineprinter(src), InteractiveUtils.warntype_type_printer) diff --git a/src/utils.jl b/src/utils.jl index 2bfb8e13..11cc6ca5 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -94,19 +94,11 @@ end macro locked(ex) def = splitdef(ex) def[:body] = quote - if VERSION >= v"1.9.0-DEV.1308" - ccall(:jl_typeinf_lock_begin, Cvoid, ()) - else - ccall(:jl_typeinf_begin, Cvoid, ()) - end + ccall(:jl_typeinf_lock_begin, Cvoid, ()) try $(def[:body]) finally - if VERSION >= v"1.9.0-DEV.1308" - ccall(:jl_typeinf_lock_end, Cvoid, ()) - else - ccall(:jl_typeinf_end, Cvoid, ()) - end + ccall(:jl_typeinf_lock_end, Cvoid, ()) end end esc(combinedef(def)) @@ -116,19 +108,11 @@ end macro unlocked(ex) def = splitdef(ex) def[:body] = quote - if VERSION >= v"1.9.0-DEV.1308" - ccall(:jl_typeinf_lock_end, Cvoid, ()) - else - ccall(:jl_typeinf_end, Cvoid, ()) - end + ccall(:jl_typeinf_lock_end, Cvoid, ()) try $(def[:body]) finally - if VERSION >= v"1.9.0-DEV.1308" - ccall(:jl_typeinf_lock_begin, Cvoid, ()) - else - ccall(:jl_typeinf_begin, Cvoid, ()) - end + ccall(:jl_typeinf_lock_begin, Cvoid, ()) end end esc(combinedef(def)) diff --git a/test/gcn_tests.jl b/test/gcn_tests.jl index ac083da0..1536dbed 100644 --- a/test/gcn_tests.jl +++ b/test/gcn_tests.jl @@ -1,10 +1,6 @@ @testitem "GCN" setup=[GCN, Helpers] begin -if VERSION >= v"1.9.0-DEV.1018" @inline sink_gcn(i) = sink(i, Val(5)) -else -@inline sink_gcn(i) = sink(i, Val(0)) -end @test GCNCompilerTarget(dev_isa="gfx900") == GCNCompilerTarget("gfx900") @@ -23,19 +19,6 @@ end @test occursin("amdgpu_kernel", ir) end -if VERSION < v"1.9.0-DEV.1018" -@testset "alloca addrspace" begin - function kernel(i) - sink(i, Val(0)) # sink provides an alloca in addrspace 0 - return - end - - ir = sprint(io->GCN.code_llvm(io, kernel, Tuple{Int64}; dump_module=true)) - @test occursin(r"alloca i64, (align 8, )?addrspace\(5\)$"m, ir) - @test !occursin(r"alloca i64(, align \d)?$"m, ir) -end -end - end ############################################################################################ diff --git a/test/native_tests.jl b/test/native_tests.jl index 016c390a..298c1010 100644 --- a/test/native_tests.jl +++ b/test/native_tests.jl @@ -264,10 +264,8 @@ end ir = sprint(io->Native.code_llvm(io, identity, Tuple{Nothing}; entry_safepoint=false, optimize=false, dump_module=true)) @test !occursin("%safepoint", ir) - if v"1.9.0-DEV.1660" <= VERSION < v"1.9.0-alpha1.57" || VERSION >= v"1.10-" - ir = sprint(io->Native.code_llvm(io, identity, Tuple{Nothing}; entry_safepoint=true, optimize=false, dump_module=true)) - @test occursin("%safepoint", ir) - end + ir = sprint(io->Native.code_llvm(io, identity, Tuple{Nothing}; entry_safepoint=true, optimize=false, dump_module=true)) + @test occursin("%safepoint", ir) end @testset "always_inline" begin diff --git a/test/runtests.jl b/test/runtests.jl index 9411dbc7..199e641f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -22,7 +22,7 @@ runtests(GPUCompiler; nworkers=min(Sys.CPU_THREADS,4), nworker_threads=1, end end - if ti.name in ["PTX", "GCN", "PTX precompile"] && Sys.isapple() && VERSION >= v"1.10-" + if ti.name in ["PTX", "GCN", "PTX precompile"] && Sys.isapple() # support for AMDGPU and NVTX on macOS has been removed from Julia's LLVM build return false end