[llvm] llvm-reduce: Fix invalid reduction on tokens in operands-to-args (PR #133855)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 31 21:32:33 PDT 2025
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/133855
None
>From fbc48c9488a98ffef6b093f7414d65ecf3bda9d0 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Tue, 1 Apr 2025 11:31:45 +0700
Subject: [PATCH] llvm-reduce: Fix invalid reduction on tokens in
operands-to-args
---
.../reduce-operands-to-args-token.ll | 27 +++++++++++++++++++
.../deltas/ReduceOperandsToArgs.cpp | 2 +-
2 files changed, 28 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/tools/llvm-reduce/reduce-operands-to-args-token.ll
diff --git a/llvm/test/tools/llvm-reduce/reduce-operands-to-args-token.ll b/llvm/test/tools/llvm-reduce/reduce-operands-to-args-token.ll
new file mode 100644
index 0000000000000..6dba9c266551a
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/reduce-operands-to-args-token.ll
@@ -0,0 +1,27 @@
+; Check no invalid reduction caused by introducing a token typed
+; function argument
+
+; 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
+; RUN: FileCheck -check-prefix=RESULT %s < %t
+
+; INTERESTING-LABEL: define void @tokens(
+; INTERESTING: call void @llvm.token.consumer
+
+; RESULT-LABEL: define void @tokens(ptr %local.ptr) {
+; RESULT-NEXT: %local.ptr1 = alloca i32, align 4
+; RESULT-NEXT: %token = call token @llvm.token.producer()
+; RESULT-NEXT: store i32 0, ptr %local.ptr, align 4
+; RESULT-NEXT: call void @llvm.token.consumer(token %token)
+; RESULT-NEXT: store i32 1, ptr %local.ptr, align 4
+; RESULT-NEXT: ret void
+define void @tokens() {
+ %local.ptr = alloca i32
+ %token = call token @llvm.token.producer()
+ store i32 0, ptr %local.ptr
+ call void @llvm.token.consumer(token %token)
+ store i32 1, ptr %local.ptr
+ ret void
+}
+
+declare token @llvm.token.producer()
+declare void @llvm.token.consumer(token)
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp b/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
index 3548130d3276a..c107e99ecaa74 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
@@ -36,7 +36,7 @@ static bool canReduceUse(Use &Op) {
return false;
// Don't pass labels/metadata as arguments.
- if (Ty->isLabelTy() || Ty->isMetadataTy())
+ if (Ty->isLabelTy() || Ty->isMetadataTy() || Ty->isTokenTy())
return false;
// No need to replace values that are already arguments.
More information about the llvm-commits
mailing list