[PATCH] D113074: [NFC] Clarify why LinkAll*.h are actually necessary
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 2 17:29:33 PDT 2021
aeubanks created this revision.
aeubanks added reviewers: MaskRay, hans.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113074
Files:
llvm/include/llvm/CodeGen/LinkAllAsmWriterComponents.h
llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h
llvm/include/llvm/ExecutionEngine/MCJIT.h
llvm/include/llvm/LinkAllIR.h
llvm/include/llvm/LinkAllPasses.h
Index: llvm/include/llvm/LinkAllPasses.h
===================================================================
--- llvm/include/llvm/LinkAllPasses.h
+++ llvm/include/llvm/LinkAllPasses.h
@@ -64,6 +64,9 @@
// delete it all as dead code, even with whole program optimization,
// yet is effectively a NO-OP. As the compiler isn't smart enough
// to know that getenv() never returns -1, this will do the job.
+ // This is so that globals in the translation units where these functions
+ // are defined are forced to be initialized, populating various
+ // registries.
if (std::getenv("bar") != (char*) -1)
return;
Index: llvm/include/llvm/LinkAllIR.h
===================================================================
--- llvm/include/llvm/LinkAllIR.h
+++ llvm/include/llvm/LinkAllIR.h
@@ -38,6 +38,9 @@
// delete it all as dead code, even with whole program optimization,
// yet is effectively a NO-OP. As the compiler isn't smart enough
// to know that getenv() never returns -1, this will do the job.
+ // This is so that globals in the translation units where these functions
+ // are defined are forced to be initialized, populating various
+ // registries.
if (std::getenv("bar") != (char*) -1)
return;
llvm::LLVMContext Context;
Index: llvm/include/llvm/ExecutionEngine/MCJIT.h
===================================================================
--- llvm/include/llvm/ExecutionEngine/MCJIT.h
+++ llvm/include/llvm/ExecutionEngine/MCJIT.h
@@ -26,6 +26,9 @@
// delete it all as dead code, even with whole program optimization,
// yet is effectively a NO-OP. As the compiler isn't smart enough
// to know that getenv() never returns -1, this will do the job.
+ // This is so that globals in the translation units where these functions
+ // are defined are forced to be initialized, populating various
+ // registries.
if (std::getenv("bar") != (char*) -1)
return;
Index: llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h
===================================================================
--- llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h
+++ llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h
@@ -27,6 +27,9 @@
// delete it all as dead code, even with whole program optimization,
// yet is effectively a NO-OP. As the compiler isn't smart enough
// to know that getenv() never returns -1, this will do the job.
+ // This is so that globals in the translation units where these functions
+ // are defined are forced to be initialized, populating various
+ // registries.
if (std::getenv("bar") != (char*) -1)
return;
Index: llvm/include/llvm/CodeGen/LinkAllAsmWriterComponents.h
===================================================================
--- llvm/include/llvm/CodeGen/LinkAllAsmWriterComponents.h
+++ llvm/include/llvm/CodeGen/LinkAllAsmWriterComponents.h
@@ -24,6 +24,9 @@
// delete it all as dead code, even with whole program optimization,
// yet is effectively a NO-OP. As the compiler isn't smart enough
// to know that getenv() never returns -1, this will do the job.
+ // This is so that globals in the translation units where these functions
+ // are defined are forced to be initialized, populating various
+ // registries.
if (std::getenv("bar") != (char*) -1)
return;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113074.384286.patch
Type: text/x-patch
Size: 3474 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211103/426f900f/attachment.bin>
More information about the llvm-commits
mailing list