Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BOLT] CDSplit Main Logic Part 1/3 #73082

Closed

Conversation

ShatianWang
Copy link
Contributor

The first diff in a series of 3 that implements the main logic of
CDSplit. Under X86, function splitting can lead to block size increase.
This is because conditional and unconditional branch instructions whose
offset is under 8 bits can be encoded with 2 bytes. If the offset is
greater than 8 bits, then they need 6 and 5 bytes respectively.
Splitting a short conditional / unconditional branch will thus increase
the size of the src basic block by 4 and 3 bytes respectively. CDSplit
takes into account the potential block size increase when it makes
splitting decisions. This diff implements a function
estimatePostSplitBBAddress in CDSplit that approximates the block level
size increase at the given split index of the given function.

@ShatianWang ShatianWang marked this pull request as ready for review November 22, 2023 04:41
@ShatianWang
Copy link
Contributor Author

Note: this PR is 6/8 for upstreaming a new 3-way (hot-warm-cold) function splitting algorithm CDSplit.
It is one commit ahead of #73081

This commit modifies BinaryContext::calculateEmittedSize to update the
BinaryBasicBlock::OutputAddressRange for each basic block in the input
BF. The modification is done in place, where BB.OutputAddressRange.second
less BB.OutputAddressRange.first now gives the emitted size of the basic
block.
This commit updates SplitFunctions.h and SplitFunctions.cpp to enable
the reuse of createEHTrampolines, mergeEHTrampolines, hasFullProfile,
and allBlocksCold by a distinct function splitting pass (CDSplit).
This commit establishes the general structure of the CDSplit
implementation without incorporating the exact splitting logic.
Currently, all functions undergo hot-cold splitting based on the
decisions made by the SplitFunctions pass. Subsequent commits
will introduce the precise splitting logic.
This commit explicitly adds a warm code section, .text.warm, when the
-use-cdsplit=1 flag is set. This replaces the previous approach of using
.text.cold.0 as warm and .text.cold.1 as cold in 3-way splitting.
This diff defines and initializes auxiliary variables used by CDSplit.
The first diff in a series of 3 that implements the main logic of
CDSplit. Under X86, function splitting can lead to block size increase.
This is because conditional and unconditional branch instructions whose
offset is under 8 bits can be encoded with 2 bytes. If the offset is
greater than 8 bits, then they need 6 and 5 bytes respectively.
Splitting a short conditional / unconditional branch will thus increase
the size of the src basic block by 4 and 3 bytes respectively. CDSplit
takes into account the potential block size increase when it makes
splitting decisions. This diff implements a function
estimatePostSplitBBAddress in CDSplit that approximates the block level
size increase at the given split index of the given function.
@ShatianWang ShatianWang force-pushed the 112123Commit6_CDSplitMainLogic1 branch from f88459f to 9069680 Compare November 22, 2023 17:12
@ShatianWang ShatianWang marked this pull request as draft November 23, 2023 20:41
@ShatianWang ShatianWang deleted the 112123Commit6_CDSplitMainLogic1 branch December 21, 2023 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant