Skip to content

Commit b1778c7

Browse files
[AsmPrinter] Remove mbb-profile-dump flag (#76595)
Now that the work embedding PGO information in SHT_LLVM_BB_ADDR_MAP ELF sections has landed, there is no longer a need to keep around the mbb-profile-dump flag.
1 parent 766e645 commit b1778c7

File tree

3 files changed

+0
-114
lines changed

3 files changed

+0
-114
lines changed

llvm/include/llvm/CodeGen/AsmPrinter.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,6 @@ class AsmPrinter : public MachineFunctionPass {
236236
/// split stack prologue.
237237
bool HasNoSplitStack = false;
238238

239-
/// Raw FDOstream for outputting machine basic block frequncies if the
240-
/// --mbb-profile-dump flag is set for downstream cost modelling applications
241-
std::unique_ptr<raw_fd_ostream> MBBProfileDumpFileOutput;
242-
243239
protected:
244240
explicit AsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer);
245241

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,6 @@ using namespace llvm;
134134

135135
#define DEBUG_TYPE "asm-printer"
136136

137-
static cl::opt<std::string> BasicBlockProfileDump(
138-
"mbb-profile-dump", cl::Hidden,
139-
cl::desc("Basic block profile dump for external cost modelling. If "
140-
"matching up BBs with afterwards, the compilation must be "
141-
"performed with -basic-block-sections=labels. Enabling this "
142-
"flag during in-process ThinLTO is not supported."));
143-
144137
// This is a replication of fields of object::PGOAnalysisMap::Features. It
145138
// should match the order of the fields so that
146139
// `object::PGOAnalysisMap::Features::decode(PgoAnalysisMapFeatures.getBits())`
@@ -646,16 +639,6 @@ bool AsmPrinter::doInitialization(Module &M) {
646639
HI.Handler->beginModule(&M);
647640
}
648641

649-
if (!BasicBlockProfileDump.empty()) {
650-
std::error_code PossibleFileError;
651-
MBBProfileDumpFileOutput = std::make_unique<raw_fd_ostream>(
652-
BasicBlockProfileDump, PossibleFileError);
653-
if (PossibleFileError) {
654-
M.getContext().emitError("Failed to open file for MBB Profile Dump: " +
655-
PossibleFileError.message() + "\n");
656-
}
657-
}
658-
659642
return false;
660643
}
661644

@@ -2026,40 +2009,6 @@ void AsmPrinter::emitFunctionBody() {
20262009
OutStreamer->getCommentOS() << "-- End function\n";
20272010

20282011
OutStreamer->addBlankLine();
2029-
2030-
// Output MBB ids, function names, and frequencies if the flag to dump
2031-
// MBB profile information has been set
2032-
if (MBBProfileDumpFileOutput && !MF->empty() &&
2033-
MF->getFunction().getEntryCount()) {
2034-
if (!MF->hasBBLabels()) {
2035-
MF->getContext().reportError(
2036-
SMLoc(),
2037-
"Unable to find BB labels for MBB profile dump. -mbb-profile-dump "
2038-
"must be called with -basic-block-sections=labels");
2039-
} else {
2040-
MachineBlockFrequencyInfo &MBFI =
2041-
getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI();
2042-
// The entry count and the entry basic block frequency aren't the same. We
2043-
// want to capture "absolute" frequencies, i.e. the frequency with which a
2044-
// MBB is executed when the program is executed. From there, we can derive
2045-
// Function-relative frequencies (divide by the value for the first MBB).
2046-
// We also have the information about frequency with which functions
2047-
// were called. This helps, for example, in a type of integration tests
2048-
// where we want to cross-validate the compiler's profile with a real
2049-
// profile.
2050-
// Using double precision because uint64 values used to encode mbb
2051-
// "frequencies" may be quite large.
2052-
const double EntryCount =
2053-
static_cast<double>(MF->getFunction().getEntryCount()->getCount());
2054-
for (const auto &MBB : *MF) {
2055-
const double MBBRelFreq = MBFI.getBlockFreqRelativeToEntryBlock(&MBB);
2056-
const double AbsMBBFreq = MBBRelFreq * EntryCount;
2057-
*MBBProfileDumpFileOutput.get()
2058-
<< MF->getName() << "," << MBB.getBBID()->BaseID << ","
2059-
<< AbsMBBFreq << "\n";
2060-
}
2061-
}
2062-
}
20632012
}
20642013

20652014
/// Compute the number of Global Variables that uses a Constant.

llvm/test/CodeGen/Generic/bb-profile-dump.ll

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)