[llvm] [polly] Slightly improve the getenv("bar") linking problem (PR #150020)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 22 08:08:21 PDT 2025


================
@@ -22,12 +22,10 @@ namespace {
     ForceAsmWriterLinking() {
       // We must reference the plug-ins in such a way that compilers will not
       // 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)
+      // yet is effectively a NO-OP. This is so that globals in the translation
+      // units where these functions are defined are forced to be initialized,
+      // populating various registries.
+      if (llvm::getNonFoldableAlwaysTrue())
----------------
nikic wrote:

I think that would be ok.

https://github.com/llvm/llvm-project/pull/150020


More information about the llvm-commits mailing list