Skip to content

Commit b4e4ba7

Browse files
authored
restrict optimize_until argument type correctly (#56912)
The object types that `optimize_until` can accept are restricted by `matchpass`, so this restriction should also be reflected in functions like `typeinf_ircode` too.
1 parent 8788497 commit b4e4ba7

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

Compiler/src/optimize.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ function run_passes_ipo_safe(
10251025
optimize_until = nothing, # run all passes by default
10261026
)
10271027
__stage__ = 0 # used by @pass
1028-
# NOTE: The pass name MUST be unique for `optimize_until::AbstractString` to work
1028+
# NOTE: The pass name MUST be unique for `optimize_until::String` to work
10291029
@pass "convert" ir = convert_to_ircode(ci, sv)
10301030
@pass "slot2reg" ir = slot2reg(ir, ci, sv)
10311031
# TODO: Domsorting can produce an updated domtree - no need to recompute here

Compiler/src/typeinfer.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -977,23 +977,23 @@ end
977977

978978
"""
979979
typeinf_ircode(interp::AbstractInterpreter, match::MethodMatch,
980-
optimize_until::Union{Integer,AbstractString,Nothing}) -> (ir::Union{IRCode,Nothing}, returntype::Type)
980+
optimize_until::Union{Int,String,Nothing}) -> (ir::Union{IRCode,Nothing}, returntype::Type)
981981
typeinf_ircode(interp::AbstractInterpreter,
982982
method::Method, atype, sparams::SimpleVector,
983-
optimize_until::Union{Integer,AbstractString,Nothing}) -> (ir::Union{IRCode,Nothing}, returntype::Type)
983+
optimize_until::Union{Int,String,Nothing}) -> (ir::Union{IRCode,Nothing}, returntype::Type)
984984
typeinf_ircode(interp::AbstractInterpreter, mi::MethodInstance,
985-
optimize_until::Union{Integer,AbstractString,Nothing}) -> (ir::Union{IRCode,Nothing}, returntype::Type)
985+
optimize_until::Union{Int,String,Nothing}) -> (ir::Union{IRCode,Nothing}, returntype::Type)
986986
987987
Infer a `method` and return an `IRCode` with inferred `returntype` on success.
988988
"""
989989
typeinf_ircode(interp::AbstractInterpreter, match::MethodMatch,
990-
optimize_until::Union{Integer,AbstractString,Nothing}) =
990+
optimize_until::Union{Int,String,Nothing}) =
991991
typeinf_ircode(interp, specialize_method(match), optimize_until)
992992
typeinf_ircode(interp::AbstractInterpreter, method::Method, @nospecialize(atype), sparams::SimpleVector,
993-
optimize_until::Union{Integer,AbstractString,Nothing}) =
993+
optimize_until::Union{Int,String,Nothing}) =
994994
typeinf_ircode(interp, specialize_method(method, atype, sparams), optimize_until)
995995
function typeinf_ircode(interp::AbstractInterpreter, mi::MethodInstance,
996-
optimize_until::Union{Integer,AbstractString,Nothing})
996+
optimize_until::Union{Int,String,Nothing})
997997
frame = typeinf_frame(interp, mi, false)
998998
if frame === nothing
999999
return nothing, Any

base/reflection.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ internals.
463463
when looking up methods, use current world age if not specified.
464464
- `interp::Core.Compiler.AbstractInterpreter = Core.Compiler.NativeInterpreter(world)`:
465465
optional, controls the abstract interpreter to use, use the native interpreter if not specified.
466-
- `optimize_until::Union{Integer,AbstractString,Nothing} = nothing`: optional,
466+
- `optimize_until::Union{Int,String,Nothing} = nothing`: optional,
467467
controls the optimization passes to run.
468468
If it is a string, it specifies the name of the pass up to which the optimizer is run.
469469
If it is an integer, it specifies the number of passes to run.
@@ -507,7 +507,7 @@ function code_ircode_by_type(
507507
@nospecialize(tt::Type);
508508
world::UInt=get_world_counter(),
509509
interp=nothing,
510-
optimize_until::Union{Integer,AbstractString,Nothing}=nothing,
510+
optimize_until::Union{Int,String,Nothing}=nothing,
511511
)
512512
passed_interp = interp
513513
interp = passed_interp === nothing ? invoke_default_compiler(:_default_interp, world) : interp

0 commit comments

Comments
 (0)