https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/133409

>From 38d881a2ce55f76900c7dec71b86e1ab1f3d3334 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <matthew.arsena...@amd.com>
Date: Fri, 28 Mar 2025 16:29:29 +0700
Subject: [PATCH] llvm-reduce: Fix losing metadata when removing arguments

---
 .../tools/llvm-reduce/remove-arguments-preserve-fmf.ll     | 7 +++++--
 llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp          | 4 +++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/llvm/test/tools/llvm-reduce/remove-arguments-preserve-fmf.ll 
b/llvm/test/tools/llvm-reduce/remove-arguments-preserve-fmf.ll
index 2ceb3e717200b..4c78920ede44a 100644
--- a/llvm/test/tools/llvm-reduce/remove-arguments-preserve-fmf.ll
+++ b/llvm/test/tools/llvm-reduce/remove-arguments-preserve-fmf.ll
@@ -16,11 +16,14 @@ declare float @math_callee_decl(float %a, float %b)
 ; INTERESTING: call
 ; INTERESTING: call
 
-; RESULT: %call0 = call nnan nsz float @math_callee()
+; RESULT: %call0 = call nnan nsz float @math_callee(), !fpmath !0
 ; RESULT: %call1 = call ninf float @math_callee_decl()
 define float @math_caller(float %x) {
-  %call0 = call nnan nsz float @math_callee(float %x, float 2.0)
+  %call0 = call nnan nsz float @math_callee(float %x, float 2.0), !fpmath !0
   %call1 = call ninf float @math_callee_decl(float %x, float 2.0)
   %result = fadd float %call0, %call1
   ret float %result
 }
+
+; RESULT: !0 = !{float 2.000000e+00}
+!0 = !{float 2.0}
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp 
b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
index b1bbcf8917b3c..ba8721e09b99c 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
@@ -61,7 +61,7 @@ static void replaceFunctionCalls(Function &OldF, Function 
&NewF,
         }
       }
 
-      // FIXME: Losing bundles and metadata
+      // FIXME: Losing bundles
       CallInst *NewCI = CallInst::Create(&NewF, Args);
       NewCI->setCallingConv(NewF.getCallingConv());
 
@@ -78,6 +78,8 @@ static void replaceFunctionCalls(Function &OldF, Function 
&NewF,
       if (auto *FPOp = dyn_cast<FPMathOperator>(NewCI))
         cast<Instruction>(FPOp)->setFastMathFlags(CI->getFastMathFlags());
 
+      NewCI->copyMetadata(*CI);
+
       if (!CI->use_empty())
         CI->replaceAllUsesWith(NewCI);
       ReplaceInstWithInst(CI, NewCI);

_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to