Cthulhu.jl icon indicating copy to clipboard operation
Cthulhu.jl copied to clipboard

Add descend with constant arguments

Open vchuravy opened this issue 4 years ago • 5 comments

Sometimes inference decides that const prop is not worthwhile and in order to debug those decisions we should add the option to enter a call side with const information

X-ref: https://github.com/JuliaLang/julia/pull/29261

Cc: @simeonschaub who had a good example

vchuravy avatar Jul 24 '21 10:07 vchuravy

It's easy to start descending with const arguments with something like:

descend((T,)) do typearg
    foo(constarg, typearg)
end

Could you elaborate what we want a bit more ?

aviatesk avatar Jul 29 '21 14:07 aviatesk

I want to start with an actual Const lattice element. Not even necessarily from the top-level.

But sometimes I come across a call site that has all const arguments and it didn't get constant-propped. So I want to explore why.

vchuravy avatar Jul 29 '21 15:07 vchuravy

Are we making use of the messages that get passed back?

julia> interp.msgs
Dict{Core.MethodInstance, Vector{Pair{Int64, String}}} with 6 entries:
  MethodInstance for Base.indexed_iterate(::Tuple{Float64, Int64… => [3=>"[constprop] Disabled by function heuristic", 3=>"[constprop] Disabled by function heuristic"]
  MethodInstance for isempty(::OneTo{Int64})                      => [3=>"[constprop] Disabled by function heuristic"]
  MethodInstance for Base.collect_to_with_first!(::Vector{Float6… => [3=>"[constprop] Disabled by function heuristic", 3=>"Call result type was widened because the return value is unused"]
  MethodInstance for iterate(::OneTo{Int64}, ::Int64)          => [9=>"[constprop] Disabled by function heuristic"]
  MethodInstance for max(::Int64, ::Int64)                     => [1=>"[constprop] Disabled by function heuristic"]
  MethodInstance for Base.collect_to!(::Vector{Float64}, ::Ge… => [25=>"Call result type was widened because the return value is unused", 29=>"[constprop] Disabled by function heuristic", 25=>"[co…

timholy avatar Jul 29 '21 16:07 timholy

No, we don't show them in our UI in anyway right now. Maybe we want to show them aside of callsites that failed to constprop ?

aviatesk avatar Jul 29 '21 16:07 aviatesk