Skip to content

Commit 664e847

Browse files
authored
llvm-reduce: Fix invalid reduction on tokens in operands-to-args (#133855)
1 parent aa73124 commit 664e847

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
; Check no invalid reduction caused by introducing a token typed
2+
; function argument
3+
4+
; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=operands-to-args --test FileCheck --test-arg --check-prefix=INTERESTING --test-arg %s --test-arg --input-file %s -o %t
5+
; RUN: FileCheck -check-prefix=RESULT %s < %t
6+
7+
; INTERESTING-LABEL: define void @tokens(
8+
; INTERESTING: call void @llvm.token.consumer
9+
10+
; RESULT-LABEL: define void @tokens(ptr %local.ptr) {
11+
; RESULT-NEXT: %local.ptr1 = alloca i32, align 4
12+
; RESULT-NEXT: %token = call token @llvm.token.producer()
13+
; RESULT-NEXT: store i32 0, ptr %local.ptr, align 4
14+
; RESULT-NEXT: call void @llvm.token.consumer(token %token)
15+
; RESULT-NEXT: store i32 1, ptr %local.ptr, align 4
16+
; RESULT-NEXT: ret void
17+
define void @tokens() {
18+
%local.ptr = alloca i32
19+
%token = call token @llvm.token.producer()
20+
store i32 0, ptr %local.ptr
21+
call void @llvm.token.consumer(token %token)
22+
store i32 1, ptr %local.ptr
23+
ret void
24+
}
25+
26+
declare token @llvm.token.producer()
27+
declare void @llvm.token.consumer(token)

llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static bool canReduceUse(Use &Op) {
3636
return false;
3737

3838
// Don't pass labels/metadata as arguments.
39-
if (Ty->isLabelTy() || Ty->isMetadataTy())
39+
if (Ty->isLabelTy() || Ty->isMetadataTy() || Ty->isTokenTy())
4040
return false;
4141

4242
// No need to replace values that are already arguments.

0 commit comments

Comments
 (0)