[compiler-rt] [llvm] [AIX] PGO codegen changes for function-sections. (PR #139761)
Sean Fertile via llvm-commits
llvm-commits at lists.llvm.org
Wed May 14 10:36:47 PDT 2025
================
@@ -2810,6 +2826,57 @@ void PPCAIXAsmPrinter::emitGlobalVariableHelper(const GlobalVariable *GV) {
MCSectionXCOFF *Csect = cast<MCSectionXCOFF>(
getObjFileLowering().SectionForGlobal(GV, GVKind, TM));
+ // When compiling with function sections enabled, we need some special
+ // codegen to rename the CSECTs. For each profiling data symbol find its
+ // associated profiling counters.
+ if (TM.getFunctionSections() &&
+ Csect->getName().starts_with("__llvm_prf_data.")) {
+ // Unraveling the initializer to find the related counters variable. The
+ // initializer is a structure whose third member is a subtract expression
+ // between the counters label and the label for the start of this structure.
+ // Use the subtract expression to get the GlobalValue for the counters
+ // global.
+ assert(GV->hasInitializer() &&
----------------
mandlebug wrote:
I really dislike this part because we are so tightly coupled to the implementation that if anyone changed the initializer format they would have to simultaneously modify the PPC target which is a problem. For ELF the section keys on the Comdats carry the relationship info in the IR implicitly.
What do you think of an alternative approach where we could use a metadata node to explicitly attach to dependancy info to the data symbol? https://llvm.org/docs/LangRef.html#associated-metadata is a similar idea for ELF.
https://github.com/llvm/llvm-project/pull/139761
More information about the llvm-commits
mailing list