[clang] [llvm] [lld] [SHT_LLVM_BB_ADDR_MAP] Allow basic-block-sections and labels be used together by decoupling the handling of the two features. (PR #74128)
Aiden Grossman via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 26 01:06:27 PST 2024
================
@@ -172,6 +172,105 @@ class OtoolOptTable : public CommonOptTable {
"Mach-O object file displaying tool") {}
};
+struct BBAddrMapLabel {
+ std::string BlockLabel;
+ std::string PGOAnalysis;
+};
+
+// This class represents the BBAddrMap and PGOMap associated with a single
+// function.
+class BBAddrMapFunctionEntry {
+public:
+ BBAddrMapFunctionEntry(BBAddrMap AddrMap, PGOAnalysisMap PGOMap)
+ : AddrMap(std::move(AddrMap)), PGOMap(std::move(PGOMap)) {}
+
+ const BBAddrMap &getAddrMap() const { return AddrMap; }
+
+ // Returns the PGO string associated with the entry of index `PGOBBEntryIndex`
+ // in `PGOMap`.
+ std::string constructPGOLabelString(size_t PGOBBEntryIndex) const {
+ if (!PGOMap.FeatEnable.hasPGOAnalysis())
+ return "";
+ std::string PGOString;
+ raw_string_ostream PGOSS(PGOString);
+
+ PGOSS << " (";
+ if (PGOMap.FeatEnable.FuncEntryCount && PGOBBEntryIndex == 0) {
+ PGOSS << "Entry count: " << Twine(PGOMap.FuncEntryCount);
+ if (PGOMap.FeatEnable.hasPGOAnalysisBBData()) {
+ PGOSS << ", ";
+ }
+ }
+
+ if (PGOMap.FeatEnable.hasPGOAnalysisBBData()) {
+
+ assert(PGOBBEntryIndex < PGOMap.BBEntries.size() &&
+ "Expected PGOAnalysisMap and BBAddrMap to have the same entires");
----------------
boomanaiden154 wrote:
`/s/entires/entries`
Looks like a typo carried over from my `llvm-objdump` patch adding in support for symbolizing PGO Analysis data.
https://github.com/llvm/llvm-project/pull/74128
More information about the cfe-commits
mailing list