[PATCH] D133907: [LazyCallGraph] Handle spurious ref edges when deleting a dead function

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 14 16:35:22 PDT 2022


aeubanks created this revision.
aeubanks added a reviewer: asbirlea.
Herald added a subscriber: hiraditya.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133907

Files:
  llvm/include/llvm/Analysis/LazyCallGraph.h
  llvm/lib/Analysis/LazyCallGraph.cpp
  llvm/test/Analysis/LazyCallGraph/remove-dead-function-spurious-ref-edge.ll
  llvm/unittests/Analysis/LazyCallGraphTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133907.460264.patch
Type: text/x-patch
Size: 12093 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220914/28670df5/attachment.bin>


More information about the llvm-commits mailing list