Skip to content

Commit 9013e6a

Browse files
committed
llvm-reduce: Fix losing metadata when removing arguments
1 parent 688df34 commit 9013e6a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Diff for: llvm/test/tools/llvm-reduce/remove-arguments-preserve-fmf.ll

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ declare float @math_callee_decl(float %a, float %b)
1616
; INTERESTING: call
1717
; INTERESTING: call
1818

19-
; RESULT: %call0 = call nnan nsz float @math_callee()
19+
; RESULT: %call0 = call nnan nsz float @math_callee(), !fpmath !0
2020
; RESULT: %call1 = call ninf float @math_callee_decl()
2121
define float @math_caller(float %x) {
22-
%call0 = call nnan nsz float @math_callee(float %x, float 2.0)
22+
%call0 = call nnan nsz float @math_callee(float %x, float 2.0), !fpmath !0
2323
%call1 = call ninf float @math_callee_decl(float %x, float 2.0)
2424
%result = fadd float %call0, %call1
2525
ret float %result
2626
}
27+
28+
; RESULT: !0 = !{float 2.000000e+00}
29+
!0 = !{float 2.0}

Diff for: llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static void replaceFunctionCalls(Function &OldF, Function &NewF,
6161
}
6262
}
6363

64-
// FIXME: Losing bundles and metadata
64+
// FIXME: Losing bundles
6565
CallInst *NewCI = CallInst::Create(&NewF, Args);
6666
NewCI->setCallingConv(NewF.getCallingConv());
6767

@@ -78,6 +78,8 @@ static void replaceFunctionCalls(Function &OldF, Function &NewF,
7878
if (auto *FPOp = dyn_cast<FPMathOperator>(NewCI))
7979
cast<Instruction>(FPOp)->setFastMathFlags(CI->getFastMathFlags());
8080

81+
NewCI->copyMetadata(*CI);
82+
8183
if (!CI->use_empty())
8284
CI->replaceAllUsesWith(NewCI);
8385
ReplaceInstWithInst(CI, NewCI);

0 commit comments

Comments
 (0)