[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
Mon Mar 21 18:12:22 PDT 2022


tingwang created this revision.
tingwang added reviewers: PowerPC, jsji, nemanjai, shchenz, hubert.reinterpretcast.
tingwang added a project: LLVM.
Herald added subscribers: kbarton, hiraditya.
Herald added a project: All.
tingwang requested review of this revision.
Herald added a subscriber: llvm-commits.

On AIX `-bcdtors:csect` linker option requires ".ref" pseudo-op to indicate the connection among static variables (static global variable, static class member etc.) and static init/term functions, so that linker can generate the correct output.

Here in IR we borrow ‘associated’ metadata to indicate the relationship for ".ref". There are three types of association need be addressed:
(1) static variable to sinit/sterm functions (required to add functions to _cdtors array if the variable is included in linker output)
(2) sinit/sterm function to sinit/sterm function (required to correctly handle atexit/unatexit registration/unregistration)
(3) normal function to static variable  (required to get the variable in linker output)

This is the first half change to support `-bcdtors:csect` linker option, and there will be change in clang afterwards.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122198

Files:
  llvm/include/llvm/MC/MCStreamer.h
  llvm/include/llvm/MC/MCXCOFFStreamer.h
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/lib/MC/MCSectionXCOFF.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/test/CodeGen/PowerPC/aix-xcoff-ref.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122198.417140.patch
Type: text/x-patch
Size: 8400 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220322/44d8634c/attachment-0001.bin>


More information about the llvm-commits mailing list