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

collect(Take(1), 1:1) cannot be inferred #18

Open
tkf opened this issue Jul 17, 2019 · 0 comments
Open

collect(Take(1), 1:1) cannot be inferred #18

tkf opened this issue Jul 17, 2019 · 0 comments
Labels

Comments

@tkf
Copy link
Member

tkf commented Jul 17, 2019

It seems that the type instability happens in the anonymous function defined as the do bolck in next(rf::R_{Take}, result, input):

https://github.com/tkf/Transducers.jl/blob/eab67ddb94e0e6c82c0b65c41b1e218287d8675a/src/library.jl#L378-L388

The compiler gives up to track the union and decides to use Tuple{Int64, Union{Array, Reduced}} instead of Tuple{Int64, Union{Array{Union{},1}, Array{Int64,1}, Reduced{Array{Union{},1}}, Reduced{Array{Int64,1}}}}.

This probably is impossible to directly solve, since Julia compiler has the limit const MAX_TYPEUNION_LENGTH = 3 (but re-compiling Julia with length=4 didn't improve the inference result...)

Full `@​descend` session
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.3.0-DEV.533 (2019-07-10)
 _/ |\__'_|_|_|\__'_|  |  Commit 073cbbb491 (7 days old master)
|__/                   |

julia> using Transducers

julia> using Cthulhu

julia> @descend_code_warntype collect(Take(1), 1:1)

│ ─ %-1  = invoke collect(::Take,::UnitRange{Int64})::Any
Body::Any
     @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:599 within `collect'
1 ──        goto #2
     @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:603 within `collect'
    ┌ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:90 within `reducingfunction'
    │┌ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:90 within `#reducingfunction#60'
    ││┌ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:94 within `_reducingfunction'
    │││┌ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:94 within `#_reducingfunction#61'
    ││││┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:338 within `Reduction' @ /home/takafumi/.julia/dev/Transducers/src/core.jl:336 @ /home/takafumi/.julia/dev/Transducers/src/core.jl:308
2 ──│││││ %2   = %new(Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE}, xf, $(QuoteNode(Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}}(Completing{typeof(BangBang.push!!)}(BangBang.push!!)))))::Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE}
│   └└└└└
│    @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:604 within `collect'
│   ┌ @ array.jl:365 within `getindex'
│   │┌ @ boot.jl:423 within `Array' @ boot.jl:404
│   ││ %3   = $(Expr(:foreigncall, :(:jl_alloc_array_1d), Array{Union{},1}, svec(Any, Int64), :(:ccall), 2, Array{Union{},1}, 0, 0))::Array{Union{},1}
│   └└
│    @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:606 within `collect'
│   ┌ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:325 within `transduce'
│   │┌ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:326 within `#transduce#63'
│   ││┌ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:316 within `_start_init'
│   │││┌ @ /home/takafumi/.julia/dev/Transducers/src/library.jl:375 within `start'
│   ││││┌ @ Base.jl:20 within `getproperty'
│   │││││ %4   = Base.getfield(xf, :n)::Int64
│   ││││└
│   ││││┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:583 within `wrap'
│   │││││┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:475 within `privatestate' @ /home/takafumi/.julia/dev/Transducers/src/core.jl:488
│   ││││││ %5   = %new(Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,Array{Union{},1}}, %4, %3)::Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,Array{Union{},1}}
│   ││└└└└
│   ││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:327 within `#transduce#63'
│   ││┌ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:154 within `__foldl__'
│   │││┌ @ range.jl:477 within `isempty'
│   ││││┌ @ range.jl:565 within `first'
│   │││││┌ @ Base.jl:20 within `getproperty'
│   ││││││ %6   = Base.getfield(coll, :start)::Int64
│   ││││└└
│   ││││┌ @ range.jl:570 within `last'
│   │││││┌ @ Base.jl:20 within `getproperty'
│   ││││││ %7   = Base.getfield(coll, :stop)::Int64
│   ││││└└
│   ││││┌ @ operators.jl:294 within `>'
│   │││││┌ @ int.jl:49 within `<'
│   ││││││ %8   = Base.slt_int(%7, %6)::Bool
│   │││└└└
└───│││        goto #4 if not %8
3 ──│││        goto #38
    │││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:155 within `__foldl__'
    │││┌ @ abstractarray.jl:212 within `eachindex'
    ││││┌ @ abstractarray.jl:95 within `axes1'
    │││││┌ @ abstractarray.jl:75 within `axes'
    ││││││┌ @ range.jl:473 within `size'
    │││││││┌ @ range.jl:543 within `length'
    ││││││││┌ @ range.jl:570 within `last'
    │││││││││┌ @ Base.jl:20 within `getproperty'
4 ──││││││││││ %11  = Base.getfield(coll, :stop)::Int64
│   ││││││││└└
│   ││││││││┌ @ range.jl:565 within `first'
│   │││││││││┌ @ Base.jl:20 within `getproperty'
│   ││││││││││ %12  = Base.getfield(coll, :start)::Int64
│   ││││││││└└
│   ││││││││┌ @ checked.jl:222 within `checked_sub'
│   │││││││││┌ @ checked.jl:194 within `sub_with_overflow'
│   ││││││││││ %13  = Base.Checked.checked_ssub_int(%11, %12)::Tuple{Int64,Bool}
│   │││││││││└
│   │││││││││┌ @ tuple.jl:63 within `indexed_iterate' @ tuple.jl:63
│   ││││││││││ %14  = Base.getfield(%13, 1)::Int64
│   ││││││││││ @ tuple.jl:63 within `indexed_iterate'
│   ││││││││││ %15  = Base.getfield(%13, 2)::Bool
│   │││││││││└
│   │││││││││ @ checked.jl:223 within `checked_sub'
└───│││││││││        goto #6 if not %15
5 ──│││││││││        invoke Base.Checked.throw_overflowerr_binaryop(:-::Symbol, %11::Int64, %12::Int64)
└───│││││││││        $(Expr(:unreachable))
    │││││││││ @ checked.jl:224 within `checked_sub'
6 ┄─│││││││││        goto #7
    ││││││││└
    ││││││││┌ @ checked.jl:165 within `checked_add'
    │││││││││┌ @ checked.jl:132 within `add_with_overflow'
7 ──││││││││││ %20  = Base.Checked.checked_sadd_int(%14, 1)::Tuple{Int64,Bool}
│   │││││││││└
│   │││││││││┌ @ tuple.jl:63 within `indexed_iterate' @ tuple.jl:63
│   ││││││││││ %21  = Base.getfield(%20, 1)::Int64
│   ││││││││││ @ tuple.jl:63 within `indexed_iterate'
│   ││││││││││ %22  = Base.getfield(%20, 2)::Bool
│   │││││││││└
│   │││││││││ @ checked.jl:166 within `checked_add'
└───│││││││││        goto #9 if not %22
8 ──│││││││││        invoke Base.Checked.throw_overflowerr_binaryop(:+::Symbol, %14::Int64, 1::Int64)
└───│││││││││        $(Expr(:unreachable))
    │││││││││ @ checked.jl:167 within `checked_add'
9 ┄─│││││││││        goto #10
    ││││││││└
10 ─││││││││        goto #11
    │││││││└
11 ─│││││││        goto #12
    ││││││└
    ││││││┌ @ tuple.jl:139 within `map'
    │││││││┌ @ range.jl:320 within `OneTo' @ range.jl:311
    ││││││││┌ @ promotion.jl:414 within `max'
    │││││││││┌ @ int.jl:49 within `<'
12 ─││││││││││ %29  = Base.slt_int(%21, 0)::Bool
│   │││││││││└
│   │││││││││ %30  = Base.ifelse(%29, 0, %21)::Int64
│   ││││││└└└
└───││││││        goto #13
    │││││└
13 ─│││││        goto #14
    ││││└
14 ─││││        goto #15
    │││└
    │││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:156 within `__foldl__'
    │││┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:182 within `macro expansion'
    ││││┌ @ range.jl:625 within `getindex'
