This is an archive of the discontinued LLVM Phabricator instance.

[LazyCallGraph] Handle spurious ref edges when deleting a dead function
ClosedPublic

Authored by aeubanks on Sep 14 2022, 4:35 PM.

Details

Summary

Spurious ref edges are ref edges that still exist in the call graph even
though the corresponding IR reference no longer exists. This can cause
issues when deleting a dead function which has a spurious ref edge
pointed at it because currently we expect the dead function's RefSCC to
be trivial.

In the case that the dead function's RefSCC is not trivial, remove all
ref edges from other nodes in the RefSCC to it.

Removing a ref edge can result in splitting RefSCCs. There's actually no
reason to revisit those RefSCCs because currently we only run passes on
SCCs, and we've already added all SCCs in the RefSCC to the worklist.
(as opposed to removing the ref edge in
updateCGAndAnalysisManagerForPass() which can modify the call graph of
SCCs we have not visited yet). We also don't expect that RefSCC
refinement will allow us to glean any more information for optimization
use. Also, doing so would drastically increase the complexity of
LazyCallGraph::removeDeadFunction(), requiring us to return a list of
invalidated RefSCCs and new RefSCCs to add to the worklist.

Fixes #56503

Diff Detail

Event Timeline

aeubanks created this revision.Sep 14 2022, 4:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 14 2022, 4:35 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
aeubanks requested review of this revision.Sep 14 2022, 4:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 14 2022, 4:35 PM
aeubanks updated this revision to Diff 462290.Sep 22 2022, 2:12 PM

add comment

asbirlea accepted this revision.Sep 22 2022, 2:30 PM

Thanks for resolving this!

llvm/include/llvm/Analysis/LazyCallGraph.h
1068

incomplete comment?

This revision is now accepted and ready to land.Sep 22 2022, 2:30 PM
aeubanks updated this revision to Diff 462301.Sep 22 2022, 2:53 PM

remove outdated comment