-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[SHT_LLVM_BB_ADDR] Implement ELF and YAML support for Propeller CFG data in PGO analysis map. #164914
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
[SHT_LLVM_BB_ADDR] Implement ELF and YAML support for Propeller CFG data in PGO analysis map. #164914
Changes from 9 commits
4607f03
a0f61cb
f367d59
3068d13
2c84241
2ef8082
71604d3
a2347af
989b55e
a5e3564
4f9aee7
ceb304f
9b92076
3832bf9
ffd870c
c113f78
028c3cb
8a0a020
7e7ab00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -834,6 +834,7 @@ struct BBAddrMap { | |
| bool OmitBBEntries : 1; | ||
| bool CallsiteEndOffsets : 1; | ||
| bool BBHash : 1; | ||
| bool PropellerCfg : 1; | ||
|
|
||
| bool hasPGOAnalysis() const { return FuncEntryCount || BBFreq || BrProb; } | ||
|
|
||
|
|
@@ -847,7 +848,8 @@ struct BBAddrMap { | |
| (static_cast<uint8_t>(MultiBBRange) << 3) | | ||
| (static_cast<uint8_t>(OmitBBEntries) << 4) | | ||
| (static_cast<uint8_t>(CallsiteEndOffsets) << 5) | | ||
| (static_cast<uint8_t>(BBHash) << 6); | ||
| (static_cast<uint8_t>(BBHash) << 6) | | ||
| (static_cast<uint8_t>(PropellerCfg) << 7); | ||
| } | ||
|
|
||
| // Decodes from minimum bit width representation and validates no | ||
|
|
@@ -857,7 +859,7 @@ struct BBAddrMap { | |
| static_cast<bool>(Val & (1 << 0)), static_cast<bool>(Val & (1 << 1)), | ||
| static_cast<bool>(Val & (1 << 2)), static_cast<bool>(Val & (1 << 3)), | ||
| static_cast<bool>(Val & (1 << 4)), static_cast<bool>(Val & (1 << 5)), | ||
| static_cast<bool>(Val & (1 << 6))}; | ||
| static_cast<bool>(Val & (1 << 6)), static_cast<bool>(Val & (1 << 7))}; | ||
| if (Feat.encode() != Val) | ||
| return createStringError( | ||
| std::error_code(), "invalid encoding for BBAddrMap::Features: 0x%x", | ||
|
|
@@ -867,10 +869,12 @@ struct BBAddrMap { | |
|
|
||
| bool operator==(const Features &Other) const { | ||
| return std::tie(FuncEntryCount, BBFreq, BrProb, MultiBBRange, | ||
| OmitBBEntries, CallsiteEndOffsets, BBHash) == | ||
| OmitBBEntries, CallsiteEndOffsets, BBHash, | ||
| PropellerCfg) == | ||
| std::tie(Other.FuncEntryCount, Other.BBFreq, Other.BrProb, | ||
| Other.MultiBBRange, Other.OmitBBEntries, | ||
| Other.CallsiteEndOffsets, Other.BBHash); | ||
| Other.CallsiteEndOffsets, Other.BBHash, | ||
| Other.PropellerCfg); | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -1013,20 +1017,25 @@ struct PGOAnalysisMap { | |
| uint32_t ID; | ||
| /// Branch Probability of the edge to this successor taken from MBPI. | ||
| BranchProbability Prob; | ||
| /// Edge frequency from Propeller. | ||
| uint32_t PropellerFreq; | ||
|
|
||
| bool operator==(const SuccessorEntry &Other) const { | ||
| return std::tie(ID, Prob) == std::tie(Other.ID, Other.Prob); | ||
| return std::tie(ID, Prob, PropellerFreq) == | ||
| std::tie(Other.ID, Other.Prob, Other.PropellerFreq); | ||
| } | ||
| }; | ||
|
|
||
| /// Block frequency taken from MBFI | ||
| BlockFrequency BlockFreq; | ||
| /// Block frequency taken from Propeller. | ||
| uint32_t PropellerBlockFreq; | ||
|
||
| /// List of successors of the current block | ||
| llvm::SmallVector<SuccessorEntry, 2> Successors; | ||
|
|
||
| bool operator==(const PGOBBEntry &Other) const { | ||
| return std::tie(BlockFreq, Successors) == | ||
| std::tie(Other.BlockFreq, Other.Successors); | ||
| return std::tie(BlockFreq, PropellerBlockFreq, Successors) == | ||
| std::tie(Other.BlockFreq, PropellerBlockFreq, Other.Successors); | ||
| } | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,8 +6,9 @@ | |
| # Case 4: Specify Entries. | ||
| # CHECK: Name: .llvm_bb_addr_map (1) | ||
| # CHECK: SectionData ( | ||
| # CHECK-NEXT: 0000: 02072000 00000000 0000010B 010203E8 | ||
| # CHECK-NEXT: 0010: 07E80702 0CEEDDBB F70E0D91 A2C48801 | ||
| # CHECK-NEXT: 0000: 02872000 00000000 0000010B 010203E8 | ||
| # CHECK-NEXT: 0010: 07E80764 020CEEDD BBF70E28 0D91A2C4 | ||
| # CHECK-NEXT: 0020: 880100 | ||
| # CHECK-NEXT: ) | ||
|
|
||
| # Case 7: Not including a field which is enabled in feature doesn't emit value | ||
|
|
@@ -31,7 +32,7 @@ Sections: | |
| Type: SHT_LLVM_BB_ADDR_MAP | ||
| Entries: | ||
| - Version: 2 | ||
| Feature: 0x7 | ||
| Feature: 0x87 | ||
| BBRanges: | ||
| - BaseAddress: 0x0000000000000020 | ||
| BBEntries: | ||
|
|
@@ -42,12 +43,14 @@ Sections: | |
| PGOAnalyses: | ||
| - FuncEntryCount: 1000 | ||
| PGOBBEntries: | ||
| - BBFreq: 1000 | ||
| - BBFreq: 1000 | ||
| PropellerBBFreq: 100 | ||
| Successors: | ||
| - ID: 12 | ||
| BrProb: 0xeeeeeeee | ||
| - ID: 13 | ||
| BrProb: 0x11111111 | ||
| - ID: 12 | ||
| BrProb: 0xeeeeeeee | ||
| PropellerBrFreq: 40 | ||
| - ID: 13 | ||
| BrProb: 0x11111111 | ||
|
|
||
| ## 2) According to feature we have FuncEntryCount but none is provided in yaml | ||
| - Name: '.llvm_bb_addr_map (2)' | ||
|
|
@@ -65,8 +68,8 @@ Sections: | |
| Metadata: 0x00000003 | ||
|
|
||
| ## Check that yaml2obj generates a warning when we use unsupported feature. | ||
| # RUN: yaml2obj --docnum=2 %s 2>&1 | FileCheck %s --check-prefix=INVALID-FEATURE | ||
| # INVALID-FEATURE: warning: invalid encoding for BBAddrMap::Features: 0xf0 | ||
| # RUN: not yaml2obj --docnum=2 %s 2>&1 | FileCheck %s --check-prefix=INVALID-FEATURE | ||
| # INVALID-FEATURE: error: out of range hex8 number | ||
|
||
|
|
||
| --- !ELF | ||
| FileHeader: | ||
|
|
@@ -79,4 +82,4 @@ Sections: | |
| Entries: | ||
| - Version: 2 | ||
| ## Specify unsupported feature | ||
| Feature: 0xF0 | ||
| Feature: 0x100 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you zero-init the primitive types? less chance of UB through maintenance later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.