File tree 1 file changed +13
-8
lines changed 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -6615,19 +6615,18 @@ const Value *llvm::getUnderlyingObjectAggressive(const Value *V) {
6615
6615
SmallPtrSet<const Value *, 8 > Visited;
6616
6616
SmallVector<const Value *, 8 > Worklist;
6617
6617
Worklist.push_back (V);
6618
- const Value *Object = nullptr , *FirstObject = nullptr ;
6618
+ const Value *Object = nullptr ;
6619
6619
do {
6620
6620
const Value *P = Worklist.pop_back_val ();
6621
6621
P = getUnderlyingObject (P);
6622
6622
6623
- if (!FirstObject)
6624
- FirstObject = P;
6625
-
6626
6623
if (!Visited.insert (P).second )
6627
6624
continue ;
6628
6625
6629
- if (Visited.size () == MaxVisited)
6630
- return FirstObject;
6626
+ if (Visited.size () == MaxVisited) {
6627
+ Object = nullptr ;
6628
+ break ;
6629
+ }
6631
6630
6632
6631
if (auto *SI = dyn_cast<SelectInst>(P)) {
6633
6632
Worklist.push_back (SI->getTrueValue ());
@@ -6642,10 +6641,16 @@ const Value *llvm::getUnderlyingObjectAggressive(const Value *V) {
6642
6641
6643
6642
if (!Object)
6644
6643
Object = P;
6645
- else if (Object != P)
6646
- return FirstObject;
6644
+ else if (Object != P) {
6645
+ Object = nullptr ;
6646
+ break ;
6647
+ }
6647
6648
} while (!Worklist.empty ());
6648
6649
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);
6649
6654
return Object;
6650
6655
}
6651
6656
You can’t perform that action at this time.
0 commit comments