Skip to content

Commit eec85d5

Browse files
committed
Clean-up version checks.
1 parent 8dacba3 commit eec85d5

9 files changed

+29
-131
lines changed

src/irgen.jl

+2-15
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,6 @@ function irgen(@nospecialize(job::CompilerJob), method_instance::Core.MethodInst
1010
# only occurs in debug builds
1111
delete!(function_attributes(llvmf), EnumAttribute("sspstrong", 0, ctx))
1212

13-
if VERSION < v"1.5.0-DEV.393"
14-
# make function names safe for ptxas
15-
llvmfn = LLVM.name(llvmf)
16-
if !isdeclaration(llvmf)
17-
llvmfn′ = safe_name(llvmfn)
18-
if llvmfn != llvmfn′
19-
LLVM.name!(llvmf, llvmfn′)
20-
llvmfn = llvmfn′
21-
end
22-
end
23-
end
24-
2513
if Sys.iswindows()
2614
personality!(llvmf, nothing)
2715
end
@@ -315,8 +303,7 @@ function classify_arguments(@nospecialize(job::CompilerJob), codegen_f::LLVM.Fun
315303
args = []
316304
codegen_i = 1
317305
for (source_i, source_typ) in enumerate(source_types)
318-
if isghosttype(source_typ) ||
319-
(VERSION >= v"1.5.0-DEV.581" && Core.Compiler.isconstType(source_typ))
306+
if isghosttype(source_typ) || Core.Compiler.isconstType(source_typ)
320307
push!(args, (cc=GHOST, typ=source_typ))
321308
continue
322309
end
@@ -326,7 +313,7 @@ function classify_arguments(@nospecialize(job::CompilerJob), codegen_f::LLVM.Fun
326313
push!(args, (cc=MUT_REF, typ=source_typ,
327314
codegen=(typ=codegen_typ, i=codegen_i)))
328315
elseif codegen_typ isa LLVM.PointerType && issized(eltype(codegen_typ)) &&
329-
!(source_typ <: Ptr) && !(VERSION >= v"1.5-" && source_typ <: Core.LLVMPtr)
316+
!(source_typ <: Ptr) && !(source_typ <: Core.LLVMPtr)
330317
push!(args, (cc=BITS_REF, typ=source_typ,
331318
codegen=(typ=codegen_typ, i=codegen_i)))
332319
else

src/jlgen.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ end
8888

8989
## method overrides
9090

91-
@static if VERSION >= v"1.7-"
91+
@static if isdefined(Base.Experimental, Symbol("@overlay"))
9292

9393
# use an overlay method table
9494

@@ -141,7 +141,7 @@ end
141141
by a check to `ccall(:jl_generating_output, Cint, ()) != 0`).
142142
"""
143143
macro override(mt, ex)
144-
if VERSION >= v"1.7-"
144+
if isdefined(Base.Experimental, Symbol("@overlay"))
145145
esc(quote
146146
Base.Experimental.@overlay $mt $ex
147147
end)
@@ -222,7 +222,7 @@ if VERSION >= v"1.7.0-DEV.577"
222222
Core.Compiler.verbose_stmt_info(interp::GPUInterpreter) = false
223223
end
224224

225-
if VERSION >= v"1.7-"
225+
if isdefined(Base.Experimental, Symbol("@overlay"))
226226
Core.Compiler.method_table(interp::GPUInterpreter, sv::InferenceState) =
227227
Core.Compiler.OverlayMethodTable(interp.world, interp.method_table)
228228
else

src/reflection.jl

+1-5
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,7 @@ macro device_code(ex...)
261261
end
262262

263263
open(joinpath(dir, "$fn.typed.jl"), "w") do io
264-
if VERSION >= v"1.1.0"
265-
code = only(code_typed(job; debuginfo=:source))
266-
else
267-
code = only(code_typed(job))
268-
end
264+
code = only(code_typed(job; debuginfo=:source))
269265
println(io, code)
270266
end
271267

src/rtlib.jl

+11-23
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,8 @@ end
2121
function cachedir(depot=DEPOT_PATH[1])
2222
# this mimicks Base.compilecache. we can't just call the function, or we might actually
2323
# _generate_ a cache file, e.g., when running with `--compiled-modules=no`.
24-
if VERSION >= v"1.3.0-alpha.146"
25-
entrypath, entryfile = Base.cache_file_entry(Base.PkgId(GPUCompiler))
26-
abspath(depot, entrypath, entryfile)
27-
else
28-
cachefile = abspath(depot, Base.cache_file_entry(Base.PkgId(GPUCompiler)))
29-
30-
# the cachefile consists of `/depot/compiled/vXXX/GPUCompiler/$slug.ji`
31-
# transform that into `/depot/compiled/vXXX/GPUCompiler/$slug/`
32-
splitext(cachefile)[1]
33-
end
24+
entrypath, entryfile = Base.cache_file_entry(Base.PkgId(GPUCompiler))
25+
abspath(depot, entrypath, entryfile)
3426
end
3527

3628

@@ -82,21 +74,17 @@ function emit_function!(mod, @nospecialize(job::CompilerJob), f, method)
8274
end
8375

8476
# recent Julia versions include prototypes for all runtime functions, even if unused
85-
if VERSION >= v"1.5-"
86-
pm = ModulePassManager()
87-
strip_dead_prototypes!(pm)
88-
run!(pm, new_mod)
89-
dispose(pm)
90-
end
77+
pm = ModulePassManager()
78+
strip_dead_prototypes!(pm)
79+
run!(pm, new_mod)
80+
dispose(pm)
9181

9282
temp_name = LLVM.name(entry)
93-
if VERSION >= v"1.6.0-DEV.674"
94-
# FIXME: on 1.6, there's no single global LLVM context anymore,
95-
# but there's no API yet to pass a context to codegen.
96-
# round-trip the module through serialization to get it in the proper context.
97-
buf = convert(MemoryBuffer, new_mod)
98-
new_mod = parse(LLVM.Module, buf, context(mod))
99-
end
83+
# FIXME: on 1.6, there's no single global LLVM context anymore,
84+
# but there's no API yet to pass a context to codegen.
85+
# round-trip the module through serialization to get it in the proper context.
86+
buf = convert(MemoryBuffer, new_mod)
87+
new_mod = parse(LLVM.Module, buf, context(mod))
10088
@assert context(mod) == context(new_mod)
10189
link!(mod, new_mod)
10290
entry = functions(mod)[temp_name]

src/runtime.jl

+2-22
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function compile(def, return_type, types, llvm_return_type=nothing, llvm_types=n
8686
if def isa Symbol
8787
args = [gensym() for typ in types]
8888
@eval @inline $def($(args...)) =
89-
ccall($"extern $llvm_name", llvmcall, $return_type, ($(types...),), $(args...))
89+
ccall($("extern $llvm_name"), llvmcall, $return_type, ($(types...),), $(args...))
9090
end
9191

9292
return
@@ -112,29 +112,9 @@ compile(:report_exception_name, Nothing, (Ptr{Cchar},))
112112

113113
## GC
114114

115-
if VERSION < v"1.4"
116-
117-
@enum AddressSpace begin
118-
Generic = 1
119-
Tracked = 10
120-
Derived = 11
121-
CalleeRooted = 12
122-
Loaded = 13
123-
end
124-
125-
# LLVM type of a tracked pointer
126-
function T_prjlvalue(ctx)
127-
T_pjlvalue = convert(LLVMType, Any, ctx; allow_boxed=true)
128-
LLVM.PointerType(eltype(T_pjlvalue), Tracked)
129-
end
130-
131-
else
132-
133-
# FIXME: once we only support 1.4, get rid of this and allow boxed types
115+
# FIXME: get rid of this and allow boxed types
134116
T_prjlvalue(ctx) = convert(LLVMType, Any, ctx; allow_boxed=true)
135117

136-
end
137-
138118
function gc_pool_alloc(sz::Csize_t)
139119
ptr = malloc(sz)
140120
if ptr == C_NULL

src/validation.jl

+7-46
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ function check_method(@nospecialize(job::CompilerJob))
2525
return
2626
end
2727

28-
if VERSION < v"1.1.0-DEV.593"
29-
fieldtypes(@nospecialize(dt)) = ntuple(i->fieldtype(dt, i), fieldcount(dt))
30-
end
31-
3228
# The actual check is rather complicated
3329
# and might change from version to version...
3430
function hasfieldcount(@nospecialize(dt))
@@ -60,24 +56,13 @@ function check_invocation(@nospecialize(job::CompilerJob), entry::LLVM.Function)
6056
sig = Base.signature_type(job.source.f, job.source.tt)::Type
6157
for (arg_i,dt) in enumerate(sig.parameters)
6258
isghosttype(dt) && continue
63-
VERSION >= v"1.5.0-DEV.581" && Core.Compiler.isconstType(dt) && continue
59+
Core.Compiler.isconstType(dt) && continue
6460
real_arg_i += 1
6561

6662
if !isbitstype(dt)
67-
if VERSION >= v"1.5.0-DEV.581"
68-
throw(KernelError(job, "passing and using non-bitstype argument",
69-
"""Argument $arg_i to your kernel function is of type $dt, which is not isbits:
70-
$(explain_nonisbits(dt))"""))
71-
else
72-
# be slightly more lenient pre 1.5, to support `function(::Type, ...)`
73-
param = parameters(entry)[real_arg_i]
74-
if !isempty(uses(param))
75-
throw(KernelError(job, "passing and using non-bitstype argument",
76-
"""Argument $arg_i to your kernel function is of type $dt, which is not isbits:
77-
$(explain_nonisbits(dt))
78-
Passing non-isbits types is only allowed if they they are unused by the kernel."""))
79-
end
80-
end
63+
throw(KernelError(job, "passing and using non-bitstype argument",
64+
"""Argument $arg_i to your kernel function is of type $dt, which is not isbits:
65+
$(explain_nonisbits(dt))"""))
8166
end
8267
end
8368

@@ -167,15 +152,7 @@ function check_ir!(job, errors::Vector{IRError}, inst::LLVM.CallInst)
167152
end
168153
elseif fn == "jl_invoke"
169154
try
170-
if VERSION < v"1.3.0-DEV.244"
171-
meth, args, nargs, _ = operands(inst)
172-
else
173-
f, args, nargs, meth = operands(inst)
174-
end
175-
if VERSION < v"1.5.0-DEV.802"
176-
# addrspacecast
177-
meth = first(operands(meth::ConstantExpr))
178-
end
155+
f, args, nargs, meth = operands(inst)
179156
meth = first(operands(meth::ConstantExpr))::ConstantInt
180157
meth = convert(Int, meth)
181158
meth = Ptr{Cvoid}(meth)
@@ -187,19 +164,7 @@ function check_ir!(job, errors::Vector{IRError}, inst::LLVM.CallInst)
187164
end
188165
elseif fn == "jl_apply_generic"
189166
try
190-
if VERSION < v"1.3.0-DEV.244"
191-
args, nargs, _ = operands(inst)
192-
## args is a buffer where arguments are stored in
193-
f, args = user.(uses(args))
194-
## first store into the args buffer is a direct store
195-
f = first(operands(f::LLVM.StoreInst))::ConstantExpr
196-
else
197-
f, args, nargs, _ = operands(inst)
198-
end
199-
200-
if VERSION < v"1.5.0-DEV.802"
201-
f = first(operands(f::ConstantExpr)) # get rid of addrspacecast
202-
end
167+
f, args, nargs, _ = operands(inst)
203168
f = first(operands(f))::ConstantInt # get rid of inttoptr
204169
f = convert(Int, f)
205170
f = Ptr{Cvoid}(f)
@@ -245,11 +210,7 @@ function check_ir!(job, errors::Vector{IRError}, inst::LLVM.CallInst)
245210
frames = ccall(:jl_lookup_code_address, Any, (Ptr{Cvoid}, Cint,), ptr, 0)
246211
if length(frames) >= 1
247212
@compiler_assert length(frames) == 1 job frames=frames
248-
if VERSION >= v"1.4.0-DEV.123"
249-
fn, file, line, linfo, fromC, inlined = last(frames)
250-
else
251-
fn, file, line, linfo, fromC, inlined, ip = last(frames)
252-
end
213+
fn, file, line, linfo, fromC, inlined = last(frames)
253214
push!(errors, (POINTER_FUNCTION, bt, fn))
254215
else
255216
push!(errors, (POINTER_FUNCTION, bt, nothing))

test/gcn.jl

+1-5
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,7 @@ end
194194
asm = sprint(io->gcn_code_native(io, ref_kernel, Tuple{Ptr{Int64}, Int}))
195195
196196
197-
if VERSION < v"1.2.0-DEV.375"
198-
@test_broken !occursin("gpu_gc_pool_alloc", asm)
199-
else
200-
@test !occursin("gpu_gc_pool_alloc", asm)
201-
end
197+
@test !occursin("gpu_gc_pool_alloc", asm)
202198
end
203199
=#
204200

test/native.jl

-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ end
124124
native_code_llvm(devnull, kernel, Tuple{Vector{Int}}; kernel=true)
125125
end
126126

127-
if VERSION >= v"1.0.2"
128127
@testset "CUDAnative.jl#278" begin
129128
# codegen idempotency
130129
# 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"
137136
# even in the presence of the above bug
138137
native_code_llvm(devnull, Base.print_to_string, Tuple{Int,Int}; optimize=false)
139138
end
140-
end
141139

142140
@testset "LLVM D32593" begin
143141
@eval struct D32593_struct

test/ptx.jl

+2-10
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ end
2525
end
2626

2727
ir = sprint(io->ptx_code_llvm(io, kernel, Tuple{Aggregate}))
28-
if VERSION < v"1.5.0-DEV.802"
29-
@test occursin(r"@.*julia_kernel.+\(({ i64 }|\[1 x i64\]) addrspace\(\d+\)?\*", ir)
30-
else
31-
@test occursin(r"@.*julia_kernel.+\(({ i64 }|\[1 x i64\])\*", ir)
32-
end
28+
@test occursin(r"@.*julia_kernel.+\(({ i64 }|\[1 x i64\])\*", ir)
3329

3430
ir = sprint(io->ptx_code_llvm(io, kernel, Tuple{Aggregate}; kernel=true))
3531
@test occursin(r"@.*julia_kernel.+\(({ i64 }|\[1 x i64\])", ir)
@@ -247,11 +243,7 @@ end
247243
asm = sprint(io->ptx_code_native(io, ref_kernel, Tuple{Ptr{Int64}, Int}))
248244

249245

250-
if VERSION < v"1.2.0-DEV.375"
251-
@test_broken !occursin("gpu_gc_pool_alloc", asm)
252-
else
253-
@test !occursin("gpu_gc_pool_alloc", asm)
254-
end
246+
@test !occursin("gpu_gc_pool_alloc", asm)
255247
end
256248

257249
@testset "float boxes" begin

0 commit comments

Comments
 (0)