This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Replace uses of layout with basic block list
ClosedPublic

Authored by FPar on Jul 12 2022, 12:31 PM.

Details

Summary

As we are moving towards support for multiple fragments, loops that
iterate over all basic blocks of a function, but do not depend on the
order of basic blocks in the final layout, should iterate over binary
functions directly, rather than the layout.

Eventually, all loops using the layout list should either iterate over
the function, or be aware of multiple layouts. This patch replaces
references to binary function's block layout with the binary function
itself where only little code changes are necessary.

Diff Detail

Event Timeline

FPar created this revision.Jul 12 2022, 12:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2022, 12:31 PM
Herald added a subscriber: ayermolo. · View Herald Transcript
FPar requested review of this revision.Jul 12 2022, 12:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2022, 12:31 PM
FPar updated this revision to Diff 444142.Jul 12 2022, 8:39 PM

Remove some substitutions

Maybe instead of for (const BinaryBasicBlock *const BB : BasicBlocks) we can have for (const BinaryBasicBlock &BB : blocks())?

Other than that, looks good to me. Thanks.

bolt/lib/Core/BinaryFunction.cpp
3521

nit: remove curly braces.

3525

Likewise.

FPar updated this revision to Diff 444719.Jul 14 2022, 10:28 AM

Replace iterations over blocks with *this

FPar marked 2 inline comments as done.Jul 14 2022, 10:30 AM
FPar updated this revision to Diff 444726.Jul 14 2022, 10:37 AM

Use blocks() instead of *this to iterate

FPar added a comment.Jul 14 2022, 10:38 AM

Maybe instead of for (const BinaryBasicBlock *const BB : BasicBlocks) we can have for (const BinaryBasicBlock &BB : blocks())?

Done.

maksfb accepted this revision.Jul 14 2022, 11:55 AM

LGTM. Please address a couple if nits before commit.

bolt/lib/Core/BinaryFunction.cpp
3514

nit:

3518

nit:

This revision is now accepted and ready to land.Jul 14 2022, 11:55 AM
This revision was automatically updated to reflect the committed changes.
FPar marked 2 inline comments as done.Jul 14 2022, 1:13 PM