aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/MemoryBuiltins.cpp
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2024-05-02 19:13:14 -0700
committerGitHub <noreply@github.com>2024-05-02 19:13:14 -0700
commit43a38e2759e81beaf41224a58c04b9db603e62aa (patch)
tree8a2b6a17952cdfb52eea59576c22a113ae3eba4e /llvm/lib/Analysis/MemoryBuiltins.cpp
parentb0eeacb20379f6d80079793b8461f56c240e6570 (diff)
downloadllvm-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.cpp8
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);
}