[PATCH] D97446: Change some addUsedGlobal to addUsedOrCompilerUsedGlobal

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 25 13:55:26 PST 2021


rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm

> I see that it's currently listed as Undocumented. We should fix that while we're rehashing how this is supposed to work, and clarify what it does on each platform. As I understand it, __attribute__((used)) globals will be GC roots on Mac/Win, but not ELF targets. The mismatch in behavior is unfortunate, but it matches the dominant system compilers on those platforms.

I found the doc update in the other patch:
https://reviews.llvm.org/D97447#change-3MBnnJ2r7Yn8



================
Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2093
+         "Only globals with definition can force usage.");
+  if (this->getTarget().getTriple().isOSBinFormatELF())
+    LLVMCompilerUsed.emplace_back(GV);
----------------
nit: CGM has a getTriple() helper to shorten this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97446



More information about the cfe-commits mailing list