[compiler-rt] [llvm] [AIX] PGO codegen changes for function-sections. (PR #139761)
Amy Kwan via llvm-commits
llvm-commits at lists.llvm.org
Wed May 14 10:22:12 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() &&
+ "profiling data symbol must have an initializer");
+ assert(isa<ConstantStruct>(GV->getInitializer()) &&
----------------
amy-kwan wrote:
I think we can probably pull out the `getInitializer()` call since it's used more than once.
https://github.com/llvm/llvm-project/pull/139761
More information about the llvm-commits
mailing list