15 ─│││││        goto #16
    │││││ @ range.jl:626 within `getindex'
16 ─│││││        goto #17
    │││││ @ range.jl:618 within `getindex'
    │││││┌ @ Base.jl:20 within `getproperty'
17 ─││││││ %36  = Base.getfield(coll, :start)::Int64
│   │││││└
│   │││││┌ @ int.jl:52 within `-'
│   ││││││ %37  = Base.sub_int(1, 1)::Int64
│   │││││└
│   │││││┌ @ int.jl:53 within `+'
│   ││││││ %38  = Base.add_int(%36, %37)::Int64
│   │││││└
│   │││││ @ range.jl:619 within `getindex'
└───│││││        goto #18
    │││││ @ range.jl:620 within `getindex'
18 ─│││││        goto #19
    ││││└
19 ─││││ %41  = invoke Transducers.next(%2::Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE}, %5::Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,Array{Union{},1}}, %38::Int64)::Union{Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,_A} where _A, Reduced}
│   ││││ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:183 within `macro expansion'
│   ││││ %42  = (%41 isa Transducers.Reduced)::Bool
└───││││        goto #21 if not %42
20 ─││││ %44  = π (%41, Reduced)
└───││││        goto #38
    ││││ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:184 within `macro expansion'
21 ─││││ %46  = π (%41, Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,_A} where _A)
│   │││└
│   │││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:157 within `__foldl__'
│   │││┌ @ /home/takafumi/.julia/dev/Transducers/src/simd.jl:98 within `macro expansion'
└───││││        goto #22
    ││││ @ /home/takafumi/.julia/dev/Transducers/src/simd.jl:106 within `macro expansion'
    ││││┌ @ abstractarray.jl:303 within `lastindex'
    │││││┌ @ abstractarray.jl:268 within `eachindex'
    ││││││┌ @ abstractarray.jl:95 within `axes1'
    │││││││┌ @ abstractarray.jl:75 within `axes'
    ││││││││┌ @ tuple.jl:139 within `map'
    │││││││││┌ @ range.jl:320 within `OneTo' @ range.jl:311
    ││││││││││┌ @ promotion.jl:414 within `max'
    │││││││││││┌ @ int.jl:49 within `<'
