Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InferAddressSpaces: Make getPredicatedAddrSpace less confusing #104052

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ class InferAddressSpacesImpl {
SmallVectorImpl<const Use *> *PoisonUsesToFix) const;
unsigned joinAddressSpaces(unsigned AS1, unsigned AS2) const;

unsigned getPredicatedAddrSpace(const Value &V, Value *Opnd) const;
unsigned getPredicatedAddrSpace(const Value &PtrV,
const Instruction *UserCtxI) const;

public:
InferAddressSpacesImpl(AssumptionCache &AC, const DominatorTree *DT,
Expand Down Expand Up @@ -909,18 +910,14 @@ void InferAddressSpacesImpl::inferAddressSpaces(
}
}

unsigned InferAddressSpacesImpl::getPredicatedAddrSpace(const Value &V,
Value *Opnd) const {
const Instruction *I = dyn_cast<Instruction>(&V);
if (!I)
return UninitializedAddressSpace;

Opnd = Opnd->stripInBoundsOffsets();
for (auto &AssumeVH : AC.assumptionsFor(Opnd)) {
unsigned InferAddressSpacesImpl::getPredicatedAddrSpace(
const Value &Ptr, const Instruction *UserCtxI) const {
const Value *StrippedPtr = Ptr.stripInBoundsOffsets();
for (auto &AssumeVH : AC.assumptionsFor(StrippedPtr)) {
if (!AssumeVH)
continue;
CallInst *CI = cast<CallInst>(AssumeVH);
if (!isValidAssumeForContext(CI, I, DT))
if (!isValidAssumeForContext(CI, UserCtxI, DT))
continue;

const Value *Ptr;
Expand Down Expand Up @@ -989,7 +986,8 @@ bool InferAddressSpacesImpl::updateAddressSpace(
OperandAS = PtrOperand->getType()->getPointerAddressSpace();
if (OperandAS == FlatAddrSpace) {
// Check AC for assumption dominating V.
unsigned AS = getPredicatedAddrSpace(V, PtrOperand);
unsigned AS =
getPredicatedAddrSpace(*PtrOperand, &cast<Instruction>(V));
Artem-B marked this conversation as resolved.
Show resolved Hide resolved
if (AS != UninitializedAddressSpace) {
LLVM_DEBUG(dbgs()
<< " deduce operand AS from the predicate addrspace "
Expand Down
Loading