Skip to content

Commit

Permalink
LSV: document hang reported in llvm#37865 (llvm#102479)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
artagnon authored and bwendling committed Aug 15, 2024
1 parent dc2bf4f commit c64dc7a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ void reorder(Instruction *I) {
if (IM->getParent() != I->getParent())
continue;

assert(IM != I && "Unexpected cycle while re-ordering instructions");

if (!IM->comesBefore(I)) {
InstructionsToMove.insert(IM);
Worklist.push_back(IM);
Expand Down
15 changes: 15 additions & 0 deletions llvm/test/Transforms/LoadStoreVectorizer/AArch64/pr37865.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; REQUIRES: asserts
; RUN: not --crash opt -mtriple=aarch64 -passes=load-store-vectorizer \
; RUN: -disable-output %s 2>&1 | FileCheck %s

define i32 @load_cycle(ptr %x) {
; CHECK: Unexpected cycle while re-ordering instructions
entry:
%gep.x.1 = getelementptr inbounds [2 x i32], ptr %x, i32 0, i32 1
%load.x.1 = load i32, ptr %gep.x.1
%rem = urem i32 %load.x.1, 1
%gep.x.2 = getelementptr inbounds [2 x i32], ptr %x, i32 %rem, i32 0
%load.x.2 = load i32, ptr %gep.x.2
%ret = add i32 %load.x.2, %load.x.1
ret i32 %ret
}

0 comments on commit c64dc7a

Please sign in to comment.