@@ -241,7 +241,7 @@ class InferAddressSpacesImpl {
241
241
unsigned joinAddressSpaces (unsigned AS1, unsigned AS2) const ;
242
242
243
243
unsigned getPredicatedAddrSpace (const Value &PtrV,
244
- const Instruction *UserCtxI ) const ;
244
+ const Value *UserCtx ) const ;
245
245
246
246
public:
247
247
InferAddressSpacesImpl (AssumptionCache &AC, const DominatorTree *DT,
@@ -910,8 +910,13 @@ void InferAddressSpacesImpl::inferAddressSpaces(
910
910
}
911
911
}
912
912
913
- unsigned InferAddressSpacesImpl::getPredicatedAddrSpace (
914
- const Value &Ptr, const Instruction *UserCtxI) const {
913
+ unsigned
914
+ InferAddressSpacesImpl::getPredicatedAddrSpace (const Value &Ptr,
915
+ const Value *UserCtx) const {
916
+ const Instruction *UserCtxI = dyn_cast<Instruction>(UserCtx);
917
+ if (!UserCtxI)
918
+ return UninitializedAddressSpace;
919
+
915
920
const Value *StrippedPtr = Ptr.stripInBoundsOffsets ();
916
921
for (auto &AssumeVH : AC.assumptionsFor (StrippedPtr)) {
917
922
if (!AssumeVH)
@@ -986,8 +991,7 @@ bool InferAddressSpacesImpl::updateAddressSpace(
986
991
OperandAS = PtrOperand->getType ()->getPointerAddressSpace ();
987
992
if (OperandAS == FlatAddrSpace) {
988
993
// Check AC for assumption dominating V.
989
- unsigned AS =
990
- getPredicatedAddrSpace (*PtrOperand, &cast<Instruction>(V));
994
+ unsigned AS = getPredicatedAddrSpace (*PtrOperand, &V);
991
995
if (AS != UninitializedAddressSpace) {
992
996
LLVM_DEBUG (dbgs ()
993
997
<< " deduce operand AS from the predicate addrspace "
0 commit comments