diff options
author | Aiden Grossman <agrossman154@yahoo.com> | 2024-01-23 16:48:10 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-23 16:48:10 -0800 |
commit | b1778c7d7b9ec07c075118546b85a7cc9741e1f1 (patch) | |
tree | a95ec1cc35dcab9e3ca2cd93e4d18c1fcda357b4 | |
parent | 766e645d8d1e9e999386b90e3e19554d72324a66 (diff) |
[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.
-rw-r--r-- | llvm/include/llvm/CodeGen/AsmPrinter.h | 4 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 51 | ||||
-rw-r--r-- | llvm/test/CodeGen/Generic/bb-profile-dump.ll | 59 |
3 files changed, 0 insertions, 114 deletions
diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 5ec246ee7015..fbd198a75a24 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -236,10 +236,6 @@ private: /// split stack prologue. bool HasNoSplitStack = false; - /// Raw FDOstream for outputting machine basic block frequncies if the - /// --mbb-profile-dump flag is set for downstream cost modelling applications - std::unique_ptr<raw_fd_ostream> MBBProfileDumpFileOutput; - protected: explicit AsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer); diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 29da2b1c29f8..0d573562de96 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -134,13 +134,6 @@ using namespace llvm; #define DEBUG_TYPE "asm-printer" -static cl::opt<std::string> BasicBlockProfileDump( - "mbb-profile-dump", cl::Hidden, - cl::desc("Basic block profile dump for external cost modelling. If " - "matching up BBs with afterwards, the compilation must be " - "performed with -basic-block-sections=labels. Enabling this " - "flag during in-process ThinLTO is not supported.")); - // This is a replication of fields of object::PGOAnalysisMap::Features. It // should match the order of the fields so that // `object::PGOAnalysisMap::Features::decode(PgoAnalysisMapFeatures.getBits())` @@ -646,16 +639,6 @@ bool AsmPrinter::doInitialization(Module &M) { HI.Handler->beginModule(&M); } - if (!BasicBlockProfileDump.empty()) { - std::error_code PossibleFileError; - MBBProfileDumpFileOutput = std::make_unique<raw_fd_ostream>( - BasicBlockProfileDump, PossibleFileError); - if (PossibleFileError) { - M.getContext().emitError("Failed to open file for MBB Profile Dump: " + - PossibleFileError.message() + "\n"); - } - } - return false; } @@ -2026,40 +2009,6 @@ void AsmPrinter::emitFunctionBody() { OutStreamer->getCommentOS() << "-- End function\n"; OutStreamer->addBlankLine(); - - // Output MBB ids, function names, and frequencies if the flag to dump - // MBB profile information has been set - if (MBBProfileDumpFileOutput && !MF->empty() && - MF->getFunction().getEntryCount()) { - if (!MF->hasBBLabels()) { - MF->getContext().reportError( - SMLoc(), - "Unable to find BB labels for MBB profile dump. -mbb-profile-dump " - "must be called with -basic-block-sections=labels"); - } else { - MachineBlockFrequencyInfo &MBFI = - getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI(); - // The entry count and the entry basic block frequency aren't the same. We - // want to capture "absolute" frequencies, i.e. the frequency with which a - // MBB is executed when the program is executed. From there, we can derive - // Function-relative frequencies (divide by the value for the first MBB). - // We also have the information about frequency with which functions - // were called. This helps, for example, in a type of integration tests - // where we want to cross-validate the compiler's profile with a real - // profile. - // Using double precision because uint64 values used to encode mbb - // "frequencies" may be quite large. - const double EntryCount = - static_cast<double>(MF->getFunction().getEntryCount()->getCount()); - for (const auto &MBB : *MF) { - const double MBBRelFreq = MBFI.getBlockFreqRelativeToEntryBlock(&MBB); - const double AbsMBBFreq = MBBRelFreq * EntryCount; - *MBBProfileDumpFileOutput.get() - << MF->getName() << "," << MBB.getBBID()->BaseID << "," - << AbsMBBFreq << "\n"; - } - } - } } /// Compute the number of Global Variables that uses a Constant. diff --git a/llvm/test/CodeGen/Generic/bb-profile-dump.ll b/llvm/test/CodeGen/Generic/bb-profile-dump.ll deleted file mode 100644 index 7391a6ee6f91..000000000000 --- a/llvm/test/CodeGen/Generic/bb-profile-dump.ll +++ /dev/null @@ -1,59 +0,0 @@ -; REQUIRES: x86-registered-target -; -; Check that the basic block profile dump outputs data and in the correct -; format. -; -; RUN: llc -mtriple=x86_64-linux-unknown -o /dev/null -basic-block-sections=labels -mbb-profile-dump=- %s | FileCheck %s - -; Check that given a simple case, we can return the default MBFI - -define i64 @f2(i64 %a, i64 %b) !prof !1{ - %sum = add i64 %a, %b - ret i64 %sum -} - -; CHECK: f2,0,1.000000e+03 - -define i64 @f1() !prof !2{ - %sum = call i64 @f2(i64 2, i64 2) - %isEqual = icmp eq i64 %sum, 4 - br i1 %isEqual, label %ifEqual, label %ifNotEqual, !prof !3 -ifEqual: - ret i64 0 -ifNotEqual: - ret i64 %sum -} - -; CHECK-NEXT: f1,0,1.000000e+01 -; CHECK-NEXT: f1,2,6.000000e+00 -; CHECK-NEXT: f1,1,4.000000e+00 - -define void @f3(i32 %iter) !prof !4 { -entry: - br label %loop -loop: - %i = phi i32 [0, %entry], [%i_next, %loop] - %i_next = add i32 %i, 1 - %exit_cond = icmp slt i32 %i_next, %iter - br i1 %exit_cond, label %loop, label %exit, !prof !5 -exit: - ret void -} - -; CHECK-NEXT: f3,0,2.000000e+00 -; CHECK-NEXT: f3,1,2.002000e+03 -; CHECK-NEXT: f3,2,2.000000e+00 - -!1 = !{!"function_entry_count", i64 1000} -!2 = !{!"function_entry_count", i64 10} -!3 = !{!"branch_weights", i32 2, i32 3} -!4 = !{!"function_entry_count", i64 2} -!5 = !{!"branch_weights", i32 1000, i32 1} - -; Check that if we pass -mbb-profile-dump but don't set -basic-block-sections, -; we get an appropriate error message - -; RUN: not llc -mtriple=x86_64-linux-unknown -o /dev/null -mbb-profile-dump=- %s 2>&1 | FileCheck --check-prefix=NO-SECTIONS %s - -; NO-SECTIONS: <unknown>:0: error: Unable to find BB labels for MBB profile dump. -mbb-profile-dump must be called with -basic-block-sections=labels - |