22 ─││││││││││││ %48  = Base.slt_int(%30, 0)::Bool
│   │││││││││││└
│   │││││││││││ %49  = Base.ifelse(%48, 0, %30)::Int64
│   ││││└└└└└└└
│   ││││┌ @ range.jl:5 within `Colon'
│   │││││┌ @ range.jl:277 within `UnitRange'
│   ││││││┌ @ range.jl:282 within `unitrange_last'
│   │││││││┌ @ operators.jl:341 within `>='
│   ││││││││┌ @ int.jl:424 within `<='
│   │││││││││ %50  = Base.sle_int(2, %49)::Bool
│   │││││││└└
│   │││││││ %51  = Base.ifelse(%50, %49, 1)::Int64
│   ││││└└└
│   ││││┌ @ range.jl:593 within `iterate'
│   │││││┌ @ range.jl:477 within `isempty'
│   ││││││┌ @ operators.jl:294 within `>'
│   │││││││┌ @ int.jl:49 within `<'
│   ││││││││ %52  = Base.slt_int(%51, 2)::Bool
│   │││││└└└
└───│││││        goto #24 if not %52
23 ─│││││        goto #25
24 ─│││││        goto #25
    ││││└
25 ┄││││ %56  = φ (#23 => true, #24 => false)::Bool
│   ││││ %57  = φ (#24 => 2)::Int64
│   ││││ %58  = φ (#24 => 2)::Int64
│   ││││ %59  = Base.not_int(%56)::Bool
└───││││        goto #37 if not %59
26 ┄││││ %61  = φ (#25 => %46, #36 => %76)::Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,_A} where _A
│   ││││ %62  = φ (#25 => %57, #36 => %82)::Int64
│   ││││ %63  = φ (#25 => %58, #36 => %83)::Int64
│   ││││ @ /home/takafumi/.julia/dev/Transducers/src/simd.jl:106 within `macro expansion' @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:158
│   ││││┌ @ range.jl:625 within `getindex'
└───│││││        goto #27
    │││││ @ range.jl:626 within `getindex'
