This is an archive of the discontinued LLVM Phabricator instance.

[SimpifyCFG] Remove recursion from FoldCondBranchOnPHI. NFCI.
ClosedPublic

Authored by critson on Aug 10 2021, 1:16 AM.

Details

Summary

Avoid stack overflow errors on systems with small stack sizes
by removing recursion in FoldCondBranchOnPHI.

This is a simple change as the recursion was only iteratively
calling the function again on the same arguments.
Ideally this would be compiled to a tail call, but there is
no guarantee.

Diff Detail

Event Timeline

critson created this revision.Aug 10 2021, 1:16 AM
critson requested review of this revision.Aug 10 2021, 1:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2021, 1:16 AM
lebedev.ri added inline comments.Aug 10 2021, 1:32 AM
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
2727

Presumably this should return None?

2735–2741

This might be more readable, we don't really care how much recursion we have..

critson marked 2 inline comments as done.Aug 10 2021, 2:51 AM
critson added inline comments.
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
2727

Yes, thanks!
I had forgotten what the NoneType was called.

2735–2741

Agreed.

critson updated this revision to Diff 365401.Aug 10 2021, 2:51 AM
critson marked 2 inline comments as done.
  • Incorporate reviewer feedback
This revision is now accepted and ready to land.Aug 10 2021, 2:53 AM
This revision was landed with ongoing or failed builds.Aug 10 2021, 3:33 AM
This revision was automatically updated to reflect the committed changes.