diff --git a/llvm/lib/Transforms/Utils/VNCoercion.cpp b/llvm/lib/Transforms/Utils/VNCoercion.cpp index 1e0ae28051641..7fed512183133 100644 --- a/llvm/lib/Transforms/Utils/VNCoercion.cpp +++ b/llvm/lib/Transforms/Utils/VNCoercion.cpp @@ -248,6 +248,11 @@ int analyzeLoadFromClobberingMemInst(Type *LoadTy, Value *LoadPtr, ConstantInt *SizeCst = dyn_cast(MI->getLength()); if (!SizeCst) return -1; + // If this is a pointer type that's larger than the largest integer that we + // support, then ignore it. + if (LoadTy->isPointerTy() && + DL.getTypeSizeInBits(LoadTy) > DL.getLargestLegalIntTypeSizeInBits()) + return -1; uint64_t MemSizeInBits = SizeCst->getZExtValue() * 8; // If this is memset, we just need to see if the offset is valid in the size