Skip to content

Commit ee575f3

Browse files
committed
VNCoercion: Safely handle targets where pointers are larger than the largest legal integers.
This does not impact any in-tree targets, but does impact CHERI targets.
1 parent 3dc9755 commit ee575f3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

llvm/lib/Transforms/Utils/VNCoercion.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ int analyzeLoadFromClobberingMemInst(Type *LoadTy, Value *LoadPtr,
248248
ConstantInt *SizeCst = dyn_cast<ConstantInt>(MI->getLength());
249249
if (!SizeCst)
250250
return -1;
251+
// If this is a pointer type that's larger than the largest integer that we
252+
// support, then ignore it.
253+
if (LoadTy->isPointerTy() &&
254+
DL.getTypeSizeInBits(LoadTy) > DL.getLargestLegalIntTypeSizeInBits())
255+
return -1;
251256
uint64_t MemSizeInBits = SizeCst->getZExtValue() * 8;
252257

253258
// If this is memset, we just need to see if the offset is valid in the size

0 commit comments

Comments
 (0)