[llvm] 5b5f402 - llvm-reduce: Fix losing callsite attributes in operand-to-args (#133420)

via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 29 02:14:49 PDT 2025


Author: Matt Arsenault
Date: 2025-03-29T16:14:46+07:00
New Revision: 5b5f40283da2244f777eb606c722e4483fee4fab

URL: https://github.com/llvm/llvm-project/commit/5b5f40283da2244f777eb606c722e4483fee4fab
DIFF: https://github.com/llvm/llvm-project/commit/5b5f40283da2244f777eb606c722e4483fee4fab.diff

LOG: llvm-reduce: Fix losing callsite attributes in operand-to-args (#133420)

Added: 
    llvm/test/tools/llvm-reduce/operands-to-args-preserve-attributes.ll

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

Removed: 
    


################################################################################
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