mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Change Value::getUnderlyingObject to have the MaxLookup value specified as a
parameter with a default value, instead of just hardcoding it in the implementation. The limit of MaxLookup = 6 was introduced in r69151 to fix a performance problem with O(n^2) behavior in instcombine, but the scalarrepl pass is relying on getUnderlyingObject to go all the way back to an AllocaInst. Making the limit part of the method signature makes it clear that by default the result is limited and should help avoid similar problems in the future. This fixes pr6126. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94433 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -341,12 +341,11 @@ Value *Value::stripPointerCasts() {
|
||||
} while (1);
|
||||
}
|
||||
|
||||
Value *Value::getUnderlyingObject() {
|
||||
Value *Value::getUnderlyingObject(unsigned MaxLookup) {
|
||||
if (!isa<PointerType>(getType()))
|
||||
return this;
|
||||
Value *V = this;
|
||||
unsigned MaxLookup = 6;
|
||||
do {
|
||||
for (unsigned Count = 0; MaxLookup == 0 || Count < MaxLookup; ++Count) {
|
||||
if (GEPOperator *GEP = dyn_cast<GEPOperator>(V)) {
|
||||
V = GEP->getPointerOperand();
|
||||
} else if (Operator::getOpcode(V) == Instruction::BitCast) {
|
||||
@@ -359,7 +358,7 @@ Value *Value::getUnderlyingObject() {
|
||||
return V;
|
||||
}
|
||||
assert(isa<PointerType>(V->getType()) && "Unexpected operand type!");
|
||||
} while (--MaxLookup);
|
||||
}
|
||||
return V;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user