forked from OSchip/llvm-project
constify getUnderlyingObject implementation [nfc]
This commit is contained in:
parent
ebe6161c54
commit
d9a29a6752
|
@ -370,10 +370,11 @@ constexpr unsigned MaxAnalysisRecursionDepth = 6;
|
|||
/// that the returned value has pointer type if the specified value does. If
|
||||
/// the MaxLookup value is non-zero, it limits the number of instructions to
|
||||
/// be stripped off.
|
||||
Value *getUnderlyingObject(Value *V, unsigned MaxLookup = 6);
|
||||
inline const Value *getUnderlyingObject(const Value *V,
|
||||
unsigned MaxLookup = 6) {
|
||||
return getUnderlyingObject(const_cast<Value *>(V), MaxLookup);
|
||||
const Value *getUnderlyingObject(const Value *V, unsigned MaxLookup = 6);
|
||||
inline Value *getUnderlyingObject(Value *V, unsigned MaxLookup = 6) {
|
||||
// Force const to avoid infinite recursion.
|
||||
const Value *VConst = V;
|
||||
return const_cast<Value *>(getUnderlyingObject(VConst, MaxLookup));
|
||||
}
|
||||
|
||||
/// This method is similar to getUnderlyingObject except that it can
|
||||
|
|
|
@ -4162,18 +4162,18 @@ static bool isSameUnderlyingObjectInLoop(const PHINode *PN,
|
|||
return true;
|
||||
}
|
||||
|
||||
Value *llvm::getUnderlyingObject(Value *V, unsigned MaxLookup) {
|
||||
const Value *llvm::getUnderlyingObject(const Value *V, unsigned MaxLookup) {
|
||||
if (!V->getType()->isPointerTy())
|
||||
return V;
|
||||
for (unsigned Count = 0; MaxLookup == 0 || Count < MaxLookup; ++Count) {
|
||||
if (GEPOperator *GEP = dyn_cast<GEPOperator>(V)) {
|
||||
if (auto *GEP = dyn_cast<GEPOperator>(V)) {
|
||||
V = GEP->getPointerOperand();
|
||||
} else if (Operator::getOpcode(V) == Instruction::BitCast ||
|
||||
Operator::getOpcode(V) == Instruction::AddrSpaceCast) {
|
||||
V = cast<Operator>(V)->getOperand(0);
|
||||
if (!V->getType()->isPointerTy())
|
||||
return V;
|
||||
} else if (GlobalAlias *GA = dyn_cast<GlobalAlias>(V)) {
|
||||
} else if (auto *GA = dyn_cast<GlobalAlias>(V)) {
|
||||
if (GA->isInterposable())
|
||||
return V;
|
||||
V = GA->getAliasee();
|
||||
|
|
Loading…
Reference in New Issue