Skip to content

Commit 29c076b

Browse files
committed
[Lint] Fix crash with scalable alloca
1 parent 2fef449 commit 29c076b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

llvm/lib/Analysis/Lint.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,8 @@ void Lint::visitMemoryReference(Instruction &I, const MemoryLocation &Loc,
436436

437437
if (AllocaInst *AI = dyn_cast<AllocaInst>(Base)) {
438438
Type *ATy = AI->getAllocatedType();
439-
if (!AI->isArrayAllocation() && ATy->isSized())
440-
BaseSize = DL->getTypeAllocSize(ATy);
439+
if (!AI->isArrayAllocation() && ATy->isSized() && !ATy->isScalableTy())
440+
BaseSize = DL->getTypeAllocSize(ATy).getFixedValue();
441441
BaseAlign = AI->getAlign();
442442
} else if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Base)) {
443443
// If the global may be defined differently in another compilation unit

llvm/test/Analysis/Lint/scalable.ll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -S -passes=lint < %s | FileCheck %s
3+
4+
; Make sure we don't crash.
5+
6+
define <vscale x 8 x i8> @test() {
7+
; CHECK-LABEL: define <vscale x 8 x i8> @test() {
8+
; CHECK-NEXT: [[A:%.*]] = alloca <vscale x 8 x i8>, align 8
9+
; CHECK-NEXT: [[V:%.*]] = load <vscale x 8 x i8>, ptr [[A]], align 8
10+
; CHECK-NEXT: ret <vscale x 8 x i8> [[V]]
11+
;
12+
%a = alloca <vscale x 8 x i8>
13+
%v = load <vscale x 8 x i8>, ptr %a
14+
ret <vscale x 8 x i8> %v
15+
}

0 commit comments

Comments
 (0)