[PATCH] D127233: [CodeGen] Sort llvm.global_ctors by lexing order before emission

Yuanfang Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 7 10:34:36 PDT 2022


ychen created this revision.
ychen added reviewers: rnk, rsmith.
Herald added a project: All.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/55804

The lexing order is already bookkept in DelayedCXXInitPosition but we
were not using it based on the wrong assumption that inline variable is
unordered. This patch fixes it by ordering entries in llvm.global_ctors
by orders in DelayedCXXInitPosition.

for llvm.global_ctors entries without a lexing order, ordering them by
the insertion order.

(This *mostly* orders the template instantiation in
https://reviews.llvm.org/D126341 intuitively, minus one tweak for which I'll
submit a separate patch.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127233

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/static-init-inline-variable.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127233.434882.patch
Type: text/x-patch
Size: 4913 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220607/a7767620/attachment-0001.bin>


More information about the cfe-commits mailing list