From eec85d5096370dd4e518e99519e6bd55bd2bf053 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Wed, 17 Mar 2021 08:02:54 +0100 Subject: [PATCH] Clean-up version checks. --- src/irgen.jl | 17 ++------------- src/jlgen.jl | 6 +++--- src/reflection.jl | 6 +----- src/rtlib.jl | 34 ++++++++++-------------------- src/runtime.jl | 24 ++------------------- src/validation.jl | 53 +++++++---------------------------------------- test/gcn.jl | 6 +----- test/native.jl | 2 -- test/ptx.jl | 12 ++--------- 9 files changed, 29 insertions(+), 131 deletions(-) diff --git a/src/irgen.jl b/src/irgen.jl index ab3d1e19..6db943fa 100644 --- a/src/irgen.jl +++ b/src/irgen.jl @@ -10,18 +10,6 @@ function irgen(@nospecialize(job::CompilerJob), method_instance::Core.MethodInst # only occurs in debug builds delete!(function_attributes(llvmf), EnumAttribute("sspstrong", 0, ctx)) - if VERSION < v"1.5.0-DEV.393" - # make function names safe for ptxas - llvmfn = LLVM.name(llvmf) - if !isdeclaration(llvmf) - llvmfn′ = safe_name(llvmfn) - if llvmfn != llvmfn′ - LLVM.name!(llvmf, llvmfn′) - llvmfn = llvmfn′ - end - end - end - if Sys.iswindows() personality!(llvmf, nothing) end @@ -315,8 +303,7 @@ function classify_arguments(@nospecialize(job::CompilerJob), codegen_f::LLVM.Fun args = [] codegen_i = 1 for (source_i, source_typ) in enumerate(source_types) - if isghosttype(source_typ) || - (VERSION >= v"1.5.0-DEV.581" && Core.Compiler.isconstType(source_typ)) + if isghosttype(source_typ) || Core.Compiler.isconstType(source_typ) push!(args, (cc=GHOST, typ=source_typ)) continue end @@ -326,7 +313,7 @@ function classify_arguments(@nospecialize(job::CompilerJob), codegen_f::LLVM.Fun push!(args, (cc=MUT_REF, typ=source_typ, codegen=(typ=codegen_typ, i=codegen_i))) elseif codegen_typ isa LLVM.PointerType && issized(eltype(codegen_typ)) && - !(source_typ <: Ptr) && !(VERSION >= v"1.5-" && source_typ <: Core.LLVMPtr) + !(source_typ <: Ptr) && !(source_typ <: Core.LLVMPtr) push!(args, (cc=BITS_REF, typ=source_typ, codegen=(typ=codegen_typ, i=codegen_i))) else diff --git a/src/jlgen.jl b/src/jlgen.jl index d2535672..ba9204bc 100644 --- a/src/jlgen.jl +++ b/src/jlgen.jl @@ -88,7 +88,7 @@ end ## method overrides -@static if VERSION >= v"1.7-" +@static if isdefined(Base.Experimental, Symbol("@overlay")) # use an overlay method table @@ -141,7 +141,7 @@ end by a check to `ccall(:jl_generating_output, Cint, ()) != 0`). """ macro override(mt, ex) - if VERSION >= v"1.7-" + if isdefined(Base.Experimental, Symbol("@overlay")) esc(quote Base.Experimental.@overlay $mt $ex end) @@ -222,7 +222,7 @@ if VERSION >= v"1.7.0-DEV.577" Core.Compiler.verbose_stmt_info(interp::GPUInterpreter) = false end -if VERSION >= v"1.7-" +if isdefined(Base.Experimental, Symbol("@overlay")) Core.Compiler.method_table(interp::GPUInterpreter, sv::InferenceState) = Core.Compiler.OverlayMethodTable(interp.world, interp.method_table) else diff --git a/src/reflection.jl b/src/reflection.jl index 49fa3ea4..aa6f7c9a 100644 --- a/src/reflection.jl +++ b/src/reflection.jl @@ -261,11 +261,7 @@ macro device_code(ex...) end open(joinpath(dir, "$fn.typed.jl"), "w") do io - if VERSION >= v"1.1.0" - code = only(code_typed(job; debuginfo=:source)) - else - code = only(code_typed(job)) - end + code = only(code_typed(job; debuginfo=:source)) println(io, code) end diff --git a/src/rtlib.jl b/src/rtlib.jl index 14c2c7bf..77d08755 100644 --- a/src/rtlib.jl +++ b/src/rtlib.jl @@ -21,16 +21,8 @@ end function cachedir(depot=DEPOT_PATH[1]) # this mimicks Base.compilecache. we can't just call the function, or we might actually # _generate_ a cache file, e.g., when running with `--compiled-modules=no`. - if VERSION >= v"1.3.0-alpha.146" - entrypath, entryfile = Base.cache_file_entry(Base.PkgId(GPUCompiler)) - abspath(depot, entrypath, entryfile) - else - cachefile = abspath(depot, Base.cache_file_entry(Base.PkgId(GPUCompiler))) - - # the cachefile consists of `/depot/compiled/vXXX/GPUCompiler/$slug.ji` - # transform that into `/depot/compiled/vXXX/GPUCompiler/$slug/` - splitext(cachefile)[1] - end + entrypath, entryfile = Base.cache_file_entry(Base.PkgId(GPUCompiler)) + abspath(depot, entrypath, entryfile) end @@ -82,21 +74,17 @@ function emit_function!(mod, @nospecialize(job::CompilerJob), f, method) end # recent Julia versions include prototypes for all runtime functions, even if unused - if VERSION >= v"1.5-" - pm = ModulePassManager() - strip_dead_prototypes!(pm) - run!(pm, new_mod) - dispose(pm) - end + pm = ModulePassManager() + strip_dead_prototypes!(pm) + run!(pm, new_mod) + dispose(pm) temp_name = LLVM.name(entry) - if VERSION >= v"1.6.0-DEV.674" - # FIXME: on 1.6, there's no single global LLVM context anymore, - # but there's no API yet to pass a context to codegen. - # round-trip the module through serialization to get it in the proper context. - buf = convert(MemoryBuffer, new_mod) - new_mod = parse(LLVM.Module, buf, context(mod)) - end + # FIXME: on 1.6, there's no single global LLVM context anymore, + # but there's no API yet to pass a context to codegen. + # round-trip the module through serialization to get it in the proper context. + buf = convert(MemoryBuffer, new_mod) + new_mod = parse(LLVM.Module, buf, context(mod)) @assert context(mod) == context(new_mod) link!(mod, new_mod) entry = functions(mod)[temp_name] diff --git a/src/runtime.jl b/src/runtime.jl index 3c96bf0f..e082249a 100644 --- a/src/runtime.jl +++ b/src/runtime.jl @@ -86,7 +86,7 @@ function compile(def, return_type, types, llvm_return_type=nothing, llvm_types=n if def isa Symbol args = [gensym() for typ in types] @eval @inline $def($(args...)) = - ccall($"extern $llvm_name", llvmcall, $return_type, ($(types...),), $(args...)) + ccall($("extern $llvm_name"), llvmcall, $return_type, ($(types...),), $(args...)) end return @@ -112,29 +112,9 @@ compile(:report_exception_name, Nothing, (Ptr{Cchar},)) ## GC -if VERSION < v"1.4" - -@enum AddressSpace begin - Generic = 1 - Tracked = 10 - Derived = 11 - CalleeRooted = 12 - Loaded = 13 -end - -# LLVM type of a tracked pointer -function T_prjlvalue(ctx) - T_pjlvalue = convert(LLVMType, Any, ctx; allow_boxed=true) - LLVM.PointerType(eltype(T_pjlvalue), Tracked) -end - -else - -# FIXME: once we only support 1.4, get rid of this and allow boxed types +# FIXME: get rid of this and allow boxed types T_prjlvalue(ctx) = convert(LLVMType, Any, ctx; allow_boxed=true) -end - function gc_pool_alloc(sz::Csize_t) ptr = malloc(sz) if ptr == C_NULL diff --git a/src/validation.jl b/src/validation.jl index e4537779..61844cd9 100644 --- a/src/validation.jl +++ b/src/validation.jl @@ -25,10 +25,6 @@ function check_method(@nospecialize(job::CompilerJob)) return end -if VERSION < v"1.1.0-DEV.593" - fieldtypes(@nospecialize(dt)) = ntuple(i->fieldtype(dt, i), fieldcount(dt)) -end - # The actual check is rather complicated # and might change from version to version... function hasfieldcount(@nospecialize(dt)) @@ -60,24 +56,13 @@ function check_invocation(@nospecialize(job::CompilerJob), entry::LLVM.Function) sig = Base.signature_type(job.source.f, job.source.tt)::Type for (arg_i,dt) in enumerate(sig.parameters) isghosttype(dt) && continue - VERSION >= v"1.5.0-DEV.581" && Core.Compiler.isconstType(dt) && continue + Core.Compiler.isconstType(dt) && continue real_arg_i += 1 if !isbitstype(dt) - if VERSION >= v"1.5.0-DEV.581" - throw(KernelError(job, "passing and using non-bitstype argument", - """Argument $arg_i to your kernel function is of type $dt, which is not isbits: - $(explain_nonisbits(dt))""")) - else - # be slightly more lenient pre 1.5, to support `function(::Type, ...)` - param = parameters(entry)[real_arg_i] - if !isempty(uses(param)) - throw(KernelError(job, "passing and using non-bitstype argument", - """Argument $arg_i to your kernel function is of type $dt, which is not isbits: - $(explain_nonisbits(dt)) - Passing non-isbits types is only allowed if they they are unused by the kernel.""")) - end - end + throw(KernelError(job, "passing and using non-bitstype argument", + """Argument $arg_i to your kernel function is of type $dt, which is not isbits: + $(explain_nonisbits(dt))""")) end end @@ -167,15 +152,7 @@ function check_ir!(job, errors::Vector{IRError}, inst::LLVM.CallInst) end elseif fn == "jl_invoke" try - if VERSION < v"1.3.0-DEV.244" - meth, args, nargs, _ = operands(inst) - else - f, args, nargs, meth = operands(inst) - end - if VERSION < v"1.5.0-DEV.802" - # addrspacecast - meth = first(operands(meth::ConstantExpr)) - end + f, args, nargs, meth = operands(inst) meth = first(operands(meth::ConstantExpr))::ConstantInt meth = convert(Int, meth) meth = Ptr{Cvoid}(meth) @@ -187,19 +164,7 @@ function check_ir!(job, errors::Vector{IRError}, inst::LLVM.CallInst) end elseif fn == "jl_apply_generic" try - if VERSION < v"1.3.0-DEV.244" - args, nargs, _ = operands(inst) - ## args is a buffer where arguments are stored in - f, args = user.(uses(args)) - ## first store into the args buffer is a direct store - f = first(operands(f::LLVM.StoreInst))::ConstantExpr - else - f, args, nargs, _ = operands(inst) - end - - if VERSION < v"1.5.0-DEV.802" - f = first(operands(f::ConstantExpr)) # get rid of addrspacecast - end + f, args, nargs, _ = operands(inst) f = first(operands(f))::ConstantInt # get rid of inttoptr f = convert(Int, f) f = Ptr{Cvoid}(f) @@ -245,11 +210,7 @@ function check_ir!(job, errors::Vector{IRError}, inst::LLVM.CallInst) frames = ccall(:jl_lookup_code_address, Any, (Ptr{Cvoid}, Cint,), ptr, 0) if length(frames) >= 1 @compiler_assert length(frames) == 1 job frames=frames - if VERSION >= v"1.4.0-DEV.123" - fn, file, line, linfo, fromC, inlined = last(frames) - else - fn, file, line, linfo, fromC, inlined, ip = last(frames) - end + fn, file, line, linfo, fromC, inlined = last(frames) push!(errors, (POINTER_FUNCTION, bt, fn)) else push!(errors, (POINTER_FUNCTION, bt, nothing)) diff --git a/test/gcn.jl b/test/gcn.jl index 765287c5..4f8b1ef3 100644 --- a/test/gcn.jl +++ b/test/gcn.jl @@ -194,11 +194,7 @@ end asm = sprint(io->gcn_code_native(io, ref_kernel, Tuple{Ptr{Int64}, Int})) - if VERSION < v"1.2.0-DEV.375" - @test_broken !occursin("gpu_gc_pool_alloc", asm) - else - @test !occursin("gpu_gc_pool_alloc", asm) - end + @test !occursin("gpu_gc_pool_alloc", asm) end =# diff --git a/test/native.jl b/test/native.jl index c044c0c8..bfacce08 100644 --- a/test/native.jl +++ b/test/native.jl @@ -124,7 +124,6 @@ end native_code_llvm(devnull, kernel, Tuple{Vector{Int}}; kernel=true) end -if VERSION >= v"1.0.2" @testset "CUDAnative.jl#278" begin # codegen idempotency # NOTE: this isn't fixed, but surfaces here due to bad inference of checked_sub @@ -137,7 +136,6 @@ if VERSION >= v"1.0.2" # even in the presence of the above bug native_code_llvm(devnull, Base.print_to_string, Tuple{Int,Int}; optimize=false) end -end @testset "LLVM D32593" begin @eval struct D32593_struct diff --git a/test/ptx.jl b/test/ptx.jl index 9550f060..10e3b685 100644 --- a/test/ptx.jl +++ b/test/ptx.jl @@ -25,11 +25,7 @@ end end ir = sprint(io->ptx_code_llvm(io, kernel, Tuple{Aggregate})) - if VERSION < v"1.5.0-DEV.802" - @test occursin(r"@.*julia_kernel.+\(({ i64 }|\[1 x i64\]) addrspace\(\d+\)?\*", ir) - else - @test occursin(r"@.*julia_kernel.+\(({ i64 }|\[1 x i64\])\*", ir) - end + @test occursin(r"@.*julia_kernel.+\(({ i64 }|\[1 x i64\])\*", ir) ir = sprint(io->ptx_code_llvm(io, kernel, Tuple{Aggregate}; kernel=true)) @test occursin(r"@.*julia_kernel.+\(({ i64 }|\[1 x i64\])", ir) @@ -247,11 +243,7 @@ end asm = sprint(io->ptx_code_native(io, ref_kernel, Tuple{Ptr{Int64}, Int})) - if VERSION < v"1.2.0-DEV.375" - @test_broken !occursin("gpu_gc_pool_alloc", asm) - else - @test !occursin("gpu_gc_pool_alloc", asm) - end + @test !occursin("gpu_gc_pool_alloc", asm) end @testset "float boxes" begin