Skip to content

call backedges sometimes dropped in presence of identical invoke edges #57115

Closed
@topolarity

Description

@topolarity

Issue to track #57079

PkgA:

module PkgA
    struct DummyStruct{T} end

    bar(@nospecialize(::DummyStruct)) = error("unimplemented")
    function foo(@nospecialize(x::DummyStruct))
        if @noinline rand(Bool)
            # Add an 'invoke' edge from 'foo' to 'bar'
            Core.invoke(bar, Tuple{DummyStruct}, x)
        else
            # ... and also an identical 'call' edge
            @noinline bar(x)
        end
    end
end

PkgB:

module PkgB
    import PkgA: DummyStruct, foo, bar

    # This should invalidate 'foo'
    bar(::DummyStruct{Int}) = 15
    
    # The new 'foo' that is precompiled needs to add the
    # correct backedges to 'bar(::DummyStruct)'.
    #
    # These are the same backedges from before, but this
    # tests that they survive de-serialization by an
    # external package.
    precompile(foo, (DummyStruct,))
end

When loading:

julia> using PkgA, PkgB

julia> m = methods(PkgA.bar, (PkgA.DummyStruct,))[end]
bar(::PkgA.DummyStruct)
     @ PkgA ~/repos/julia/PkgA/src/PkgA.jl:5

julia> m.specializations.backedges
2-element Vector{Any}:
 Tuple{typeof(PkgA.bar), PkgA.DummyStruct}
 MethodInstance for PkgA.foo(::PkgA.DummyStruct)

On 1.10 / 1.11, we're missing a call backedge. The backedge list should be:

julia> m.specializations.backedges
3-element Vector{Any}:
 Tuple{typeof(PkgA.bar), PkgA.DummyStruct}
 MethodInstance for PkgA.foo(::PkgA.DummyStruct)
 MethodInstance for PkgA.foo(::PkgA.DummyStruct)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions