[PATCH] D131910: [Windows] Put init_seg(compiler/lib) in llvm.global_ctors

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 15 11:19:00 PDT 2022


aeubanks created this revision.
aeubanks added reviewers: rnk, hans.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Currently we treat initializers with init_seg(compiler/lib) as similar
to any other init_seg, they simply have a global variable in the proper
section (".CRT$XCC" for compiler/".CRT$XCL" for lib) and are added to
llvm.used. However, this doesn't match with how LLVM sees normal (or
init_seg(user)) initializers via llvm.global_ctors. This
causes issues like incorrect init_seg(compiler) vs init_seg(user)
ordering due to GlobalOpt evaluating constructors, and the
ability to remove init_seg(compiler/lib) initializers at all.

To preserve the existing uses of 'A' for priorities less than 200 and
otherwise 'T' as much as possible, use priority 200 for
init_seg(compiler) and 201 for init_seg(lib), which use 'C' and 'L'.

Fixes #56922


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131910

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/test/CodeGenCXX/pragma-init_seg.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/test/CodeGen/X86/ctor-priority-coff.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131910.452749.patch
Type: text/x-patch
Size: 8108 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220815/be57e387/attachment.bin>


More information about the llvm-commits mailing list