27 ─│││││        goto #28
    ││││└
    ││││ @ /home/takafumi/.julia/dev/Transducers/src/simd.jl:106 within `macro expansion' @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:159 @ /home/takafumi/.julia/dev/Transducers/src/core.jl:182
    ││││┌ @ range.jl:618 within `getindex'
    │││││┌ @ Base.jl:20 within `getproperty'
28 ─││││││ %66  = Base.getfield(coll, :start)::Int64
│   │││││└
│   │││││┌ @ int.jl:52 within `-'
│   ││││││ %67  = Base.sub_int(%62, 1)::Int64
│   │││││└
│   │││││┌ @ int.jl:53 within `+'
│   ││││││ %68  = Base.add_int(%66, %67)::Int64
│   │││││└
│   │││││ @ range.jl:619 within `getindex'
└───│││││        goto #29
    │││││ @ range.jl:620 within `getindex'
29 ─│││││        goto #30
    ││││└
30 ─││││ %71  = Transducers.next(%2, %61, %68)::Union{Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,_A} where _A, Reduced}
│   ││││ @ /home/takafumi/.julia/dev/Transducers/src/simd.jl:106 within `macro expansion' @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:159 @ /home/takafumi/.julia/dev/Transducers/src/core.jl:183
│   ││││ %72  = (%71 isa Transducers.Reduced)::Bool
└───││││        goto #32 if not %72
31 ─││││ %74  = π (%71, Reduced)
└───││││        goto #38
    ││││ @ /home/takafumi/.julia/dev/Transducers/src/simd.jl:106 within `macro expansion' @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:159 @ /home/takafumi/.julia/dev/Transducers/src/core.jl:184
32 ─││││ %76  = π (%71, Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,_A} where _A)
│   ││││ @ /home/takafumi/.julia/dev/Transducers/src/simd.jl:106 within `macro expansion'
│   ││││┌ @ range.jl:597 within `iterate'
│   │││││┌ @ promotion.jl:403 within `=='
│   ││││││ %77  = (%63 === %51)::Bool
│   │││││└
└───│││││        goto #34 if not %77
33 ─│││││        goto #35
    │││││ @ range.jl:598 within `iterate'
    │││││┌ @ int.jl:53 within `+'
34 ─││││││ %80  = Base.add_int(%63, 1)::Int64
│   │││││└
│   │││││ @ range.jl:599 within `iterate'
└───│││││        goto #35
    ││││└
35 ┄││││ %82  = φ (#34 => %80)::Int64
│   ││││ %83  = φ (#34 => %80)::Int64
│   ││││ %84  = φ (#33 => true, #34 => false)::Bool
│   ││││ %85  = Base.not_int(%84)::Bool
└───││││        goto #37 if not %85
36 ─││││        goto #26
    │││└
    │││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:161 within `__foldl__'
