Skip to content

Commit 46477cc

Browse files
Kenooscarddssmith
andauthored
Delete trust_inference option (#50432)
* Flip trust_inference option I think the time has come to flip this. This was added when the type system was much less reliable at producing intersections. It is true that we still have the occasional type sytem bug, but we're already trusting inference in a bunch of other places. At the same time, the cost of this has grown in terms of bloated IR needing to be visited in places like irinterp, so let's flip the bit and we'll deal with type system bugs the way we usually due. * refactor to remove trust_inference entirely --------- Co-authored-by: oscarddssmith <[email protected]>
1 parent c09efd9 commit 46477cc

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

base/compiler/ssair/inlining.jl

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ function cfg_inline_unionsplit!(ir::IRCode, idx::Int,
236236
push!(from_bbs, length(state.new_cfg_blocks))
237237
# TODO: Right now we unconditionally generate a fallback block
238238
# in case of subtyping errors - This is probably unnecessary.
239-
if i != length(cases) || (!fully_covered || (!params.trust_inference))
239+
if i != length(cases) || (!fully_covered)
240240
# This block will have the next condition or the final else case
241241
push!(state.new_cfg_blocks, BasicBlock(StmtRange(idx, idx)))
242242
push!(state.new_cfg_blocks[cond_bb].succs, length(state.new_cfg_blocks))
@@ -575,7 +575,7 @@ function ir_inline_unionsplit!(compact::IncrementalCompact, idx::Int,
575575
cond = true
576576
nparams = fieldcount(atype)
577577
@assert nparams == fieldcount(mtype)
578-
if i != ncases || !fully_covered || !params.trust_inference
578+
if i != ncases || !fully_covered
579579
for i = 1:nparams
580580
a, m = fieldtype(atype, i), fieldtype(mtype, i)
581581
# If this is always true, we don't need to check for it
@@ -630,14 +630,7 @@ function ir_inline_unionsplit!(compact::IncrementalCompact, idx::Int,
630630
end
631631
bb += 1
632632
# We're now in the fall through block, decide what to do
633-
if fully_covered
634-
if !params.trust_inference
635-
e = Expr(:call, GlobalRef(Core, :throw), FATAL_TYPE_BOUND_ERROR)
636-
insert_node_here!(compact, NewInstruction(e, Union{}, line))
637-
insert_node_here!(compact, NewInstruction(ReturnNode(), Union{}, line))
638-
finish_current_bb!(compact, 0)
639-
end
640-
else
633+
if !fully_covered
641634
ssa = insert_node_here!(compact, NewInstruction(stmt, typ, line))
642635
push!(pn.edges, bb)
643636
push!(pn.values, ssa)

base/compiler/types.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,6 @@ Parameters that control optimizer operation.
247247
generating `:invoke` expression based on the [`@nospecialize`](@ref) annotation,
248248
in order to avoid over-specialization.
249249
---
250-
- `opt_params.trust_inference::Bool = false`\\
251-
If `false`, the inliner will unconditionally generate a fallback block when union-splitting
252-
a callsite, in case of existing subtyping bugs. This option may be removed in the future.
253-
---
254250
- `opt_params.assume_fatal_throw::Bool = false`\\
255251
If `true`, gives the optimizer license to assume that any `throw` is fatal and thus the
256252
state after a `throw` is not externally observable. In particular, this gives the
@@ -266,7 +262,6 @@ struct OptimizationParams
266262
inline_error_path_cost::Int
267263
max_tuple_splat::Int
268264
compilesig_invokes::Bool
269-
trust_inference::Bool
270265
assume_fatal_throw::Bool
271266

272267
function OptimizationParams(
@@ -277,7 +272,6 @@ struct OptimizationParams
277272
inline_error_path_cost::Int,
278273
max_tuple_splat::Int,
279274
compilesig_invokes::Bool,
280-
trust_inference::Bool,
281275
assume_fatal_throw::Bool)
282276
return new(
283277
inlining,
@@ -287,7 +281,6 @@ struct OptimizationParams
287281
inline_error_path_cost,
288282
max_tuple_splat,
289283
compilesig_invokes,
290-
trust_inference,
291284
assume_fatal_throw)
292285
end
293286
end
@@ -300,7 +293,6 @@ function OptimizationParams(
300293
#=inline_error_path_cost::Int=# 20,
301294
#=max_tuple_splat::Int=# 32,
302295
#=compilesig_invokes::Bool=# true,
303-
#=trust_inference::Bool=# false,
304296
#=assume_fatal_throw::Bool=# false);
305297
inlining::Bool = params.inlining,
306298
inline_cost_threshold::Int = params.inline_cost_threshold,
@@ -309,7 +301,6 @@ function OptimizationParams(
309301
inline_error_path_cost::Int = params.inline_error_path_cost,
310302
max_tuple_splat::Int = params.max_tuple_splat,
311303
compilesig_invokes::Bool = params.compilesig_invokes,
312-
trust_inference::Bool = params.trust_inference,
313304
assume_fatal_throw::Bool = params.assume_fatal_throw)
314305
return OptimizationParams(
315306
inlining,
@@ -319,7 +310,6 @@ function OptimizationParams(
319310
inline_error_path_cost,
320311
max_tuple_splat,
321312
compilesig_invokes,
322-
trust_inference,
323313
assume_fatal_throw)
324314
end
325315

0 commit comments

Comments
 (0)