-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SHT_LLVM_BB_ADDR_MAP][AsmPrinter] Add none and all options to PGO Map #111221
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_MAP][AsmPrinter] Add none and all options to PGO Map #111221
Conversation
This patch adds none and all options to the -pgo-analysis-map flag, which do basically what they say on the tin. The none option is added to enable forcing the pgo-analysis-map by overriding an earlier invocation of the flag. The all option is just added for convenience.
@llvm/pr-subscribers-backend-x86 Author: Aiden Grossman (boomanaiden154) ChangesThis patch adds none and all options to the -pgo-analysis-map flag, which do basically what they say on the tin. The none option is added to enable forcing the pgo-analysis-map by overriding an earlier invocation of the flag. The all option is just added for convenience. Full diff: https://github.com/llvm/llvm-project/pull/111221.diff 2 Files Affected:
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 3a8cde7330efc0..6d1fbf29580e3a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -141,18 +141,22 @@ using namespace llvm;
// `object::PGOAnalysisMap::Features::decode(PgoAnalysisMapFeatures.getBits())`
// succeeds.
enum class PGOMapFeaturesEnum {
+ None,
FuncEntryCount,
BBFreq,
BrProb,
+ All,
};
static cl::bits<PGOMapFeaturesEnum> PgoAnalysisMapFeatures(
"pgo-analysis-map", cl::Hidden, cl::CommaSeparated,
- cl::values(clEnumValN(PGOMapFeaturesEnum::FuncEntryCount,
- "func-entry-count", "Function Entry Count"),
- clEnumValN(PGOMapFeaturesEnum::BBFreq, "bb-freq",
- "Basic Block Frequency"),
- clEnumValN(PGOMapFeaturesEnum::BrProb, "br-prob",
- "Branch Probability")),
+ cl::values(
+ clEnumValN(PGOMapFeaturesEnum::None, "none", "Disable all options"),
+ clEnumValN(PGOMapFeaturesEnum::FuncEntryCount, "func-entry-count",
+ "Function Entry Count"),
+ clEnumValN(PGOMapFeaturesEnum::BBFreq, "bb-freq",
+ "Basic Block Frequency"),
+ clEnumValN(PGOMapFeaturesEnum::BrProb, "br-prob", "Branch Probability"),
+ clEnumValN(PGOMapFeaturesEnum::All, "all", "Enable all options")),
cl::desc(
"Enable extended information within the SHT_LLVM_BB_ADDR_MAP that is "
"extracted from PGO related analysis."));
@@ -1367,9 +1371,18 @@ static uint32_t getBBAddrMapMetadata(const MachineBasicBlock &MBB) {
static llvm::object::BBAddrMap::Features
getBBAddrMapFeature(const MachineFunction &MF, int NumMBBSectionRanges) {
- return {PgoAnalysisMapFeatures.isSet(PGOMapFeaturesEnum::FuncEntryCount),
- PgoAnalysisMapFeatures.isSet(PGOMapFeaturesEnum::BBFreq),
- PgoAnalysisMapFeatures.isSet(PGOMapFeaturesEnum::BrProb),
+ bool NoFeatures = PgoAnalysisMapFeatures.isSet(PGOMapFeaturesEnum::None);
+ bool AllFeatures = PgoAnalysisMapFeatures.isSet(PGOMapFeaturesEnum::All);
+ bool FuncEntryCountEnabled =
+ AllFeatures || (!NoFeatures && PgoAnalysisMapFeatures.isSet(
+ PGOMapFeaturesEnum::FuncEntryCount));
+ bool BBFreqEnabled =
+ AllFeatures ||
+ (!NoFeatures && PgoAnalysisMapFeatures.isSet(PGOMapFeaturesEnum::BBFreq));
+ bool BrProbEnabled =
+ AllFeatures ||
+ (!NoFeatures && PgoAnalysisMapFeatures.isSet(PGOMapFeaturesEnum::BrProb));
+ return {FuncEntryCountEnabled, BBFreqEnabled, BrProbEnabled,
MF.hasBBSections() && NumMBBSectionRanges > 1};
}
diff --git a/llvm/test/CodeGen/X86/basic-block-address-map-pgo-features.ll b/llvm/test/CodeGen/X86/basic-block-address-map-pgo-features.ll
index 73fe4f6ffedb0e..1c3db738a94768 100644
--- a/llvm/test/CodeGen/X86/basic-block-address-map-pgo-features.ll
+++ b/llvm/test/CodeGen/X86/basic-block-address-map-pgo-features.ll
@@ -1,8 +1,10 @@
; Check the basic block sections labels option
-; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-address-map | FileCheck %s --check-prefixes=CHECK,BASIC
+; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-address-map | FileCheck %s --check-prefixes=CHECK,BASIC,PGO-NONE
+; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-address-map -pgo-analysis-map=none | FileCheck %s --check-prefixes=CHECK,BASIC,PGO-NONE
;; Also verify this holds for all PGO features enabled
; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-address-map -pgo-analysis-map=func-entry-count,bb-freq,br-prob | FileCheck %s --check-prefixes=CHECK,PGO-ALL,PGO-FEC,PGO-BBF,PGO-BRP
+; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-address-map -pgo-analysis-map=all | FileCheck %s --check-prefixes=CHECK,PGO-ALL,PGO-FEC,PGO-BBF,PGO-BRP
;; Also verify that pgo extension only includes the enabled feature
; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-address-map -pgo-analysis-map=func-entry-count | FileCheck %s --check-prefixes=CHECK,PGO-FEC,FEC-ONLY
@@ -93,6 +95,9 @@ declare i32 @__gxx_personality_v0(...)
; CHECK-NEXT: .byte 4
;; PGO Analysis Map
+; PGO-NONE-NOT: .byte 100 # function entry count
+; PGO-NONE-NOT: .ascii "\271\235\376\332\245\200\356\017" # basic block frequency
+; PGO-NONE-NOT: .byte 2 # basic block successor count
; PGO-FEC-NEXT: .byte 100 # function entry count
; PGO-BBF-NEXT: .ascii "\271\235\376\332\245\200\356\017" # basic block frequency
; PGO-BRP-NEXT: .byte 2 # basic block successor count
|
I think an 'all' option seems good. Why do we want a 'none'? My thought is that would just be omitting the |
With certain build systems (bazel in this case), it can be useful to have the ability to have the ability to append something to the compiler command line to force the option off when building certain applications/files that interact poorly with these options (like certain configurations of OpenSSL). |
Good example! That makes sense. |
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.
LGTM
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/88/builds/3903 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/60/builds/11122 Here is the relevant piece of the build log for the reference
|
llvm#111221) This patch adds none and all options to the -pgo-analysis-map flag, which do basically what they say on the tin. The none option is added to enable forcing the pgo-analysis-map by overriding an earlier invocation of the flag. The all option is just added for convenience.
llvm#111221) This patch adds none and all options to the -pgo-analysis-map flag, which do basically what they say on the tin. The none option is added to enable forcing the pgo-analysis-map by overriding an earlier invocation of the flag. The all option is just added for convenience.
This patch adds none and all options to the -pgo-analysis-map flag, which do basically what they say on the tin. The none option is added to enable forcing the pgo-analysis-map by overriding an earlier invocation of the flag. The all option is just added for convenience.