37 ┄│││ %88  = φ (#35 => %76, #25 => %46)::Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,_A} where _A
│   │││┌ @ /home/takafumi/.julia/dev/Transducers/src/library.jl:376 within `complete'
│   ││││┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:521 within `unwrap'
│   │││││┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:497 within `psresult'
│   ││││││┌ @ Base.jl:20 within `getproperty'
│   │││││││ %89  = Base.getfield(%88, :result)::Any
│   │││└└└└
└───│││        goto #38
    ││└
38 ┄││ %91  = φ (#3 => %3, #20 => %44, #31 => %74, #37 => %89)::Any
│   ││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:328 within `#transduce#63'
│   ││ %92  = Transducers.unreduced(%91)::Any
│   ││ %93  = (%92 isa Transducers.DefaultInit)::Bool
└───││        goto #40 if not %93
    ││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:329 within `#transduce#63'
    ││┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:1008 within `EmptyResultError'
39 ─│││ %95  = Transducers.EmptyResultError::Type{Transducers.EmptyResultError}
│   │││ %96  = %new(%95, %2)::Transducers.EmptyResultError
│   ││└
│   ││        Transducers.throw(%96)
└───││        $(Expr(:unreachable))
    ││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:341 within `#transduce#63'
40 ┄││ %99  = Transducers.unreduced(%91)::Any
│   ││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:342 within `#transduce#63'
│   ││ %100 = (%99 isa Transducers.InferableInit)::Bool
└───││        goto #44 if not %100
    ││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:346 within `#transduce#63'
41 ─││ %102 = Transducers._nonidtype(Any)::Type{Any}
│   ││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:351 within `#transduce#63'
│   ││ %103 = π (%99, Union{Transducers.DefaultInit{OP}, Transducers.OptInitOf{OP}} where OP)
│   ││ %104 = invoke Transducers.convert(%102::Type{Any}, %103::Any)::Union{Transducers.DefaultInit{OP}, Transducers.OptInitOf{OP}} where OP
│   ││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:352 within `#transduce#63'
│   ││ %105 = (%91 isa Transducers.Reduced)::Bool
└───││        goto #43 if not %105
    ││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:353 within `#transduce#63'
42 ─││ %107 = Transducers.Reduced(%104)::Reduced{_A} where _A
└───││        goto #47
    ││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:355 within `#transduce#63'
43 ─││        goto #47
    ││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:359 within `#transduce#63'
44 ─││ %110 = (%91 isa Transducers.Reduced)::Bool
└───││        goto #46 if not %110
    ││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:360 within `#transduce#63'
45 ─││ %112 = Transducers.Reduced(%99)::Reduced{_A} where _A
└───││        goto #47
    ││ @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:362 within `#transduce#63'
46 ─││        goto #47
    │└
47 ┄│ %115 = φ (#42 => %107, #43 => %104, #45 => %112, #46 => %99)::Any
└───│        goto #48
    └
48 ─ %117 = Transducers.unreduced(%115)::Any
│    @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:607 within `collect'
│    %118 = (%117 isa Array{Union{},1})::Bool
└───        goto #53 if not %118
     @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:608 within `collect'
    ┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:944 within `macro expansion' @ array.jl:591
49 ─│        goto #50
50 ─│ %121 = π (false, Core.Compiler.Const(false, false))
└───│        goto #52 if not %121
51 ─│        nothing
    └
     @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:609 within `collect'
    ┌ @ array.jl:377 within `getindex'
    │┌ @ boot.jl:423 within `Array' @ boot.jl:404
52 ┄││ %124 = $(Expr(:foreigncall, :(:jl_alloc_array_1d), Array{Any,1}, svec(Any, Int64), :(:ccall), 2, Array{Any,1}, 0, 0))::Array{Any,1}
│   └└
└───        return %124
     @ /home/takafumi/.julia/dev/Transducers/src/processes.jl:611 within `collect'
53 ─        return %117

Select a call to descend into or ↩ to ascend. [q]uit.
Toggles: [o]ptimize, [w]arn, [d]ebuginfo, [s]yntax highlight for LLVM/Native.
Show: [L]LVM IR, [N]ative code
Advanced: dump [P]arams cache.

   %17  = invoke throw_overflowerr_binaryop(::Symbol,::Int64,::Int64)::Union{}
   %24  = invoke throw_overflowerr_binaryop(::Symbol,::Int64,::Int64)::Union{}
 • %41  = invoke next(::Transducers.Reduction{…},::Transducers.PrivateState{…},::Int64{…})
   %71  = invoke next(::Transducers.Reduction{…},::Transducers.PrivateState{…},::Int64{…})
   %92  = call #unreduced(::Any)::Any
   %99  = call #unreduced(::Any)::Any
   %102  = invoke _nonidtype(::Type{Any})::Type{Any}
   %104  = invoke convert(::Type{Any},::Any)
   %107  = invoke Reduced(::Union{Transducers.DefaultInit{OP}, Transducers.OptInitOf{OP}} where OP)
v  %112  = invoke Reduced(::Any)::Reduced{_A} where _A

│ ─ %-1  = invoke next(::Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},::Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,Array{Union{},1}},::Int64)::Union{Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,_A} where _A, Reduced}
Body::Union{Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,_A} where _A, Reduced}
     @ /home/takafumi/.julia/dev/Transducers/src/library.jl:378 within `next'
    ┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:604 within `wrapping'
    │┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:521 within `unwrap'
    ││┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:496 within `psstate'
    │││┌ @ Base.jl:20 within `getproperty'
1 ──││││ %1  = Base.getfield(result, :state)::Int64
│   ││└└
│   ││┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:497 within `psresult'
│   │││┌ @ Base.jl:20 within `getproperty'
│   ││││ %2  = Base.getfield(result, :result)::Array{Union{},1}
│   │└└└
│   │ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:605 within `wrapping'
│   │┌ @ /home/takafumi/.julia/dev/Transducers/src/library.jl:380 within `#7'
│   ││┌ @ operators.jl:294 within `>'
│   │││┌ @ int.jl:49 within `<'
│   ││││ %3  = Base.slt_int(0, %1)::Bool
│   ││└└
└───││       goto #3 if not %3
    ││ @ /home/takafumi/.julia/dev/Transducers/src/library.jl:381 within `#7'
    ││┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:285 within `next' @ /home/takafumi/.julia/dev/Transducers/src/core.jl:680 @ /home/takafumi/.julia/dev/Transducers/src/core.jl:422
    │││┌ @ /home/takafumi/.julia/dev/BangBang/src/base.jl:29 within `push!!'
    ││││┌ @ /home/takafumi/.julia/dev/BangBang/src/core.jl:5 within `may'
    │││││┌ @ /home/takafumi/.julia/dev/BangBang/src/NoBang/base.jl:10 within `push'
    ││││││┌ @ /home/takafumi/.julia/dev/BangBang/src/NoBang/singletoncontainers.jl:5 within `SingletonVector' @ /home/takafumi/.julia/dev/BangBang/src/NoBang/singletoncontainers.jl:5
2 ──│││││││ %5  = %new(BangBang.NoBang.SingletonVector{Int64}, input)::BangBang.NoBang.SingletonVector{Int64}
│   ││││││└
│   ││││││┌ @ abstractarray.jl:1287 within `vcat'
│   │││││││ %6  = Core.tuple(%2, %5)::Tuple{Array{Union{},1},BangBang.NoBang.SingletonVector{Int64}}
│   │││││││┌ @ abstractarray.jl:1373 within `typed_vcat'
│   ││││││││ %7  = invoke Base._typed_vcat(Int64::Type{Int64}, %6::Tuple{Array{Union{},1},BangBang.NoBang.SingletonVector{Int64}})::Array{Int64,1}
│   ││└└└└└└
│   ││ @ /home/takafumi/.julia/dev/Transducers/src/library.jl:382 within `#7'
│   ││┌ @ int.jl:52 within `-'
└───│││ %8  = Base.sub_int(%1, 1)::Int64
    ││└
    ││ @ /home/takafumi/.julia/dev/Transducers/src/library.jl:384 within `#7'
