Skip to content

Commit 8e5f7b8

Browse files
committed
Revert "Refactor FirstObject logic"
This reverts commit f160e9c.
1 parent f160e9c commit 8e5f7b8

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6615,18 +6615,19 @@ const Value *llvm::getUnderlyingObjectAggressive(const Value *V) {
66156615
SmallPtrSet<const Value *, 8> Visited;
66166616
SmallVector<const Value *, 8> Worklist;
66176617
Worklist.push_back(V);
6618-
const Value *Object = nullptr;
6618+
const Value *Object = nullptr, *FirstObject = nullptr;
66196619
do {
66206620
const Value *P = Worklist.pop_back_val();
66216621
P = getUnderlyingObject(P);
66226622

6623+
if (!FirstObject)
6624+
FirstObject = P;
6625+
66236626
if (!Visited.insert(P).second)
66246627
continue;
66256628

6626-
if (Visited.size() == MaxVisited) {
6627-
Object = nullptr;
6628-
break;
6629-
}
6629+
if (Visited.size() == MaxVisited)
6630+
return FirstObject;
66306631

66316632
if (auto *SI = dyn_cast<SelectInst>(P)) {
66326633
Worklist.push_back(SI->getTrueValue());
@@ -6641,16 +6642,10 @@ const Value *llvm::getUnderlyingObjectAggressive(const Value *V) {
66416642

66426643
if (!Object)
66436644
Object = P;
6644-
else if (Object != P) {
6645-
Object = nullptr;
6646-
break;
6647-
}
6645+
else if (Object != P)
6646+
return FirstObject;
66486647
} while (!Worklist.empty());
66496648

6650-
// If we tried looking through phi/select but did not end up with a single
6651-
// underlying object, fall back to the non-recursive underlying object of V.
6652-
if (!Object)
6653-
return getUnderlyingObject(V);
66546649
return Object;
66556650
}
66566651

0 commit comments

Comments
 (0)