[llvm] 7c9cf0c - [SHT_LLVM_BB_ADDR_MAP][AsmPrinter] Emit error on bad option combinatons
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 26 01:16:24 PDT 2024
Author: Aiden Grossman
Date: 2024-10-26T08:15:34Z
New Revision: 7c9cf0c6f09115c2d948f16946aa3b36bf483f34
URL: https://github.com/llvm/llvm-project/commit/7c9cf0c6f09115c2d948f16946aa3b36bf483f34
DIFF: https://github.com/llvm/llvm-project/commit/7c9cf0c6f09115c2d948f16946aa3b36bf483f34.diff
LOG: [SHT_LLVM_BB_ADDR_MAP][AsmPrinter] Emit error on bad option combinatons
This patch makes it so that specifying all or none for -pgo-analysis-map
along with an explicit option causes an error as this set of options
does not really make sense.
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/test/CodeGen/X86/basic-block-address-map-pgo-features.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 2d444f2f970ac1..4ea71c9bd4ad4c 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1371,6 +1371,16 @@ static uint32_t getBBAddrMapMetadata(const MachineBasicBlock &MBB) {
static llvm::object::BBAddrMap::Features
getBBAddrMapFeature(const MachineFunction &MF, int NumMBBSectionRanges) {
+ // Ensure that the user has not passed in additional options while also
+ // specifying all or none.
+ if ((PgoAnalysisMapFeatures.isSet(PGOMapFeaturesEnum::None) ||
+ PgoAnalysisMapFeatures.isSet(PGOMapFeaturesEnum::All)) &&
+ popcount(PgoAnalysisMapFeatures.getBits()) != 1) {
+ MF.getFunction().getContext().emitError(
+ "-pgo-anaylsis-map can accept only all or none with no additional "
+ "values.");
+ }
+
bool NoFeatures = PgoAnalysisMapFeatures.isSet(PGOMapFeaturesEnum::None);
bool AllFeatures = PgoAnalysisMapFeatures.isSet(PGOMapFeaturesEnum::All);
bool FuncEntryCountEnabled =
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 1c3db738a94768..fca5aa046b03b9 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
@@ -11,6 +11,10 @@
; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-address-map -pgo-analysis-map=bb-freq | FileCheck %s --check-prefixes=CHECK,PGO-BBF,BBF-ONLY
; RUN: llc < %s -mtriple=x86_64 -function-sections -unique-section-names=true -basic-block-address-map -pgo-analysis-map=br-prob | FileCheck %s --check-prefixes=CHECK,PGO-BRP,BRP-ONLY
+;; Verify that we emit an error if we try and specify values in addition to all/none
+; RUN: not llc < %s -mtriple=x86_64 -basic-block-address-map -pgo-analysis-map=all,bb-freq
+; RUN: not llc < %s -mtriple=x86_64 -basic-block-address-map -pgo-analysis-map=none,bb-freq
+
define void @_Z3bazb(i1 zeroext, i1 zeroext) personality ptr @__gxx_personality_v0 !prof !0 {
br i1 %0, label %3, label %8, !prof !1
More information about the llvm-commits
mailing list