This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Optimize copyExtraInfo deep copy
ClosedPublic

Authored by melver on Mar 6 2023, 7:49 AM.

Details

Summary

It turns out that there are relatively trivial, albeit rare, cases that
require a MaxDepth of more than 16 (see added test). However, we want to
avoid having to rely on a large fixed MaxDepth.

Since these cases are relatively rare, apply the following strategy:

  1. Start with a low MaxDepth of 16 - if the entry node was not reached, we can return (the common case).
  2. If the entry node was reached, exponentially increase MaxDepth up to some large limit that should cover all cases and guard against stack exhaustion.

This retains the better performance with a low MaxDepth in the common
case, and in complex cases backs off and retries. On a whole, this is
preferable vs. starting with a large MaxDepth which would unnecessarily
penalize the common case where a low MaxDepth is sufficient.

Diff Detail

Event Timeline

melver created this revision.Mar 6 2023, 7:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2023, 7:49 AM
melver requested review of this revision.Mar 6 2023, 7:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2023, 7:49 AM
dvyukov accepted this revision.Mar 6 2023, 8:14 AM
This revision is now accepted and ready to land.Mar 6 2023, 8:14 AM
This revision was landed with ongoing or failed builds.Mar 6 2023, 8:30 AM
This revision was automatically updated to reflect the committed changes.