Skip to content

Commit

Permalink
Add precompiled tags if backedge is missing (#15)
Browse files Browse the repository at this point in the history
In JuliaLang/julia#49617 it was found that
not all callees have backedges to callers. There is some speculation
that rather than adding the backedge to those cases, we may in fact
be able to prune the backedge graph more substantially in cases where
it may be safe to avoid propagating invalidation.

Consequently, to enforce the guarantees made by `@compile_workload`,
PrecompileTools should check the inference graph and add tags in cases
where a backedge is missing.
  • Loading branch information
timholy committed May 3, 2023
1 parent e1fa6e2 commit c6ac730
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/PrecompileTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,31 @@ function workload_enabled(mod::Module)
end
end

"""
check_edges(node)
Recursively ensure that all callees of `node` are precompiled. This is (rarely) necessary
because sometimes there is no backedge from callee to caller (xref https://github.com/JuliaLang/julia/issues/49617),
and `staticdata.c` relies on the backedge to trace back to a MethodInstance that is tagged `mi.precompiled`.
"""
function check_edges(node)
parentmi = node.mi_info.mi
for child in node.children
childmi = child.mi_info.mi
if !(isdefined(childmi, :backedges) && parentmi childmi.backedges)
precompile(childmi.specTypes)
end
check_edges(child)
end
end

function precompile_roots(roots)
@assert have_inference_tracking
for child in roots
mi = child.mi_info.mi
precompile(mi.specTypes) # TODO: Julia should allow one to pass `mi` directly (would handle `invoke` properly)
verbose[] && println(mi)
check_edges(child)
end
end

Expand Down

2 comments on commit c6ac730

@timholy
Copy link
Member Author

@timholy timholy commented on c6ac730 May 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error while trying to register: "Tag with name v1.0.2 already exists and points to a different commit"

Please sign in to comment.