forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BOLT] CDSplit main logic part 2/2 (llvm#74032)
This diff implements the main splitting logic of CDSplit. CDSplit processes functions in a binary in parallel. For each function BF, it assumes that all other functions are hot-cold split. For each possible hot-warm split point of BF, it computes its corresponding SplitScore, and chooses the split point with the best SplitScore. The SplitScore of each split point is computed in the following way: each call edge or jump edge has an edge score that is proportional to its execution count, and inversely proportional to its distance. The SplitScore of a split point is a sum of edge scores over a fixed set of edges whose distance can change due to hot-warm splitting BF. This set contains all cover calls in the form of X->Y or Y->X given function order [... X ... BF ... Y ...]; we refer to the sum of edge scores over the set of cover calls as CoverCallScore. This set also contains all jump edges (branches) within BF as well as all call edges originated from BF; we refer to the sum of edge scores over this set of edges as LocalScore. CDSplit finds the split index maximizing CoverCallScore + LocalScore.
- Loading branch information
1 parent
a37c69e
commit 4483cf2
Showing
3 changed files
with
484 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
# Test the control of aggressiveness of 3-way splitting by -call-scale. | ||
# When -call-scale=0.0, the tested function is 2-way splitted. | ||
# When -call-scale=1.0, the tested function is 3-way splitted with 5 blocks | ||
# in warm because of the increased benefit of shortening the call edges. | ||
# When -call-scale=1000.0, the tested function is 3-way splitted with 7 blocks | ||
# in warm because of the strong benefit of shortening the call edges. | ||
|
||
# RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %s -o %t.o | ||
# RUN: link_fdata %s %t.o %t.fdata | ||
# RUN: llvm-strip --strip-unneeded %t.o | ||
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q | ||
# RUN: llvm-bolt %t.exe -o %t.bolt --split-functions --split-strategy=cdsplit \ | ||
# RUN: --call-scale=0.0 --print-split --print-only=chain \ | ||
# RUN: --data=%t.fdata --reorder-blocks=ext-tsp \ | ||
# RUN: 2>&1 | FileCheck --check-prefix=LOWINCENTIVE %s | ||
# RUN: llvm-bolt %t.exe -o %t.bolt --split-functions --split-strategy=cdsplit \ | ||
# RUN: --call-scale=1.0 --print-split --print-only=chain \ | ||
# RUN: --data=%t.fdata --reorder-blocks=ext-tsp \ | ||
# RUN: 2>&1 | FileCheck --check-prefix=MEDINCENTIVE %s | ||
# RUN: llvm-bolt %t.exe -o %t.bolt --split-functions --split-strategy=cdsplit \ | ||
# RUN: --call-scale=1000.0 --print-split --print-only=chain \ | ||
# RUN: --data=%t.fdata --reorder-blocks=ext-tsp \ | ||
# RUN: 2>&1 | FileCheck --check-prefix=HIGHINCENTIVE %s | ||
|
||
# LOWINCENTIVE: Binary Function "chain" after split-functions | ||
# LOWINCENTIVE: {{^\.Ltmp5}} | ||
# LOWINCENTIVE: ------- HOT-COLD SPLIT POINT ------- | ||
# LOWINCENTIVE: {{^\.LFT1}} | ||
|
||
# MEDINCENTIVE: Binary Function "chain" after split-functions | ||
# MEDINCENTIVE: {{^\.Ltmp1}} | ||
# MEDINCENTIVE: ------- HOT-COLD SPLIT POINT ------- | ||
# MEDINCENTIVE: {{^\.LFT1}} | ||
# MEDINCENTIVE: ------- HOT-COLD SPLIT POINT ------- | ||
# MEDINCENTIVE: {{^\.Ltmp0}} | ||
# MEDINCENTIVE: {{^\.Ltmp2}} | ||
# MEDINCENTIVE: {{^\.Ltmp3}} | ||
# MEDINCENTIVE: {{^\.Ltmp4}} | ||
# MEDINCENTIVE: {{^\.Ltmp5}} | ||
|
||
# HIGHINCENTIVE: Binary Function "chain" after split-functions | ||
# HIGHINCENTIVE: {{^\.LBB00}} | ||
# HIGHINCENTIVE: ------- HOT-COLD SPLIT POINT ------- | ||
# HIGHINCENTIVE: {{^\.LFT1}} | ||
# HIGHINCENTIVE: ------- HOT-COLD SPLIT POINT ------- | ||
# HIGHINCENTIVE: {{^\.LFT0}} | ||
# HIGHINCENTIVE: {{^\.Ltmp1}} | ||
# HIGHINCENTIVE: {{^\.Ltmp0}} | ||
# HIGHINCENTIVE: {{^\.Ltmp2}} | ||
# HIGHINCENTIVE: {{^\.Ltmp3}} | ||
# HIGHINCENTIVE: {{^\.Ltmp4}} | ||
# HIGHINCENTIVE: {{^\.Ltmp5}} | ||
|
||
|
||
|
||
.text | ||
.globl chain | ||
.type chain, @function | ||
chain: | ||
pushq %rbp | ||
movq %rsp, %rbp | ||
cmpl $2, %edi | ||
LLentry_LLchain_start: | ||
jge LLchain_start | ||
# FDATA: 1 chain #LLentry_LLchain_start# 1 chain #LLchain_start# 0 10 | ||
# FDATA: 1 chain #LLentry_LLchain_start# 1 chain #LLfast# 0 500 | ||
LLfast: | ||
movl $5, %eax | ||
LLfast_LLexit: | ||
jmp LLexit | ||
# FDATA: 1 chain #LLfast_LLexit# 1 chain #LLexit# 0 500 | ||
LLchain_start: | ||
movl $10, %eax | ||
LLchain_start_LLchain1: | ||
jge LLchain1 | ||
# FDATA: 1 chain #LLchain_start_LLchain1# 1 chain #LLchain1# 0 10 | ||
# FDATA: 1 chain #LLchain_start_LLchain1# 1 chain #LLcold# 0 0 | ||
LLcold: | ||
addl $1, %eax | ||
addl $1, %eax | ||
addl $1, %eax | ||
addl $1, %eax | ||
addl $1, %eax | ||
addl $1, %eax | ||
LLchain1: | ||
addl $1, %eax | ||
LLchain1_LLchain2: | ||
jmp LLchain2 | ||
# FDATA: 1 chain #LLchain1_LLchain2# 1 chain #LLchain2# 0 10 | ||
LLchain2: | ||
addl $1, %eax | ||
LLchain2_LLchain3: | ||
jmp LLchain3 | ||
# FDATA: 1 chain #LLchain2_LLchain3# 1 chain #LLchain3# 0 10 | ||
LLchain3: | ||
addl $1, %eax | ||
addl $1, %eax | ||
addl $1, %eax | ||
addl $1, %eax | ||
addl $1, %eax | ||
LLchain3_LLchain4: | ||
jmp LLchain4 | ||
# FDATA: 1 chain #LLchain3_LLchain4# 1 chain #LLchain4# 0 10 | ||
LLchain4: | ||
addl $1, %eax | ||
addl $1, %eax | ||
addl $1, %eax | ||
addl $1, %eax | ||
addl $1, %eax | ||
LLchain4_LLexit: | ||
jmp LLexit | ||
# FDATA: 1 chain #LLchain4_LLexit# 1 chain #LLexit# 0 10 | ||
LLexit: | ||
popq %rbp | ||
ret | ||
LLchain_end: | ||
.size chain, LLchain_end-chain | ||
|
||
|
||
.globl main | ||
.type main, @function | ||
main: | ||
pushq %rbp | ||
movq %rsp, %rbp | ||
movl $1, %edi | ||
LLmain_chain1: | ||
call chain | ||
# FDATA: 1 main #LLmain_chain1# 1 chain 0 0 500 | ||
movl $4, %edi | ||
LLmain_chain2: | ||
call chain | ||
# FDATA: 1 main #LLmain_chain2# 1 chain 0 0 10 | ||
xorl %eax, %eax | ||
popq %rbp | ||
retq | ||
.Lmain_end: | ||
.size main, .Lmain_end-main |
Oops, something went wrong.