3 ┄─││ %9  = φ (#2 => %8, #1 => %1)::Int64
│   ││ %10 = φ (#2 => %7, #1 => %2)::Union{Array{Int64,1}, Array{Union{},1}}
│   ││┌ @ int.jl:424 within `<='
│   │││ %11 = Base.sle_int(%9, 0)::Bool
│   ││└
└───││       goto #15 if not %11
    ││ @ /home/takafumi/.julia/dev/Transducers/src/library.jl:385 within `#7'
4 ──││ %13 = π (%10, Union{Array{Union{},1}, Array{Int64,1}})
│   ││ %14 = (isa)(%13, Array{Union{},1})::Bool
└───││       goto #6 if not %14
5 ──││ %16 = π (%13, Array{Union{},1})
└───││       goto #9
6 ──││ %18 = (isa)(%13, Array{Int64,1})::Bool
└───││       goto #8 if not %18
7 ──││ %20 = π (%13, Array{Int64,1})
└───││       goto #9
8 ──││       Core.throw(ErrorException("fatal error in type inference (type bound)"))
└───││       $(Expr(:unreachable))
9 ┄─││ %24 = φ (#5 => %16, #7 => %20)::Union{Array{Union{},1}, Array{Int64,1}}
│   ││ %25 = (isa)(%24, Array{Union{},1})::Bool
└───││       goto #11 if not %25
10 ─││ %27 = π (%24, Array{Union{},1})
│   ││┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:93 within `reduced'
│   │││┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:49 within `Reduced' @ /home/takafumi/.julia/dev/Transducers/src/core.jl:49
│   ││││ %28 = %new(Reduced{Array{Union{},1}}, %27)::Reduced{Array{Union{},1}}
│   ││└└
└───││       goto #14
11 ─││ %30 = (isa)(%24, Array{Int64,1})::Bool
└───││       goto #13 if not %30
12 ─││ %32 = π (%24, Array{Int64,1})
│   ││┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:93 within `reduced'
│   │││┌ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:49 within `Reduced' @ /home/takafumi/.julia/dev/Transducers/src/core.jl:49
│   ││││ %33 = %new(Reduced{Array{Int64,1}}, %32)::Reduced{Array{Int64,1}}
│   ││└└
└───││       goto #14
13 ─││       Core.throw(ErrorException("fatal error in type inference (type bound)"))
└───││       $(Expr(:unreachable))
14 ┄││ %37 = φ (#10 => %28, #12 => %33)::Union{Reduced{Array{Union{},1}}, Reduced{Array{Int64,1}}}
    ││ @ /home/takafumi/.julia/dev/Transducers/src/library.jl:387 within `#7'
15 ┄││ %38 = φ (#14 => %37, #3 => %10)::Union{Array, Reduced}
└───││       goto #16
    │└
    │ @ /home/takafumi/.julia/dev/Transducers/src/core.jl:606 within `wrapping'
16 ─│ %40 = Transducers.wrap(rf, %9, %38)::Union{Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,_A} where _A, Reduced}
└───│       goto #17
    └
17 ─       return %40

Select a call to descend into or ↩ to ascend. [q]uit.
Toggles: [o]ptimize, [w]arn, [d]ebuginfo, [s]yntax highlight for LLVM/Native.
Show: [L]LVM IR, [N]ative code
Advanced: dump [P]arams cache.

 • %7  = invoke _typed_vcat(::Type{Int64},::Tuple{Array{Union{},1},BangBang.NoBang.SingletonVector{Int64}})
   %40  = call #wrap(::Transducers.Reduction{…},::Int64{…},::Union{Array, Reduced}{…})
   ↩

Here I type o.

│ ─ %-1  = invoke next(::Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},::Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,Array{Union{},1}},::Int64)::Union{Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,_A} where _A, Reduced}
Body::Union{Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,_A} where _A, Reduced}
    @ /home/takafumi/.julia/dev/Transducers/src/library.jl:378 within `next'
1 ─ %1 = Transducers.:(##7#8)::Core.Compiler.Const(getfield(Transducers, Symbol("##7#8")), false)
│   %2 = Core.typeof(rf)::Core.Compiler.Const(Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE}, false)
│   %3 = Core.typeof(input)::Core.Compiler.Const(Int64, false)
│   %4 = Core.apply_type(%1, %2, %3)::Core.Compiler.Const(getfield(Transducers, Symbol("##7#8")){Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64}, false)
│        (#7 = %new(%4, rf, input))
│   %6 = #7::getfield(Transducers, Symbol("##7#8")){Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64}
│   %7 = Transducers.wrapping(%6, rf, result)::Union{Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,_A} where _A, Reduced}
└──      return %7

Select a call to descend into or ↩ to ascend. [q]uit.
Toggles: [o]ptimize, [w]arn, [d]ebuginfo, [s]yntax highlight for LLVM/Native.
Show: [L]LVM IR, [N]ative code
Advanced: dump [P]arams cache.

 • %7  = invoke wrapping(…,…,…)
   ↩

│ ─ %-1  = invoke wrapping(::getfield(Transducers, Symbol("##7#8")){Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64},::Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},::Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,Array{Union{},1}})::Union{Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,_A} where _A, Reduced}
Body::Union{Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,_A} where _A, Reduced}
1 ─       nothing
│   @ /home/takafumi/.julia/dev/Transducers/src/core.jl:604 within `wrapping'
│   %2  = Transducers.unwrap(rf, result)::Tuple{Int64,Array{Union{},1}}
│   %3  = Base.indexed_iterate(%2, 1)::Core.Compiler.PartialStruct(Tuple{Int64,Int64}, Any[Int64, Core.Compiler.Const(2, false)])
│         (state0 = Core.getfield(%3, 1))
│         (@_6 = Core.getfield(%3, 2))
│   %6  = Base.indexed_iterate(%2, 2, @_6::Core.Compiler.Const(2, false))::Core.Compiler.PartialStruct(Tuple{Array{Union{},1},Int64}, Any[Array{Union{},1}, Core.Compiler.Const(3, false)])
│         (iresult0 = Core.getfield(%6, 1))
│   @ /home/takafumi/.julia/dev/Transducers/src/core.jl:605 within `wrapping'
│   %8  = (f)(state0, iresult0)::Tuple{Int64,Union{Array, Reduced}}
│   %9  = Base.indexed_iterate(%8, 1)::Core.Compiler.PartialStruct(Tuple{Int64,Int64}, Any[Int64, Core.Compiler.Const(2, false)])
│         (state1 = Core.getfield(%9, 1))
│         (@_9 = Core.getfield(%9, 2))
│   %12 = Base.indexed_iterate(%8, 2, @_9::Core.Compiler.Const(2, false))::Core.Compiler.PartialStruct(Tuple{Union{Array, Reduced},Int64}, Any[Union{Array, Reduced}, Core.Compiler.Const(3, false)])
│         (iresult1 = Core.getfield(%12, 1))
│   @ /home/takafumi/.julia/dev/Transducers/src/core.jl:606 within `wrapping'
│   %14 = Transducers.wrap(rf, state1, iresult1)::Union{Transducers.PrivateState{Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE},Int64,_A} where _A, Reduced}
└──       return %14

