diff --git a/llvm/lib/Analysis/Loads.cpp b/llvm/lib/Analysis/Loads.cpp index b81322b69bbd..d63f6b9b1964 100644 --- a/llvm/lib/Analysis/Loads.cpp +++ b/llvm/lib/Analysis/Loads.cpp @@ -516,7 +516,7 @@ bool llvm::canReplacePointersIfEqual(Value *A, Value *B, const DataLayout &DL, if (auto *C = dyn_cast(B)) { // Do not allow replacing a pointer with a constant pointer, unless it is // either null or at least one byte is dereferenceable. - APInt OneByte(DL.getPointerTypeSizeInBits(A->getType()), 1); + APInt OneByte(DL.getPointerTypeSizeInBits(Ty), 1); return C->isNullValue() || isDereferenceableAndAlignedPointer(B, Align(1), OneByte, DL, CtxI); }