Skip to content

Commit 425605f

Browse files
authored
adjust to the latest compiler changes (#264)
1 parent e702e32 commit 425605f

File tree

6 files changed

+29
-21
lines changed

6 files changed

+29
-21
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
version:
20-
- '^1.10.0-0'
20+
- '1.10'
2121
- 'nightly'
2222
os:
2323
- ubuntu-latest
2424
- macOS-latest
25-
# FIXME
26-
# - windows-latest
25+
# FIXME - windows-latest
2726
arch:
2827
- x64
2928
include:

src/Diffractor.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ const CC = Core.Compiler
99

1010
const GENERATORS = Expr[]
1111

12+
@static if VERSION v"1.11.0-DEV.1498"
13+
import .CC: get_inference_world
14+
using Base: get_world_counter
15+
else
16+
import .CC: get_world_counter, get_world_counter as get_inference_world
17+
end
18+
1219
@recompile_invalidations begin
1320
include("runtime.jl")
1421
include("interface.jl")

src/codegen/forward_demand.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,11 @@ function forward_diff!(interp::ADInterpreter, ir::IRCode, src::CodeInfo, mi::Met
352352

353353
method_info = CC.MethodInfo(src)
354354
argtypes = ir.argtypes[1:mi.def.nargs]
355-
world = CC.get_world_counter(interp)
355+
world = get_inference_world(interp)
356356
irsv = IRInterpretationState(interp, method_info, ir, mi, argtypes, world, src.min_world, src.max_world)
357357
rt = CC._ir_abstract_constant_propagation(interp, irsv)
358358

359359
ir = compact!(ir)
360-
360+
361361
return ir
362362
end

src/debugutils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ using Core.Compiler: AbstractInterpreter, CodeInstance, MethodInstance, WorldVie
22
using InteractiveUtils
33

44
function infer_function(interp, tt)
5-
world = Core.Compiler.get_world_counter()
5+
world = get_world_counter()
66

77
# Find all methods that are applicable to these types
88
mthds = _methods_by_ftype(tt, -1, world)
@@ -43,12 +43,12 @@ ExtractingInterpreter(;optimize=false) = ExtractingInterpreter(
4343
optimize
4444
)
4545

46-
import Core.Compiler: InferenceParams, OptimizationParams, get_world_counter,
46+
import Core.Compiler: InferenceParams, OptimizationParams, #=get_inference_world,=#
4747
get_inference_cache, code_cache,
4848
WorldView, lock_mi_inference, unlock_mi_inference, InferenceState
4949
InferenceParams(ei::ExtractingInterpreter) = InferenceParams(ei.native_interpreter)
5050
OptimizationParams(ei::ExtractingInterpreter) = OptimizationParams(ei.native_interpreter)
51-
get_world_counter(ei::ExtractingInterpreter) = get_world_counter(ei.native_interpreter)
51+
get_inference_world(ei::ExtractingInterpreter) = get_inference_world(ei.native_interpreter)
5252
get_inference_cache(ei::ExtractingInterpreter) = get_inference_cache(ei.native_interpreter)
5353

5454
# No need to do any locking since we're not putting our results into the runtime cache

src/stage1/termination.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ which(Tuple{∂⃖{N}, ∂⃖{1}, Vararg{Any}} where {N}).recursion_relation = f
4444
isa(Base.unwrap_unionall(new_sig.parameters[1].parameters[1]), Int)
4545
end
4646

47-
for (;method) in Base._methods_by_ftype(Tuple{Diffractor.∂☆recurse{N}, Vararg{Any}} where {N}, nothing, -1, Base.get_world_counter())
47+
for (;method) in Base._methods_by_ftype(Tuple{Diffractor.∂☆recurse{N}, Vararg{Any}} where {N}, nothing, -1, get_world_counter())
4848
method.recursion_relation = function (method1, method2, parent_sig, new_sig)
4949
# Recursion from a higher to a lower order is always allowed
5050
parent_order = parent_sig.parameters[1].parameters[1]
@@ -57,13 +57,13 @@ for (;method) in Base._methods_by_ftype(Tuple{Diffractor.∂☆recurse{N}, Varar
5757
end
5858
end
5959

60-
for (;method) in Base._methods_by_ftype(Tuple{Diffractor.∂☆internal{N}, Vararg{Any}} where {N}, nothing, -1, Base.get_world_counter())
60+
for (;method) in Base._methods_by_ftype(Tuple{Diffractor.∂☆internal{N}, Vararg{Any}} where {N}, nothing, -1, get_world_counter())
6161
method.recursion_relation = function (method1, method2, parent_sig, new_sig)
6262
return true
6363
end
6464
end
6565

66-
for (;method) in Base._methods_by_ftype(Tuple{Diffractor.∂☆{N}, Vararg{Any}} where {N}, nothing, -1, Base.get_world_counter())
66+
for (;method) in Base._methods_by_ftype(Tuple{Diffractor.∂☆{N}, Vararg{Any}} where {N}, nothing, -1, get_world_counter())
6767
method.recursion_relation = function (method1, method2, parent_sig, new_sig)
6868
return true
6969
end

src/stage2/interpreter.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ end
253253

254254
CC.InferenceParams(ei::ADInterpreter) = InferenceParams(ei.native_interpreter)
255255
CC.OptimizationParams(ei::ADInterpreter) = OptimizationParams(ei.native_interpreter)
256-
CC.get_world_counter(ei::ADInterpreter) = get_world_counter(ei.native_interpreter)
256+
#=CC.=#get_inference_world(ei::ADInterpreter) = get_inference_world(ei.native_interpreter)
257257
CC.get_inference_cache(ei::ADInterpreter) = get_inference_cache(ei.native_interpreter)
258258

259259
# No need to do any locking since we're not putting our results into the runtime cache
@@ -325,15 +325,6 @@ function CC.inlining_policy(interp::ADInterpreter,
325325
mi::MethodInstance, argtypes::Vector{Any})
326326
end
327327

328-
# TODO remove this overload once https://github.com/JuliaLang/julia/pull/49191 gets merged
329-
function CC.abstract_call_gf_by_type(interp::ADInterpreter, @nospecialize(f),
330-
arginfo::ArgInfo, si::StmtInfo, @nospecialize(atype),
331-
sv::IRInterpretationState, max_methods::Int)
332-
return @invoke CC.abstract_call_gf_by_type(interp::AbstractInterpreter, f::Any,
333-
arginfo::ArgInfo, si::StmtInfo, atype::Any,
334-
sv::CC.AbsIntState, max_methods::Int)
335-
end
336-
337328
#=
338329
function CC.optimize(interp::ADInterpreter, opt::OptimizationState,
339330
params::OptimizationParams, caller::InferenceResult)
@@ -362,6 +353,17 @@ else
362353
CC.finish!(::ADInterpreter, caller::InferenceResult) = _finish!(caller)
363354
end
364355

356+
@static if VERSION v"1.11.0-DEV.1278"
357+
function CC.bail_out_const_call(interp::ADInterpreter, result::CC.MethodCallResult,
358+
si::StmtInfo, sv::CC.AbsIntState)
359+
if result.rt isa CC.LimitedAccuracy
360+
return false
361+
end
362+
return @invoke CC.bail_out_const_call(interp::AbstractInterpreter, result::CC.MethodCallResult,
363+
si::StmtInfo, sv::CC.AbsIntState)
364+
end
365+
end
366+
365367
function ir2codeinst(ir::IRCode, inst::CodeInstance, ci::CodeInfo)
366368
CodeInstance(inst.def, inst.rettype, isdefined(inst, :rettype_const) ? inst.rettype_const : nothing,
367369
Cthulhu.OptimizedSource(CC.copy(ir), ci, inst.inferred.isinlineable, CC.decode_effects(inst.purity_bits)),

0 commit comments

Comments
 (0)