Select a call to descend into or ↩ to ascend. [q]uit.
Toggles: [o]ptimize, [w]arn, [d]ebuginfo, [s]yntax highlight for LLVM/Native.
Show: [L]LVM IR, [N]ative code
Advanced: dump [P]arams cache.

   %2  = invoke unwrap(::Transducers.Reduction{…},::Transducers.PrivateState{…})::Tuple{Int64,Array{Union{},1}}
   %3  = invoke indexed_iterate(::Tuple{Int64,Array{Union{},1}},::Int64)
   %6  = invoke indexed_iterate(::Tuple{Int64,Array{Union{},1}},::Int64,::Int64)
 • %8  = invoke #7(::Int64,::Array{Union{},1})::Tuple{Int64,Union{Array, Reduced}}
   %9  = invoke indexed_iterate(::Tuple{Int64,Union{Array, Reduced}},::Int64)
   %12  = invoke indexed_iterate(::Tuple{Int64,Union{Array, Reduced}},::Int64,::Int64)
   %14  = call #wrap(::Transducers.Reduction{…},::Int64{…},::Union{Array, Reduced}{…})
   ↩

│ ─ %-1  = invoke #7(::Int64,::Array{Union{},1})::Tuple{Int64,Union{Array, Reduced}}
Body::Tuple{Int64,Union{Array, Reduced}}
    @ /home/takafumi/.julia/dev/Transducers/src/library.jl:380 within `#7'
1 ─       (iresult@_5 = iresult@_3)
│         (n@_4 = n@_2)
│   %3  = (n@_4 > 0)::Bool
└──       goto #3 if not %3
    @ /home/takafumi/.julia/dev/Transducers/src/library.jl:381 within `#7'
