[llvm] 6b1acdb - llvm-reduce: Fix losing operand bundles when removing arguments (#133410)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 28 09:41:51 PDT 2025


Author: Matt Arsenault
Date: 2025-03-28T23:41:47+07:00
New Revision: 6b1acdb818dd158619c71546af1bf5e134cd7e03

URL: https://github.com/llvm/llvm-project/commit/6b1acdb818dd158619c71546af1bf5e134cd7e03
DIFF: https://github.com/llvm/llvm-project/commit/6b1acdb818dd158619c71546af1bf5e134cd7e03.diff

LOG: llvm-reduce: Fix losing operand bundles when removing arguments (#133410)

Added: 
    llvm/test/tools/llvm-reduce/remove-arguments-preserve-bundles.ll

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-reduce/remove-arguments-preserve-bundles.ll b/llvm/test/tools/llvm-reduce/remove-arguments-preserve-bundles.ll
new file mode 100644
index 0000000000000..b370aa5d1dd3b
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/remove-arguments-preserve-bundles.ll
@@ -0,0 +1,28 @@
+; Check that when removing arguments, existing bundles are preserved
+
+; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=arguments --test FileCheck --test-arg --check-prefixes=INTERESTING --test-arg %s --test-arg --input-file %s -o %t
+; RUN: FileCheck --check-prefixes=RESULT %s < %t
+
+; INTERESTING-LABEL: @convergent_callee(
+define i32 @convergent_callee(i32 %a, i32 %b) convergent {
+  ret i32 %a
+}
+
+; INTERESTING-LABEL: @convergent_callee_decl(
+declare i32 @convergent_callee_decl(i32 %a, i32 %b) convergent
+
+; INTERESTING-LABEL: @convergent_caller(
+; INTERESTING: call i32
+; INTERESTING: call i32
+
+; RESULT-LABEL: define i32 @convergent_caller()
+; RESULT: %call0 = call i32 @convergent_callee() [ "convergencectrl"(token %entry.token) ]
+; RESULT: %call1 = call i32 @convergent_callee_decl() [ "convergencectrl"(token %entry.token) ]
+define i32 @convergent_caller(i32 %x) convergent {
+  %entry.token = call token @llvm.experimental.convergence.entry()
+  %call0 = call i32 @convergent_callee(i32 %x, i32 2) [ "convergencectrl"(token %entry.token) ]
+  %call1 = call i32 @convergent_callee_decl(i32 %x, i32 2) [ "convergencectrl"(token %entry.token) ]
+  %result = add i32 %call0, %call1
+  ret i32 %result
+}
+

diff  --git a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
index ba8721e09b99c..a7689688fdc2b 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
@@ -61,8 +61,10 @@ static void replaceFunctionCalls(Function &OldF, Function &NewF,
         }
       }
 
-      // FIXME: Losing bundles
-      CallInst *NewCI = CallInst::Create(&NewF, Args);
+      SmallVector<OperandBundleDef, 2> OpBundles;
+      CI->getOperandBundlesAsDefs(OpBundles);
+
+      CallInst *NewCI = CallInst::Create(&NewF, Args, OpBundles);
       NewCI->setCallingConv(NewF.getCallingConv());
 
       AttrBuilder CallSiteAttrs(Ctx, CI->getAttributes().getFnAttrs());


        


More information about the llvm-commits mailing list