Skip to content

Commit

Permalink
replace the depwarn special case with the recent compiler annotatio…
Browse files Browse the repository at this point in the history
…ns (#52918)

The special handling for `depwarn`, originating from
#27918 in 2018, is now set to be replaced by the more
recent compiler annotations, esp. `@nospecializeinfer`. Assessing
potential regressions from this change might be challenging, but I
confirmed this only has a minimal impact on image sizes at least.
  • Loading branch information
aviatesk authored Jan 18, 2024
1 parent 0b0e3bf commit 94db364
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 0 additions & 4 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,6 @@ const RECURSION_MSG_HARDLIMIT = "Bounded recursion detected under hardlimit. Cal
function abstract_call_method(interp::AbstractInterpreter,
method::Method, @nospecialize(sig), sparams::SimpleVector,
hardlimit::Bool, si::StmtInfo, sv::AbsIntState)
if method.name === :depwarn && isdefined(Main, :Base) && method.module === Main.Base
add_remark!(interp, sv, "Refusing to infer into `depwarn`")
return MethodCallResult(Any, Any, false, false, nothing, Effects())
end
sigtuple = unwrap_unionall(sig)
sigtuple isa DataType ||
return MethodCallResult(Any, Any, false, false, nothing, Effects())
Expand Down
10 changes: 9 additions & 1 deletion base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,15 @@ macro deprecate(old, new, export_old=true)
end
end

function depwarn(msg, funcsym; force::Bool=false)
@nospecializeinfer function depwarn(msg, funcsym; force::Bool=false)
@nospecialize
# N.B. With this use of `@invokelatest`, we're preventing the addition of backedges from
# callees, such as `convert`, to this user-facing method. This approach is designed to
# enhance the resilience of packages that utilize `depwarn` against invalidation.
return @invokelatest _depwarn(msg, funcsym, force)
end
@nospecializeinfer function _depwarn(msg, funcsym, force::Bool)
@nospecialize
opts = JLOptions()
if opts.depwarn == 2
throw(ErrorException(msg))
Expand Down

0 comments on commit 94db364

Please sign in to comment.