Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is_type_unstable for unoptimized code #195

Closed
aviatesk opened this issue Aug 3, 2021 · 0 comments
Closed

is_type_unstable for unoptimized code #195

aviatesk opened this issue Aug 3, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@aviatesk
Copy link
Member

aviatesk commented Aug 3, 2021

As discussed in #193, the current implementation of is_type_unstable may not work well for unoptimized code.

Especially, it doesn't handle lhs = rhs statements where rhs is type unstable:

julia> const globalvar = Ref(42)
Base.RefValue{Int64}(42)

julia> descend(; optimize=false) do
           a = sin(globalvar[])
           b = sin(undefvar)
           return (a, b)
       end
│ ─ %-1  = invoke #3()::Tuple{Float64, Any}
    @ REPL[4]:2 within `#3`
1%1 = Base.getindex(Main.globalvar)::Int64
│        (a = Main.sin(%1))::Float64
│   @ REPL[4]:3 within `#3`
│        (b = Main.sin(Main.undefvar))::Any
│   @ REPL[4]:4 within `#3`%4 = Core.tuple(a, b)::Tuple{Float64, Any}
└──      return %4
Select a call to descend into or  to ascend. [q]uit. [b]ookmark.
Toggles: [o]ptimize, [w]arn, [h]ide type-stable statements, [d]ebuginfo, [i]nlining costs, [s]yntax highlight for Source/LLVM/Native.
Show: [S]ource code, [A]ST, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
Advanced: dump [P]arams cache.
 • %1  = getindex(::Base.RefValue{Int64})::Int64
   %2  = sin(::Int64)::Float64
   

# toggle `h` option

│ ─ %-1  = invoke #3()::Tuple{Float64, Any}
│   @ REPL[4]:4 within `#3`%4 = Core.tuple(a, b)::Tuple{Float64, Any}
Select a call to descend into or  to ascend. [q]uit. [b]ookmark.
Toggles: [o]ptimize, [w]arn, [h]ide type-stable statements, [d]ebuginfo, [i]nlining costs, [s]yntax highlight for Source/LLVM/Native.
Show: [S]ource code, [A]ST, [L]LVM IR, [N]ative code
Actions: [E]dit source code, [R]evise and redisplay
Advanced: dump [P]arams cache.
 • %1  = getindex(::Base.RefValue{Int64})::Int64
   %2  = sin(::Int64)::Float64
   

, where we still want (b = Main.sin(Main.undefvar))::Any to be shown even on h mode.

As additional information, I found it idx in used returns false for that case:

return (idx in used) && type isa Type && (!Base.isdispatchelem(type) || type == Core.Box)

@simeonschaub simeonschaub self-assigned this Aug 3, 2021
@simeonschaub simeonschaub added bug Something isn't working upstream and removed upstream labels Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants