This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Process each block only once in fixCFGForPIC
ClosedPublic

Authored by FPar on Jul 23 2022, 10:53 PM.

Details

Summary

Rather than iterating over the whole function from the start until no
internal calls are found, process each block only once and continue
processing after splitting. This version of the function also does not
seemingly invalidate iterators from within the loop.

Diff Detail

Event Timeline

FPar created this revision.Jul 23 2022, 10:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2022, 10:53 PM
Herald added a subscriber: ayermolo. · View Herald Transcript
FPar requested review of this revision.Jul 23 2022, 10:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2022, 10:53 PM

Thanks for improving the efficiency of fixCFGForPIC(). The change looks fine to me. Do you think the implementation will be simpler if we make Blocks a queue and add newly added blocks to the end? This way we can get rid of the inner loop and dealing with CurrentBB/NextBB.

FPar updated this revision to Diff 447399.Jul 25 2022, 10:24 AM

Eliminate inner loop through queue

FPar added a comment.Jul 25 2022, 10:26 AM

Thanks for improving the efficiency of fixCFGForPIC(). The change looks fine to me. Do you think the implementation will be simpler if we make Blocks a queue and add newly added blocks to the end? This way we can get rid of the inner loop and dealing with CurrentBB/NextBB.

That makes totally sense. It somehow slipped my mind.

As far as I can tell, there is also no need for setting annotation in this function anymore. Is that correct?

maksfb accepted this revision.Jul 25 2022, 11:54 AM

LGTM. Good point, no need for the annotation.

This revision is now accepted and ready to land.Jul 25 2022, 11:54 AM
This revision was automatically updated to reflect the committed changes.