@@ -141,18 +141,22 @@ using namespace llvm;
141141// `object::PGOAnalysisMap::Features::decode(PgoAnalysisMapFeatures.getBits())`
142142// succeeds.
143143enum class PGOMapFeaturesEnum {
144+ None,
144145 FuncEntryCount,
145146 BBFreq,
146147 BrProb,
148+ All,
147149};
148150static cl::bits<PGOMapFeaturesEnum> PgoAnalysisMapFeatures (
149151 " pgo-analysis-map" , cl::Hidden, cl::CommaSeparated,
150- cl::values (clEnumValN(PGOMapFeaturesEnum::FuncEntryCount,
151- " func-entry-count" , " Function Entry Count" ),
152- clEnumValN(PGOMapFeaturesEnum::BBFreq, " bb-freq" ,
153- " Basic Block Frequency" ),
154- clEnumValN(PGOMapFeaturesEnum::BrProb, " br-prob" ,
155- " Branch Probability" )),
152+ cl::values (
153+ clEnumValN (PGOMapFeaturesEnum::None, " none" , " Disable all options" ),
154+ clEnumValN(PGOMapFeaturesEnum::FuncEntryCount, " func-entry-count" ,
155+ " Function Entry Count" ),
156+ clEnumValN(PGOMapFeaturesEnum::BBFreq, " bb-freq" ,
157+ " Basic Block Frequency" ),
158+ clEnumValN(PGOMapFeaturesEnum::BrProb, " br-prob" , " Branch Probability" ),
159+ clEnumValN(PGOMapFeaturesEnum::All, " all" , " Enable all options" )),
156160 cl::desc(
157161 " Enable extended information within the SHT_LLVM_BB_ADDR_MAP that is "
158162 " extracted from PGO related analysis." ));
@@ -1367,9 +1371,18 @@ static uint32_t getBBAddrMapMetadata(const MachineBasicBlock &MBB) {
13671371
13681372static llvm::object::BBAddrMap::Features
13691373getBBAddrMapFeature (const MachineFunction &MF, int NumMBBSectionRanges) {
1370- return {PgoAnalysisMapFeatures.isSet (PGOMapFeaturesEnum::FuncEntryCount),
1371- PgoAnalysisMapFeatures.isSet (PGOMapFeaturesEnum::BBFreq),
1372- PgoAnalysisMapFeatures.isSet (PGOMapFeaturesEnum::BrProb),
1374+ bool NoFeatures = PgoAnalysisMapFeatures.isSet (PGOMapFeaturesEnum::None);
1375+ bool AllFeatures = PgoAnalysisMapFeatures.isSet (PGOMapFeaturesEnum::All);
1376+ bool FuncEntryCountEnabled =
1377+ AllFeatures || (!NoFeatures && PgoAnalysisMapFeatures.isSet (
1378+ PGOMapFeaturesEnum::FuncEntryCount));
1379+ bool BBFreqEnabled =
1380+ AllFeatures ||
1381+ (!NoFeatures && PgoAnalysisMapFeatures.isSet (PGOMapFeaturesEnum::BBFreq));
1382+ bool BrProbEnabled =
1383+ AllFeatures ||
1384+ (!NoFeatures && PgoAnalysisMapFeatures.isSet (PGOMapFeaturesEnum::BrProb));
1385+ return {FuncEntryCountEnabled, BBFreqEnabled, BrProbEnabled,
13731386 MF.hasBBSections () && NumMBBSectionRanges > 1 };
13741387}
13751388
0 commit comments