Skip to content

Commit b0c89a9

Browse files
authored
[mlir][LLVMIR] Remove "unsafe-fp-math" attribute support (llvm#162782)
These global flags block furthur improvements for clang, users should always use fast-math flags see also https://discourse.llvm.org/t/rfc-honor-pragmas-with-ffp-contract-fast/80797 Remove them incrementally, this is the mlir part.
1 parent 7b91bb2 commit b0c89a9

File tree

6 files changed

+0
-45
lines changed

6 files changed

+0
-45
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1975,7 +1975,6 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [
19751975
OptionalAttr<StrAttr>:$reciprocal_estimates,
19761976
OptionalAttr<StrAttr>:$prefer_vector_width,
19771977
OptionalAttr<LLVM_TargetFeaturesAttr>:$target_features,
1978-
OptionalAttr<BoolAttr>:$unsafe_fp_math,
19791978
OptionalAttr<BoolAttr>:$no_infs_fp_math,
19801979
OptionalAttr<BoolAttr>:$no_nans_fp_math,
19811980
OptionalAttr<BoolAttr>:$no_signed_zeros_fp_math,

mlir/lib/Target/LLVMIR/ModuleImport.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,7 +2616,6 @@ static constexpr std::array kExplicitLLVMFuncOpAttributes{
26162616
StringLiteral("optnone"),
26172617
StringLiteral("target-features"),
26182618
StringLiteral("tune-cpu"),
2619-
StringLiteral("unsafe-fp-math"),
26202619
StringLiteral("uwtable"),
26212620
StringLiteral("vscale_range"),
26222621
StringLiteral("willreturn"),
@@ -2714,10 +2713,6 @@ void ModuleImport::processFunctionAttributes(llvm::Function *func,
27142713
attr.isStringAttribute())
27152714
funcOp.setPreferVectorWidth(attr.getValueAsString());
27162715

2717-
if (llvm::Attribute attr = func->getFnAttribute("unsafe-fp-math");
2718-
attr.isStringAttribute())
2719-
funcOp.setUnsafeFpMath(attr.getValueAsBool());
2720-
27212716
if (llvm::Attribute attr = func->getFnAttribute("no-infs-fp-math");
27222717
attr.isStringAttribute())
27232718
funcOp.setNoInfsFpMath(attr.getValueAsBool());

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,9 +1560,6 @@ LogicalResult ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
15601560
getLLVMContext(), attr->getMinRange().getInt(),
15611561
attr->getMaxRange().getInt()));
15621562

1563-
if (auto unsafeFpMath = func.getUnsafeFpMath())
1564-
llvmFunc->addFnAttr("unsafe-fp-math", llvm::toStringRef(*unsafeFpMath));
1565-
15661563
if (auto noInfsFpMath = func.getNoInfsFpMath())
15671564
llvmFunc->addFnAttr("no-infs-fp-math", llvm::toStringRef(*noInfsFpMath));
15681565

mlir/test/Dialect/LLVMIR/func.mlir

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,6 @@ module {
258258
llvm.return
259259
}
260260

261-
llvm.func @unsafe_fp_math_roundtrip() attributes {unsafe_fp_math = true} {
262-
// CHECK: @unsafe_fp_math_roundtrip
263-
// CHECK-SAME: attributes {unsafe_fp_math = true}
264-
llvm.return
265-
}
266-
267261
llvm.func @no_infs_fp_math_roundtrip() attributes {no_infs_fp_math = true} {
268262
// CHECK: @no_infs_fp_math_roundtrip
269263
// CHECK-SAME: attributes {no_infs_fp_math = true}

mlir/test/Target/LLVMIR/Import/function-attributes.ll

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -303,18 +303,6 @@ declare void @align_decl() align 64
303303

304304
; // -----
305305

306-
; CHECK-LABEL: @func_attr_unsafe_fp_math_true
307-
; CHECK-SAME: attributes {unsafe_fp_math = true}
308-
declare void @func_attr_unsafe_fp_math_true() "unsafe-fp-math"="true"
309-
310-
; // -----
311-
312-
; CHECK-LABEL: @func_attr_unsafe_fp_math_false
313-
; CHECK-SAME: attributes {unsafe_fp_math = false}
314-
declare void @func_attr_unsafe_fp_math_false() "unsafe-fp-math"="false"
315-
316-
; // -----
317-
318306
; CHECK-LABEL: @func_attr_no_infs_fp_math_true
319307
; CHECK-SAME: attributes {no_infs_fp_math = true}
320308
declare void @func_attr_no_infs_fp_math_true() "no-infs-fp-math"="true"

mlir/test/Target/LLVMIR/fp-math-function-attributes.mlir

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
11
// RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s
22

3-
// CHECK-LABEL: define void @unsafe_fp_math_func_true()
4-
// CHECK-SAME: #[[ATTRS:[0-9]+]]
5-
llvm.func @unsafe_fp_math_func_true() attributes {unsafe_fp_math = true} {
6-
llvm.return
7-
}
8-
// CHECK: attributes #[[ATTRS]] = { "unsafe-fp-math"="true" }
9-
10-
// -----
11-
12-
// CHECK-LABEL: define void @unsafe_fp_math_func_false()
13-
// CHECK-SAME: #[[ATTRS:[0-9]+]]
14-
llvm.func @unsafe_fp_math_func_false() attributes {unsafe_fp_math = false} {
15-
llvm.return
16-
}
17-
// CHECK: attributes #[[ATTRS]] = { "unsafe-fp-math"="false" }
18-
19-
// -----
20-
213
// CHECK-LABEL: define void @no_infs_fp_math_func_true()
224
// CHECK-SAME: #[[ATTRS:[0-9]+]]
235
llvm.func @no_infs_fp_math_func_true() attributes {no_infs_fp_math = true} {

0 commit comments

Comments
 (0)