diff options
author | Vitaly Buka <vitalybuka@google.com> | 2024-05-02 19:13:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-02 19:13:14 -0700 |
commit | 43a38e2759e81beaf41224a58c04b9db603e62aa (patch) | |
tree | 8a2b6a17952cdfb52eea59576c22a113ae3eba4e /llvm/lib/Analysis/MemoryBuiltins.cpp | |
parent | b0eeacb20379f6d80079793b8461f56c240e6570 (diff) | |
download | llvm-43a38e2759e81beaf41224a58c04b9db603e62aa.zip llvm-43a38e2759e81beaf41224a58c04b9db603e62aa.tar.gz llvm-43a38e2759e81beaf41224a58c04b9db603e62aa.tar.bz2 |
[BoundsChecking] Handle vscale allocas (#90926)
Diffstat (limited to 'llvm/lib/Analysis/MemoryBuiltins.cpp')
-rw-r--r-- | llvm/lib/Analysis/MemoryBuiltins.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp index 46a7a921..8ca15434 100644 --- a/llvm/lib/Analysis/MemoryBuiltins.cpp +++ b/llvm/lib/Analysis/MemoryBuiltins.cpp @@ -1138,8 +1138,8 @@ SizeOffsetValue ObjectSizeOffsetEvaluator::visitAllocaInst(AllocaInst &I) { if (!I.getAllocatedType()->isSized()) return ObjectSizeOffsetEvaluator::unknown(); - // must be a VLA - assert(I.isArrayAllocation()); + // must be a VLA or vscale. + assert(I.isArrayAllocation() || I.getAllocatedType()->isScalableTy()); // If needed, adjust the alloca's operand size to match the pointer indexing // size. Subsequent math operations expect the types to match. @@ -1149,8 +1149,8 @@ SizeOffsetValue ObjectSizeOffsetEvaluator::visitAllocaInst(AllocaInst &I) { assert(ArraySize->getType() == Zero->getType() && "Expected zero constant to have pointer index type"); - Value *Size = ConstantInt::get(ArraySize->getType(), - DL.getTypeAllocSize(I.getAllocatedType())); + Value *Size = Builder.CreateTypeSize( + ArraySize->getType(), DL.getTypeAllocSize(I.getAllocatedType())); Size = Builder.CreateMul(Size, ArraySize); return SizeOffsetValue(Size, Zero); } |