[compiler-rt] [llvm] [AIX] PGO codegen changes for function-sections. (PR #139761)

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Wed May 14 10:58:46 PDT 2025


================
@@ -2960,6 +3027,54 @@ void PPCAIXAsmPrinter::emitPGORefs(Module &M) {
   }
 }
 
+void PPCAIXAsmPrinter::emitSplitSectionPGORefs() {
+  MCSymbol *NamesSym = nullptr;
+  MCSymbol *VNDSSym = nullptr;
+
+  if (OutContext.hasXCOFFSection(
+          "__llvm_prf_names",
+          XCOFF::CsectProperties(XCOFF::XMC_RO, XCOFF::XTY_SD)))
+    NamesSym = OutContext.getOrCreateSymbol("__llvm_prf_names[RO]");
+
+  if (OutContext.hasXCOFFSection(
+          "__llvm_prf_vnds",
+          XCOFF::CsectProperties(XCOFF::XMC_RW, XCOFF::XTY_SD)))
+    VNDSSym = OutContext.getOrCreateSymbol("__llvm_prf_vnds[RW]");
+
+  for (auto SubSections : ProfGenSubSections) {
+    MCSectionXCOFF *ProfDCsect = SubSections.ProfD;
+    MCSectionXCOFF *ProfCCsect = SubSections.ProfC;
+
+    OutStreamer->switchSection(ProfCCsect);
+
+    if (NamesSym)
+      OutStreamer->emitXCOFFRefDirective(NamesSym);
+
+    if (VNDSSym)
+      OutStreamer->emitXCOFFRefDirective(VNDSSym);
+
+    OutStreamer->emitXCOFFRefDirective(ProfDCsect->getQualNameSymbol());
+
+    // Rename the subsection for the counters
+    OutStreamer->emitXCOFFRenameDirective(ProfCCsect->getQualNameSymbol(),
+                                          "__llvm_prf_cnts");
----------------
petrhosek wrote:

Can we use `getInstrProfSectionName` consistently everywhere rather than hardcoding the names as strings here? That gives us flexibility in case we need to change the name in the future.

https://github.com/llvm/llvm-project/pull/139761


More information about the llvm-commits mailing list