Page MenuHomePhabricator

[CallGraph] Preserve call records vector when replacing call edge

Authored by sdmitriev on Jul 22 2020, 1:41 AM.



Try not to resize vector of call records in a call graph node when
replacing call edge. That would prevent invalidation of iterators
stored in the CG SCC pass manager's scc_iterator.

Diff Detail

Event Timeline

sdmitriev created this revision.Jul 22 2020, 1:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2020, 1:41 AM
sdmitriev updated this revision to Diff 279728.Jul 22 2020, 2:02 AM

This is a "fix" for the failure we see only if the number of callbacks is the same, correct?

Yes, exactly. If the number of callbacks is the same we can avoid invalidating iterators. I assume that should really cover most of the cases.

Added unit test for the CallGraphNode::replaceCallEdge() change. Without this change test finishes with an assertion on windows debug build.

jdoerfert accepted this revision.Jul 27 2020, 5:27 AM

LGTM. This is not "great" but one of those shortcomings of the legacy CG we can work around in the hops it will be removed soon.
FWIW, in the absence of callbacks this should not cause much cost and be a no-op.

This revision is now accepted and ready to land.Jul 27 2020, 5:27 AM
This revision was automatically updated to reflect the committed changes.