Skip to content

Commit 79658d6

Browse files
authored
InferAddressSpaces: Make getPredicatedAddrSpace less confusing (#104052)
This takes a pointer value and the user instruction. Name them as such, and remove the null check which should be dead.
1 parent 43ffe2e commit 79658d6

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ class InferAddressSpacesImpl {
240240
SmallVectorImpl<const Use *> *PoisonUsesToFix) const;
241241
unsigned joinAddressSpaces(unsigned AS1, unsigned AS2) const;
242242

243-
unsigned getPredicatedAddrSpace(const Value &V, Value *Opnd) const;
243+
unsigned getPredicatedAddrSpace(const Value &PtrV,
244+
const Instruction *UserCtxI) const;
244245

245246
public:
246247
InferAddressSpacesImpl(AssumptionCache &AC, const DominatorTree *DT,
@@ -909,18 +910,14 @@ void InferAddressSpacesImpl::inferAddressSpaces(
909910
}
910911
}
911912

912-
unsigned InferAddressSpacesImpl::getPredicatedAddrSpace(const Value &V,
913-
Value *Opnd) const {
914-
const Instruction *I = dyn_cast<Instruction>(&V);
915-
if (!I)
916-
return UninitializedAddressSpace;
917-
918-
Opnd = Opnd->stripInBoundsOffsets();
919-
for (auto &AssumeVH : AC.assumptionsFor(Opnd)) {
913+
unsigned InferAddressSpacesImpl::getPredicatedAddrSpace(
914+
const Value &Ptr, const Instruction *UserCtxI) const {
915+
const Value *StrippedPtr = Ptr.stripInBoundsOffsets();
916+
for (auto &AssumeVH : AC.assumptionsFor(StrippedPtr)) {
920917
if (!AssumeVH)
921918
continue;
922919
CallInst *CI = cast<CallInst>(AssumeVH);
923-
if (!isValidAssumeForContext(CI, I, DT))
920+
if (!isValidAssumeForContext(CI, UserCtxI, DT))
924921
continue;
925922

926923
const Value *Ptr;
@@ -989,7 +986,8 @@ bool InferAddressSpacesImpl::updateAddressSpace(
989986
OperandAS = PtrOperand->getType()->getPointerAddressSpace();
990987
if (OperandAS == FlatAddrSpace) {
991988
// Check AC for assumption dominating V.
992-
unsigned AS = getPredicatedAddrSpace(V, PtrOperand);
989+
unsigned AS =
990+
getPredicatedAddrSpace(*PtrOperand, &cast<Instruction>(V));
993991
if (AS != UninitializedAddressSpace) {
994992
LLVM_DEBUG(dbgs()
995993
<< " deduce operand AS from the predicate addrspace "

0 commit comments

Comments
 (0)