This is an archive of the discontinued LLVM Phabricator instance.

[BasicBlockSections] Introduce the path cloning profile format to BasicBlockSectionsProfileReader.
Changes PlannedPublic

Authored by rahmanl on Aug 21 2023, 11:00 AM.

Details

Reviewers
tmsriram
shenhan
Summary

Following up on prior RFC (https://lists.llvm.org/pipermail/llvm-dev/2020-September/145357.html) we can now improve above our highly-optimized basic-block-sections binary (e.g., 2% for clang) by applying path cloning. Cloning can improve performance by reducing taken branches.

This patch prepares the profile format for applying cloning actions.

The basic block cloning profile format extends the basic block sections profile in two ways.

  1. Specifies the cloning paths with a !!! prefix. For example, !!!1 4 5 specifies that blocks with BB ids 4 and 5 must be cloned along the edge 1 --> 4.
  2. For each cloned block, it will appear in the cluster info as <bb_id>.<clone_id> where clone_id is the id associated with this clone.

For example, the following profile specifies one cloned block (2) and determines its cluster position as well.

!foo
!!!1 2
!!0 1 2.1 3 2 5

This patch keeps backward-compatibility (retains the behavior for old profile format).

Diff Detail

Event Timeline

rahmanl created this revision.Aug 21 2023, 11:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 21 2023, 11:00 AM
rahmanl requested review of this revision.Aug 21 2023, 11:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 21 2023, 11:00 AM
rahmanl updated this revision to Diff 552084.Aug 21 2023, 11:26 AM

Add BasicBlockSections.cpp changes.

rahmanl edited the summary of this revision. (Show Details)Aug 21 2023, 11:35 AM
rahmanl updated this revision to Diff 552094.Aug 21 2023, 11:59 AM

clang-format.

rahmanl updated this revision to Diff 552100.Aug 21 2023, 12:26 PM

Add the cloning profile format to the function comment.

rahmanl edited the summary of this revision. (Show Details)Aug 21 2023, 12:27 PM
rahmanl edited the summary of this revision. (Show Details)
rahmanl edited the summary of this revision. (Show Details)
rahmanl edited the summary of this revision. (Show Details)
rahmanl retitled this revision from [Propeller] Introduce the path cloning profile format to BasicBlockSectionsProfileReader. to [BasicBlockSections] Introduce the path cloning profile format to BasicBlockSectionsProfileReader..Aug 21 2023, 1:09 PM

The description requires more details. Please point to any prior discussions on cloning and its performance potential. Can you explain in some more detail how this syntax is powerful enough to capture a general cloning operation?

Rather than just use "number of !s", can we try to change the grammar? How about a character to specify the action type, 'c' for cloning?

rahmanl edited the summary of this revision. (Show Details)Aug 23 2023, 1:10 PM
rahmanl added a subscriber: FatihBAKIR.
rahmanl planned changes to this revision.Aug 23 2023, 1:26 PM