@@ -1034,12 +1034,12 @@ function maybe_get_const_prop_profitable(interp::AbstractInterpreter,
10341034 match:: MethodMatch , sv:: AbsIntState )
10351035 method = match. method
10361036 force = force_const_prop (interp, f, method)
1037- if ! const_prop_entry_heuristic (interp, result, si, sv, force)
1038- # N.B. remarks are emitted within `const_prop_entry_heuristic `
1037+ if ! const_prop_rettype_heuristic (interp, result, si, sv, force)
1038+ # N.B. remarks are emitted within `const_prop_rettype_heuristic `
10391039 return nothing
10401040 end
10411041 if ! const_prop_argument_heuristic (interp, arginfo, sv)
1042- add_remark! (interp, sv, " [constprop] Disabled by argument and rettype heuristics" )
1042+ add_remark! (interp, sv, " [constprop] Disabled by argument heuristics" )
10431043 return nothing
10441044 end
10451045 all_overridden = is_all_overridden (interp, arginfo, sv)
@@ -1061,28 +1061,28 @@ function maybe_get_const_prop_profitable(interp::AbstractInterpreter,
10611061 return mi
10621062end
10631063
1064- function const_prop_entry_heuristic (interp:: AbstractInterpreter , result:: MethodCallResult ,
1065- si:: StmtInfo , sv:: AbsIntState , force:: Bool )
1066- if result. rt isa LimitedAccuracy
1064+ function const_prop_rettype_heuristic (interp:: AbstractInterpreter , result:: MethodCallResult ,
1065+ si:: StmtInfo , sv:: AbsIntState , force:: Bool )
1066+ rt = result. rt
1067+ if rt isa LimitedAccuracy
10671068 # optimizations like inlining are disabled for limited frames,
10681069 # thus there won't be much benefit in constant-prop' here
10691070 # N.B. don't allow forced constprop' for safety (xref #52763)
1070- add_remark! (interp, sv, " [constprop] Disabled by entry heuristic (limited accuracy)" )
1071+ add_remark! (interp, sv, " [constprop] Disabled by rettype heuristic (limited accuracy)" )
10711072 return false
10721073 elseif force
10731074 return true
10741075 elseif call_result_unused (si) && result. edgecycle
1075- add_remark! (interp, sv, " [constprop] Disabled by entry heuristic (edgecycle with unused result)" )
1076+ add_remark! (interp, sv, " [constprop] Disabled by rettype heuristic (edgecycle with unused result)" )
10761077 return false
10771078 end
10781079 # check if this return type is improvable (i.e. whether it's possible that with more
10791080 # information, we might get a more precise type)
1080- rt = result. rt
10811081 if isa (rt, Type)
10821082 # could always be improved to `Const`, `PartialStruct` or just a more precise type,
10831083 # unless we're already at `Bottom`
10841084 if rt === Bottom
1085- add_remark! (interp, sv, " [constprop] Disabled by entry heuristic (erroneous result)" )
1085+ add_remark! (interp, sv, " [constprop] Disabled by rettype heuristic (erroneous result)" )
10861086 return false
10871087 end
10881088 return true
@@ -1091,14 +1091,15 @@ function const_prop_entry_heuristic(interp::AbstractInterpreter, result::MethodC
10911091 return true
10921092 elseif isa (rt, Const)
10931093 if is_nothrow (result. effects)
1094- add_remark! (interp, sv, " [constprop] Disabled by entry heuristic (nothrow const)" )
1094+ add_remark! (interp, sv, " [constprop] Disabled by rettype heuristic (nothrow const)" )
10951095 return false
10961096 end
10971097 # Could still be improved to Bottom (or at least could see the effects improved)
10981098 return true
1099+ else
1100+ add_remark! (interp, sv, " [constprop] Disabled by rettype heuristic (unimprovable result)" )
1101+ return false
10991102 end
1100- add_remark! (interp, sv, " [constprop] Disabled by entry heuristic (unimprovable result)" )
1101- return false
11021103end
11031104
11041105# determines heuristically whether if constant propagation can be worthwhile
0 commit comments