[llvm] [Attributor] Do not optimize away externally_initialized loads. (PR #128170)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 24 02:10:39 PST 2025


================
@@ -259,11 +259,16 @@ AA::getInitialValueForObj(Attributor &A, const AbstractAttribute &QueryingAA,
     if (!Initializer)
       return nullptr;
   } else {
-    if (!GV->hasLocalLinkage() &&
-        (GV->isInterposable() || !(GV->isConstant() && GV->hasInitializer())))
-      return nullptr;
-    if (!GV->hasInitializer())
-      return UndefValue::get(&Ty);
+    if (GV->hasLocalLinkage()) {
+      // Uninitialized global with local linkage.
+      if (!GV->hasInitializer())
----------------
nikic wrote:

Can that happen? I thought non-external linkage always requires an initializer.

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


More information about the llvm-commits mailing list