[GlobalOpt] Avoid early exit before dead constant check

In a similar vein to 236fbf571d,
make sure we don't early-exit before the dead constant check.
This commit is contained in:
Nikita Popov 2022-02-01 15:56:42 +01:00
parent f52927c122
commit 1652c3b80c
1 changed files with 3 additions and 7 deletions

View 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;
}