[llvm] [InstCombine] Avoid Allocating Arrays Too Large For the Target (PR #70980)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 2 01:37:55 PDT 2023
================
@@ -210,14 +210,23 @@ static Instruction *simplifyAllocaArraySize(InstCombinerImpl &IC,
if (const ConstantInt *C = dyn_cast<ConstantInt>(AI.getArraySize())) {
if (C->getValue().getActiveBits() <= 64) {
Type *NewTy = ArrayType::get(AI.getAllocatedType(), C->getZExtValue());
+
+ // Make sure we do not create an array type larger than pointers on the
+ // target can index.
+ unsigned MaxArrSizeBitWidth =
+ IC.getDataLayout().getPointerTypeSizeInBits(AI.getType());
----------------
arsenm wrote:
You should use DL.getIndexSize as the basis for this, not the pointer size
https://github.com/llvm/llvm-project/pull/70980
More information about the llvm-commits
mailing list