2 ─ %5  = Core.getfield(#self#, :rf)::Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE}
│   %6  = Transducers.inner(%5)::Core.Compiler.Const(Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}}(Completing{typeof(BangBang.push!!)}(BangBang.push!!)), false)
│   %7  = iresult@_5::Array{Union{},1}::Array{Union{},1}
│   %8  = Core.getfield(#self#, :input)::Int64
│         (iresult@_5 = Transducers.next(%6, %7, %8))
│   @ /home/takafumi/.julia/dev/Transducers/src/library.jl:382 within `#7'
└──       (n@_4 = n@_4 - 1)
    @ /home/takafumi/.julia/dev/Transducers/src/library.jl:384 within `#7'
3 ┄ %11 = (n@_4 <= 0)::Bool
└──       goto #5 if not %11
    @ /home/takafumi/.julia/dev/Transducers/src/library.jl:385 within `#7'
4 ─ %13 = Core.getfield(#self#, :rf)::Transducers.Reduction{Take,Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}},Transducers.NOTYPE}
│   %14 = Transducers.inner(%13)::Core.Compiler.Const(Transducers.BottomRF{Transducers.NOTYPE,Completing{typeof(BangBang.push!!)}}(Completing{typeof(BangBang.push!!)}(BangBang.push!!)), false)
│   %15 = Transducers.complete(%14, iresult@_5::Union{Array{Union{},1}, Array{Int64,1}})::Union{Array{Union{},1}, Array{Int64,1}}
└──       (iresult@_5 = Transducers.reduced(%15))
    @ /home/takafumi/.julia/dev/Transducers/src/library.jl:387 within `#7'
5 ┄ %17 = Core.tuple(n@_4, iresult@_5)::Tuple{Int64,Union{Array, Reduced}}
└──       return %17

Select a call to descend into or ↩ to ascend. [q]uit.
Toggles: [o]ptimize, [w]arn, [d]ebuginfo, [s]yntax highlight for LLVM/Native.
Show: [L]LVM IR, [N]ative code
Advanced: dump [P]arams cache.

 • %3  = invoke >(::Int64,::Int64)::Bool
   %6  = invoke inner(::Transducers.Reduction{…})
   %9  = invoke next(::Transducers.BottomRF{…},::Array{…},::Int64{…})::Array{Int64,1}
   %10  = invoke -(::Int64,::Int64)::Int64
   %11  = invoke <=(::Int64,::Int64)::Bool
   %14  = invoke inner(::Transducers.Reduction{…})
   %15  = invoke complete(::Transducers.BottomRF{…},::Union{Array{Union{},1}, Array{Int64,1}}{…})
   %16  = invoke reduced(::Union{Array{Union{},1}, Array{Int64,1}})
   ↩
@tkf tkf added the help wanted Extra attention is needed label Jul 18, 2019
@tkf tkf added compiler and removed help wanted Extra attention is needed labels May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant