[PATCH] D122198: [PowerPC] Add .ref in backend for AIX XCOFF to support `-bcdtors:csect` linker option

Ting Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 8 08:09:33 PDT 2022


tingwang marked an inline comment as done.
tingwang added inline comments.


================
Comment at: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:2381
 
   SectionKind GVKind = getObjFileLowering().getKindForGlobal(GV, TM);
   if (!GVKind.isGlobalWriteableData() && !GVKind.isReadOnly() &&
----------------
shchenz wrote:
> tingwang wrote:
> > shchenz wrote:
> > > can we change the `GVkind` here for static globals with associated metadata? We use BSS kind for normal static globals, maybe we can change it to RW, so that we may don't need to change `MCSectionXCOFF::printSwitchToSection` and `TargetLoweringObjectFileXCOFF::SelectSectionForGlobal`?
> > My initial thought was the same. After looking into TargetLoweringObjectFile::getKindForGlobal(), I didn't find any point for platform specific logic to change the decision, and thus I turned into our platform dependent code to make changes here. (If there is already one hook, I will be happy to use that. However at this moment, I don't see any for this purpose.)
> Is it possible to custom the GVKind in current function? This function is AIX specific?
If I'm understanding correct, this is customize in the middle (my original approach is customize in the end). The trace log shows that getKindForGlobal gets called from different places, for example: GlobalMerge.cpp:::GlobalMerge::doInitialization,
PPCAsmPrinter.cpp:::PPCAIXAsmPrinter::doInitialization, TargetLoweringObjectFile.cpp:::TargetLoweringObjectFile::SectionForGlobal, TargetLoweringObjectFileImpl.cpp:::TargetLoweringObjectFileXCOFF::getTargetSymbol. Customizing in the middle means we have to cover all above code path for correct behavior, and we also have to take care of any more upcoming code changes regarding this API usage. Probably the original approach is simpler.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122198/new/

https://reviews.llvm.org/D122198



More information about the llvm-commits mailing list