Skip to content

Commit 3514320

Browse files
committed
[WIP][Attributor] Check range size before constant fold load
If the range size doesn't match the type size, it might read wrong data.
1 parent 1598062 commit 3514320

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

llvm/lib/Transforms/IPO/Attributor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ AA::getInitialValueForObj(Attributor &A, const AbstractAttribute &QueryingAA,
272272
}
273273

274274
if (RangePtr && !RangePtr->offsetOrSizeAreUnknown()) {
275+
int64_t StorageSize = DL.getTypeStoreSize(&Ty);
276+
if (StorageSize != RangePtr->Size)
277+
return nullptr;
275278
APInt Offset = APInt(64, RangePtr->Offset);
276279
return ConstantFoldLoadFromConst(Initializer, &Ty, Offset, DL);
277280
}

0 commit comments

Comments
 (0)