[PATCH] D97446: Change some addUsedGlobal to addUsedOrCompilerUsedGlobal

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 13 14:54:32 PST 2022


MaskRay marked 2 inline comments as done.
MaskRay added inline comments.


================
Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2093
+         "Only globals with definition can force usage.");
+  if (getTriple().isOSBinFormatELF())
+    LLVMCompilerUsed.emplace_back(GV);
----------------
JonChesterfield wrote:
> ^ this specifically looks wrong, which array the variable goes in should be based on what the variable is used for or what the programmer asked for, not on the binary format used by the OS (is that even a unique test? One can run elf or coff on windows iirc)
`addUsedOrCompilerUsedGlobal` is carefully used on `__attribute__((used))` and the related keep-static-consts.cpp.

`__attribute__((used))`  has a semantic split on ELF and non-ELF, so the difference is unavoidable. For other constructs we try to use the precise LLVMCompilerUsed or LLVMUsed.


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