Skip to content

Commit 199d6f2

Browse files
authored
LSV: document hang reported in #37865 (#102479)
LoadStoreVectorizer hangs on certain examples, when its reorder function goes into a cycle. Detect this cycle and explicitly forbid it, using an assert, and document the resulting crash in a test-case under AArch64.
1 parent ccb2b01 commit 199d6f2

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ void reorder(Instruction *I) {
216216
if (IM->getParent() != I->getParent())
217217
continue;
218218

219+
assert(IM != I && "Unexpected cycle while re-ordering instructions");
220+
219221
if (!IM->comesBefore(I)) {
220222
InstructionsToMove.insert(IM);
221223
Worklist.push_back(IM);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; REQUIRES: asserts
2+
; RUN: not --crash opt -mtriple=aarch64 -passes=load-store-vectorizer \
3+
; RUN: -disable-output %s 2>&1 | FileCheck %s
4+
5+
define i32 @load_cycle(ptr %x) {
6+
; CHECK: Unexpected cycle while re-ordering instructions
7+
entry:
8+
%gep.x.1 = getelementptr inbounds [2 x i32], ptr %x, i32 0, i32 1
9+
%load.x.1 = load i32, ptr %gep.x.1
10+
%rem = urem i32 %load.x.1, 1
11+
%gep.x.2 = getelementptr inbounds [2 x i32], ptr %x, i32 %rem, i32 0
12+
%load.x.2 = load i32, ptr %gep.x.2
13+
%ret = add i32 %load.x.2, %load.x.1
14+
ret i32 %ret
15+
}

0 commit comments

Comments
 (0)