[llvm] llvm-reduce: Fix losing callsite attributes in operand-to-args (PR #133420)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 28 20:05:34 PDT 2025
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/133420
>From 181a1682303fe474420c3da82057f0c89058cc9f Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Fri, 28 Mar 2025 17:54:10 +0700
Subject: [PATCH] llvm-reduce: Fix losing callsite attributes in
operand-to-args
---
.../operands-to-args-preserve-attributes.ll | 31 +++++++++++++++++++
.../deltas/ReduceOperandsToArgs.cpp | 1 +
2 files changed, 32 insertions(+)
create mode 100644 llvm/test/tools/llvm-reduce/operands-to-args-preserve-attributes.ll
diff --git a/llvm/test/tools/llvm-reduce/operands-to-args-preserve-attributes.ll b/llvm/test/tools/llvm-reduce/operands-to-args-preserve-attributes.ll
new file mode 100644
index 0000000000000..3aef3a06eafa3
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/operands-to-args-preserve-attributes.ll
@@ -0,0 +1,31 @@
+; RUN: llvm-reduce %s -o %t --abort-on-invalid-reduction --delta-passes=operands-to-args --test FileCheck --test-arg %s --test-arg --check-prefix=INTERESTING --test-arg --input-file
+; RUN: FileCheck %s --input-file %t --check-prefix=REDUCED
+
+ at a = dso_local global i8 0, align 1
+ at b = dso_local global i16 0, align 2
+
+
+declare ptr @callee(ptr %a, i16)
+
+; INTERESTING-LABEL: define ptr @caller(
+; INTERESTING: sext
+; INTERESTING: icmp
+
+; REDUCED-LABEL: define ptr @caller(ptr %some.ptr, ptr %a, i8 %ld0, ptr %b, i16 %ld1, i32 %conv, i32 %conv1, i1 %cmp, i16 %conv2, ptr %callee.ret) #0 {
+
+; REDUCED: %callee.ret8 = call align 8 ptr @callee(ptr align 8 "some-attr" %some.ptr, i16 signext %conv2) #1
+
+define ptr @caller(ptr %some.ptr) nounwind {
+entry:
+ %ld0 = load i8, ptr @a, align 1
+ %conv = zext i8 %ld0 to i32
+ %ld1 = load i16, ptr @b, align 2
+ %conv1 = sext i16 %ld1 to i32
+ %cmp = icmp sge i32 %conv, %conv1
+ %conv2 = sext i1 %cmp to i16
+ %callee.ret = call align 8 ptr @callee(ptr align 8 "some-attr" %some.ptr, i16 signext %conv2) nocallback
+ ret ptr %callee.ret
+}
+
+; REDUCED: attributes #0 = { nounwind }
+; REDUCED: attributes #1 = { nocallback }
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp b/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
index 32bceb74afa70..b9e07f2c9f63c 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
@@ -105,6 +105,7 @@ static void replaceFunctionCalls(Function *OldF, Function *NewF) {
NewCI = CallInst::Create(NewF, Args, OperandBundles, CI->getName());
}
NewCI->setCallingConv(NewF->getCallingConv());
+ NewCI->setAttributes(CI->getAttributes());
// Do the replacement for this use.
if (!CI->use_empty())
More information about the llvm-commits
mailing list