Skip to content

Commit 8d4235d

Browse files
committed
[Lint] Fix another scalable vector crash
We also need to check that the memory access LocationSize is not scalable.
1 parent b25b9a7 commit 8d4235d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

llvm/lib/Analysis/Lint.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,8 @@ void Lint::visitMemoryReference(Instruction &I, const MemoryLocation &Loc,
454454

455455
// Accesses from before the start or after the end of the object are not
456456
// defined.
457-
Check(!Loc.Size.hasValue() || BaseSize == MemoryLocation::UnknownSize ||
457+
Check(!Loc.Size.hasValue() || Loc.Size.isScalable() ||
458+
BaseSize == MemoryLocation::UnknownSize ||
458459
(Offset >= 0 && Offset + Loc.Size.getValue() <= BaseSize),
459460
"Undefined behavior: Buffer overflow", &I);
460461

llvm/test/Analysis/Lint/scalable.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ define <vscale x 8 x i8> @alloca_access() {
77
ret <vscale x 8 x i8> %v
88
}
99

10+
; CHECK-NOT: Buffer overflow
11+
define <vscale x 8 x i8> @alloca_access2() {
12+
%a = alloca <256 x i8>
13+
%v = load <vscale x 8 x i8>, ptr %a
14+
ret <vscale x 8 x i8> %v
15+
}
16+
1017
; CHECK-NOT: insertelement index out of range
1118
define <vscale x 8 x half> @insertelement() {
1219
%insert = insertelement <vscale x 8 x half> poison, half 0xH0000, i64 100

0 commit comments

Comments
 (0)