[llvm] [polly] Slightly improve the getenv("bar") linking problem (PR #150020)
Luke Drummond via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 22 08:21:16 PDT 2025
================
@@ -48,20 +48,26 @@
#include <cstdlib>
namespace llvm {
+inline bool getNonFoldableAlwaysTrue() {
+ // Some parts of the codebase require a "constant true value" used as a
+ // predicate. These cases require that even with LTO and static linking,
+ // it's not possible to for the compiler to fold the value. As compilers
+ // aren't smart enough to know that getenv() never returns -1, this will do
+ // the job.
+ return std::getenv("LLVM_IGNORED_ENV_VAR") != (char *)-1;
+}
class Triple;
}
namespace {
struct ForcePassLinking {
ForcePassLinking() {
- // We must reference the passes 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)
+ // We must reference the passes 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. // This is so that globals in the translation units
----------------
ldrumm wrote:
Done
https://github.com/llvm/llvm-project/pull/150020
More information about the llvm-commits
mailing list