[GlobalOpt] Avoid early exit before dead constant check
authorNikita Popov <npopov@redhat.com>
Tue, 1 Feb 2022 14:56:42 +0000 (15:56 +0100)
committerNikita Popov <npopov@redhat.com>
Tue, 1 Feb 2022 14:57:19 +0000 (15:57 +0100)
In a similar vein to 236fbf571dc6cebcb81ac5187a170c8de6d5bc0e,
make sure we don't early-exit before the dead constant check.

llvm/lib/Transforms/IPO/GlobalOpt.cpp

index d3cac3e..a29d4f6 100644 (file)
@@ -352,14 +352,10 @@ static bool collectSRATypes(DenseMap<uint64_t, Type *> &Types, GlobalValue *GV,
   while (!Worklist.empty()) {
     Use *U = Worklist.pop_back_val();
     User *V = U->getUser();
-    if (isa<BitCastOperator>(V) || isa<AddrSpaceCastOperator>(V)) {
-      AppendUses(V);
-      continue;
-    }
 
-    if (auto *GEP = dyn_cast<GEPOperator>(V)) {
-      if (!GEP->hasAllConstantIndices())
-        return false;
+    auto *GEP = dyn_cast<GEPOperator>(V);
+    if (isa<BitCastOperator>(V) || isa<AddrSpaceCastOperator>(V) ||
+        (GEP && GEP->hasAllConstantIndices())) {
       AppendUses(V);
       continue;
     }