This is an archive of the discontinued LLVM Phabricator instance.

[NewPM][Inliner] Check if deleted function is in current SCC
ClosedPublic

Authored by aeubanks on Jul 20 2021, 3:15 PM.

Details

Summary

In weird cases, the inliner will inline internal recursive functions,
sometimes causing them to have no more uses, in which case the
inliner will mark the function to be deleted. The function is
actually deleted after the call to
updateCGAndAnalysisManagerForCGSCCPass(). In
updateCGAndAnalysisManagerForCGSCCPass(), UR.UpdatedC may be set to
the SCC containing the function to be deleted. Then the inliner calls
CG.removeDeadFunction() which can cause that SCC to be deleted, even
though it's still stored in UR.UpdatedC.

We could potentially check in the wrappers/pass managers if UR.UpdatedC
is in UR.InvalidatedSCCs before doing anything with it, but it's safer
to do this as close to possible to the call to CG.removeDeadFunction()
to avoid issues with allocating a new SCC in the same address as
the deleted one.

It's hard to find a small test case since we need to have recursive
internal functions be reachable from non-internal functions, yet they
need to become non-recursive and not referenced by other functions when
inlined.

Similar to https://reviews.llvm.org/D106306.

Fixes PR50788.

Diff Detail

Event Timeline

aeubanks created this revision.Jul 20 2021, 3:15 PM
aeubanks requested review of this revision.Jul 20 2021, 3:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2021, 3:15 PM
asbirlea accepted this revision.Jul 20 2021, 5:02 PM

LGTM, thank you!

This revision is now accepted and ready to land.Jul 20 2021, 5:02 PM
This revision was landed with ongoing or failed builds.Jul 21 2021, 8:49 AM
This revision was automatically updated to reflect the committed changes.