https://github.com/paperchalice updated https://github.com/llvm/llvm-project/pull/180083
>From 5e2f25c2b892ad36b1fb9cb2e136e13a67a4a7b2 Mon Sep 17 00:00:00 2001 From: PaperChalice <[email protected]> Date: Wed, 4 Feb 2026 10:07:07 +0800 Subject: [PATCH] [llvm] Remove "no-infs-fp-math" attribute support --- clang/lib/CodeGen/BackendUtil.cpp | 1 - clang/lib/CodeGen/CGCall.cpp | 2 - clang/lib/CodeGen/CodeGenFunction.cpp | 1 - .../flang/Optimizer/Transforms/Passes.td | 2 +- flang/include/flang/Tools/CrossToolHelpers.h | 2 +- .../lib/Optimizer/Transforms/FunctionAttr.cpp | 4 -- flang/test/Driver/func-attr-fast-math.f90 | 4 +- llvm/include/llvm/CodeGen/CommandFlags.h | 2 - llvm/include/llvm/IR/Attributes.td | 2 - llvm/include/llvm/Target/TargetOptions.h | 10 +---- llvm/lib/CodeGen/CommandFlags.cpp | 9 ---- llvm/lib/Target/TargetMachine.cpp | 1 - .../NumericalStabilitySanitizer.cpp | 1 - llvm/test/CodeGen/AMDGPU/inline-attr.ll | 11 +++-- ...ining-compatible-and-attribute-transfer.ll | 7 ++-- llvm/test/Transforms/Inline/attributes.ll | 42 ------------------- mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td | 1 - mlir/lib/Target/LLVMIR/ModuleImport.cpp | 5 --- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 3 -- .../LLVMIR/Import/function-attributes.ll | 12 ------ .../LLVMIR/fp-math-function-attributes.mlir | 18 -------- 21 files changed, 14 insertions(+), 126 deletions(-) diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index b286ff359ec40..94257fb96fc7f 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -414,7 +414,6 @@ static bool initTargetOptions(const CompilerInstance &CI, if (CodeGenOpts.hasWasmExceptions()) Options.ExceptionModel = llvm::ExceptionHandling::Wasm; - Options.NoInfsFPMath = LangOpts.NoHonorInfs; Options.NoNaNsFPMath = LangOpts.NoHonorNaNs; Options.NoZerosInBSS = CodeGenOpts.NoZeroInitializedInBSS; diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index efb5ade668920..76535cff60d66 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -2009,8 +2009,6 @@ static void getTrivialDefaultFunctionAttributes( // TODO: Are these all needed? // unsafe/inf/nan/nsz are handled by instruction-level FastMathFlags. - if (LangOpts.NoHonorInfs) - FuncAttrs.addAttribute("no-infs-fp-math", "true"); if (LangOpts.NoHonorNaNs) FuncAttrs.addAttribute("no-nans-fp-math", "true"); if (CodeGenOpts.SoftFloat) diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index aa6f2ebaccd79..2d3507447804a 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -178,7 +178,6 @@ void CodeGenFunction::CGFPOptionsRAII::ConstructorHelper(FPOptions FPFeatures) { if (OldValue != NewValue) CGF.CurFn->addFnAttr(Name, llvm::toStringRef(NewValue)); }; - mergeFnAttrValue("no-infs-fp-math", FPFeatures.getNoHonorInfs()); mergeFnAttrValue("no-nans-fp-math", FPFeatures.getNoHonorNaNs()); mergeFnAttrValue("no-signed-zeros-fp-math", FPFeatures.getNoSignedZero()); } diff --git a/flang/include/flang/Optimizer/Transforms/Passes.td b/flang/include/flang/Optimizer/Transforms/Passes.td index c2d6526b558d2..090a1ce24fd8b 100644 --- a/flang/include/flang/Optimizer/Transforms/Passes.td +++ b/flang/include/flang/Optimizer/Transforms/Passes.td @@ -437,7 +437,7 @@ def FunctionAttr : Pass<"function-attr", "mlir::func::FuncOp"> { "Sets the name of the profiling function called during function " "exit">, Option<"noInfsFPMath", "no-infs-fp-math", "bool", /*default=*/"false", - "Set the no-infs-fp-math attribute on functions in the module.">, + "Set the ninf flag on instructions in the module.">, Option<"noNaNsFPMath", "no-nans-fp-math", "bool", /*default=*/"false", "Set the no-nans-fp-math attribute on functions in the module.">, Option<"approxFuncFPMath", "approx-func-fp-math", "bool", diff --git a/flang/include/flang/Tools/CrossToolHelpers.h b/flang/include/flang/Tools/CrossToolHelpers.h index e964882ef6dac..44fb252d2b366 100644 --- a/flang/include/flang/Tools/CrossToolHelpers.h +++ b/flang/include/flang/Tools/CrossToolHelpers.h @@ -123,7 +123,7 @@ struct MLIRToLLVMPassPipelineConfig : public FlangEPCallBacks { llvm::FramePointerKind::None; ///< Add frame pointer to functions. unsigned VScaleMin = 0; ///< SVE vector range minimum. unsigned VScaleMax = 0; ///< SVE vector range maximum. - bool NoInfsFPMath = false; ///< Set no-infs-fp-math attribute for functions. + bool NoInfsFPMath = false; ///< Set ninf flag for instructions. bool NoNaNsFPMath = false; ///< Set no-nans-fp-math attribute for functions. bool ApproxFuncFPMath = false; ///< Set afn flag for instructions. bool NoSignedZerosFPMath = diff --git a/flang/lib/Optimizer/Transforms/FunctionAttr.cpp b/flang/lib/Optimizer/Transforms/FunctionAttr.cpp index fea511cc63a37..3879a807fda2f 100644 --- a/flang/lib/Optimizer/Transforms/FunctionAttr.cpp +++ b/flang/lib/Optimizer/Transforms/FunctionAttr.cpp @@ -87,10 +87,6 @@ void FunctionAttrPass::runOnOperation() { func->setAttr(mlir::LLVM::LLVMFuncOp::getInstrumentFunctionExitAttrName( llvmFuncOpName), mlir::StringAttr::get(context, instrumentFunctionExit)); - if (noInfsFPMath) - func->setAttr( - mlir::LLVM::LLVMFuncOp::getNoInfsFpMathAttrName(llvmFuncOpName), - mlir::BoolAttr::get(context, true)); if (noNaNsFPMath) func->setAttr( mlir::LLVM::LLVMFuncOp::getNoNansFpMathAttrName(llvmFuncOpName), diff --git a/flang/test/Driver/func-attr-fast-math.f90 b/flang/test/Driver/func-attr-fast-math.f90 index 3af641ea2db26..b8f8a0e1c8a63 100644 --- a/flang/test/Driver/func-attr-fast-math.f90 +++ b/flang/test/Driver/func-attr-fast-math.f90 @@ -11,8 +11,8 @@ end subroutine func ! CHECK-OFAST-LABEL: define void @func_() local_unnamed_addr ! CHECK-OFAST-SAME: #[[ATTRS:[0-9]+]] -! CHECK-OFAST: attributes #[[ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" {{.*}}"no-signed-zeros-fp-math"="true"{{.*}} } +! CHECK-OFAST: attributes #[[ATTRS]] = { {{.*}}"no-nans-fp-math"="true" {{.*}}"no-signed-zeros-fp-math"="true"{{.*}} } ! CHECK-FFAST-MATH-LABEL: define void @func_() local_unnamed_addr ! CHECK-FFAST-MATH-SAME: #[[ATTRS:[0-9]+]] -! CHECK-FFAST-MATH: attributes #[[ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" {{.*}}"no-signed-zeros-fp-math"="true"{{.*}} } +! CHECK-FFAST-MATH: attributes #[[ATTRS]] = { {{.*}}"no-nans-fp-math"="true" {{.*}}"no-signed-zeros-fp-math"="true"{{.*}} } diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h b/llvm/include/llvm/CodeGen/CommandFlags.h index 6a907b64542ae..c83bce7771878 100644 --- a/llvm/include/llvm/CodeGen/CommandFlags.h +++ b/llvm/include/llvm/CodeGen/CommandFlags.h @@ -58,8 +58,6 @@ LLVM_ABI CodeGenFileType getFileType(); LLVM_ABI FramePointerKind getFramePointerUsage(); -LLVM_ABI bool getEnableNoInfsFPMath(); - LLVM_ABI bool getEnableNoNaNsFPMath(); LLVM_ABI bool getEnableNoSignedZerosFPMath(); diff --git a/llvm/include/llvm/IR/Attributes.td b/llvm/include/llvm/IR/Attributes.td index 5220b4768a39f..7c5457459f243 100644 --- a/llvm/include/llvm/IR/Attributes.td +++ b/llvm/include/llvm/IR/Attributes.td @@ -416,7 +416,6 @@ def AllowDirectAccessInHotPatchFunction /// Target-independent string attributes. def LessPreciseFPMAD : StrBoolAttr<"less-precise-fpmad">; -def NoInfsFPMath : StrBoolAttr<"no-infs-fp-math">; def NoNansFPMath : StrBoolAttr<"no-nans-fp-math">; def NoSignedZerosFPMath : StrBoolAttr<"no-signed-zeros-fp-math">; def NoJumpTables : StrBoolAttr<"no-jump-tables">; @@ -476,7 +475,6 @@ class MergeRule<string F> { } def : MergeRule<"setAND<LessPreciseFPMADAttr>">; -def : MergeRule<"setAND<NoInfsFPMathAttr>">; def : MergeRule<"setAND<NoNansFPMathAttr>">; def : MergeRule<"setAND<NoSignedZerosFPMathAttr>">; def : MergeRule<"setOR<NoImplicitFloatAttr>">; diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h index a9b86626cf598..e38ec301ff091 100644 --- a/llvm/include/llvm/Target/TargetOptions.h +++ b/llvm/include/llvm/Target/TargetOptions.h @@ -119,8 +119,8 @@ enum CodeObjectVersionKind { class TargetOptions { public: TargetOptions() - : NoInfsFPMath(false), NoNaNsFPMath(false), NoTrappingFPMath(true), - NoSignedZerosFPMath(false), EnableAIXExtendedAltivecABI(false), + : NoNaNsFPMath(false), NoTrappingFPMath(true), NoSignedZerosFPMath(false), + EnableAIXExtendedAltivecABI(false), HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false), GuaranteedTailCallOpt(false), StackSymbolOrdering(true), EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false), @@ -155,12 +155,6 @@ class TargetOptions { /// MCAsmInfo::BinutilsVersion. std::pair<int, int> BinutilsVersion{0, 0}; - /// NoInfsFPMath - This flag is enabled when the - /// -enable-no-infs-fp-math flag is specified on the command line. When - /// this flag is off (the default), the code generator is not allowed to - /// assume the FP arithmetic arguments and results are never +-Infs. - unsigned NoInfsFPMath : 1; - /// NoNaNsFPMath - This flag is enabled when the /// -enable-no-nans-fp-math flag is specified on the command line. When /// this flag is off (the default), the code generator is not allowed to diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp index e2e5e2263062f..24f74dbd28b61 100644 --- a/llvm/lib/CodeGen/CommandFlags.cpp +++ b/llvm/lib/CodeGen/CommandFlags.cpp @@ -74,7 +74,6 @@ CGOPT_EXP(uint64_t, LargeDataThreshold) CGOPT(ExceptionHandling, ExceptionModel) CGOPT_EXP(CodeGenFileType, FileType) CGOPT(FramePointerKind, FramePointerUsage) -CGOPT(bool, EnableNoInfsFPMath) CGOPT(bool, EnableNoNaNsFPMath) CGOPT(bool, EnableNoSignedZerosFPMath) CGOPT(bool, EnableNoTrappingFPMath) @@ -233,12 +232,6 @@ codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() { "Enable frame pointer elimination"))); CGBINDOPT(FramePointerUsage); - static cl::opt<bool> EnableNoInfsFPMath( - "enable-no-infs-fp-math", - cl::desc("Enable FP math optimizations that assume no +-Infs"), - cl::init(false)); - CGBINDOPT(EnableNoInfsFPMath); - static cl::opt<bool> EnableNoNaNsFPMath( "enable-no-nans-fp-math", cl::desc("Enable FP math optimizations that assume no NaNs"), @@ -596,7 +589,6 @@ TargetOptions codegen::InitTargetOptionsFromCodeGenFlags(const Triple &TheTriple) { TargetOptions Options; Options.AllowFPOpFusion = getFuseFPOps(); - Options.NoInfsFPMath = getEnableNoInfsFPMath(); Options.NoNaNsFPMath = getEnableNoNaNsFPMath(); Options.NoSignedZerosFPMath = getEnableNoSignedZerosFPMath(); Options.NoTrappingFPMath = getEnableNoTrappingFPMath(); @@ -747,7 +739,6 @@ void codegen::setFunctionAttributes(StringRef CPU, StringRef Features, if (getStackRealign()) NewAttrs.addAttribute("stackrealign"); - HANDLE_BOOL_ATTR(EnableNoInfsFPMathView, "no-infs-fp-math"); HANDLE_BOOL_ATTR(EnableNoNaNsFPMathView, "no-nans-fp-math"); HANDLE_BOOL_ATTR(EnableNoSignedZerosFPMathView, "no-signed-zeros-fp-math"); diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index f8f13a042fec0..3494637237c69 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -158,7 +158,6 @@ void TargetMachine::resetTargetOptions(const Function &F) const { Options.X = F.getFnAttribute(Y).getValueAsBool(); \ } while (0) - RESET_OPTION(NoInfsFPMath, "no-infs-fp-math"); RESET_OPTION(NoNaNsFPMath, "no-nans-fp-math"); RESET_OPTION(NoSignedZerosFPMath, "no-signed-zeros-fp-math"); } diff --git a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp index 66d570b3f831e..f9ef67923ed48 100644 --- a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp @@ -2020,7 +2020,6 @@ static void moveFastMathFlags(Function &F, F.removeFnAttr(attr); \ FMF.set##setter(); \ } - MOVE_FLAG("no-infs-fp-math", NoInfs) MOVE_FLAG("no-nans-fp-math", NoNaNs) MOVE_FLAG("no-signed-zeros-fp-math", NoSignedZeros) #undef MOVE_FLAG diff --git a/llvm/test/CodeGen/AMDGPU/inline-attr.ll b/llvm/test/CodeGen/AMDGPU/inline-attr.ll index c33b3344fd51c..6400c3860ad88 100644 --- a/llvm/test/CodeGen/AMDGPU/inline-attr.ll +++ b/llvm/test/CodeGen/AMDGPU/inline-attr.ll @@ -1,7 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all --version 5 ; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -O3 %s | FileCheck --check-prefixes=GCN,UNSAFE %s ; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -O3 -enable-no-nans-fp-math %s | FileCheck --check-prefixes=GCN,NONANS %s -; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -O3 -enable-no-infs-fp-math %s | FileCheck --check-prefixes=GCN,NOINFS %s declare void @extern() #0 @@ -37,17 +36,17 @@ entry: } attributes #0 = { nounwind "uniform-work-group-size"="false"} -attributes #1 = { nounwind "less-precise-fpmad"="true" "no-infs-fp-math"="true" "no-nans-fp-math"="true" } +attributes #1 = { nounwind "less-precise-fpmad"="true" "no-nans-fp-math"="true" } ;. ; UNSAFE: attributes #[[ATTR0]] = { nounwind "uniform-work-group-size"="false" } -; UNSAFE: attributes #[[ATTR1]] = { nounwind "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "uniform-work-group-size"="false" } +; UNSAFE: attributes #[[ATTR1]] = { nounwind "less-precise-fpmad"="false" "no-nans-fp-math"="false" "uniform-work-group-size"="false" } ;. ; NONANS: attributes #[[ATTR0]] = { nounwind "no-nans-fp-math"="true" "uniform-work-group-size"="false" } -; NONANS: attributes #[[ATTR1]] = { nounwind "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="true" "uniform-work-group-size"="false" } +; NONANS: attributes #[[ATTR1]] = { nounwind "less-precise-fpmad"="false" "no-nans-fp-math"="true" "uniform-work-group-size"="false" } ;. -; NOINFS: attributes #[[ATTR0]] = { nounwind "no-infs-fp-math"="true" "uniform-work-group-size"="false" } -; NOINFS: attributes #[[ATTR1]] = { nounwind "less-precise-fpmad"="false" "no-infs-fp-math"="true" "no-nans-fp-math"="false" "uniform-work-group-size"="false" } +; NOINFS: attributes #[[ATTR0]] = { nounwind "uniform-work-group-size"="false" } +; NOINFS: attributes #[[ATTR1]] = { nounwind "less-precise-fpmad"="false" "no-nans-fp-math"="false" "uniform-work-group-size"="false" } ;. ; UNSAFE: [[META0]] = !{} ;. diff --git a/llvm/test/Transforms/IROutliner/outlining-compatible-and-attribute-transfer.ll b/llvm/test/Transforms/IROutliner/outlining-compatible-and-attribute-transfer.ll index 15ce3e3c440fe..68a640ef8d3df 100644 --- a/llvm/test/Transforms/IROutliner/outlining-compatible-and-attribute-transfer.ll +++ b/llvm/test/Transforms/IROutliner/outlining-compatible-and-attribute-transfer.ll @@ -100,8 +100,7 @@ entry: ret void } -attributes #0 = { "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "less-precise-fpmad"="true" -"no-infs-fp-math"="true"} +attributes #0 = { "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "less-precise-fpmad"="true" } ; CHECK: define internal void @outlined_ir_func_0(ptr [[ARG0:%.*]], ptr [[ARG1:%.*]], ptr [[ARG2:%.*]]) [[ATTR1:#[0-9]+]] { ; CHECK: entry_to_outline: @@ -122,5 +121,5 @@ attributes #0 = { "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" "les ; CHECK-NEXT: [[CL:%.*]] = load i32, ptr [[ARG2]], align 4 -; CHECK: attributes [[ATTR1]] = { minsize optsize "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" } -; CHECK: attributes [[ATTR]] = { minsize optsize "less-precise-fpmad"="true" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" } +; CHECK: attributes [[ATTR1]] = { minsize optsize "less-precise-fpmad"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" } +; CHECK: attributes [[ATTR]] = { minsize optsize "less-precise-fpmad"="true" "no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" } diff --git a/llvm/test/Transforms/Inline/attributes.ll b/llvm/test/Transforms/Inline/attributes.ll index 9582f416ce4f6..762e3bc9a34a4 100644 --- a/llvm/test/Transforms/Inline/attributes.ll +++ b/llvm/test/Transforms/Inline/attributes.ll @@ -480,46 +480,6 @@ define i32 @test_null-pointer-is-valid2(i32 %i) null_pointer_is_valid { ; CHECK-NEXT: ret i32 } -define i32 @no-infs-fp-math_callee0(i32 %i) "no-infs-fp-math"="false" { - ret i32 %i -; CHECK: @no-infs-fp-math_callee0(i32 %i) [[NO_INFS_FPMATH_FALSE:#[0-9]+]] { -; CHECK-NEXT: ret i32 -} - -define i32 @no-infs-fp-math_callee1(i32 %i) "no-infs-fp-math"="true" { - ret i32 %i -; CHECK: @no-infs-fp-math_callee1(i32 %i) [[NO_INFS_FPMATH_TRUE:#[0-9]+]] { -; CHECK-NEXT: ret i32 -} - -define i32 @test_no-infs-fp-math0(i32 %i) "no-infs-fp-math"="false" { - %1 = call i32 @no-infs-fp-math_callee0(i32 %i) - ret i32 %1 -; CHECK: @test_no-infs-fp-math0(i32 %i) [[NO_INFS_FPMATH_FALSE]] { -; CHECK-NEXT: ret i32 -} - -define i32 @test_no-infs-fp-math1(i32 %i) "no-infs-fp-math"="false" { - %1 = call i32 @no-infs-fp-math_callee1(i32 %i) - ret i32 %1 -; CHECK: @test_no-infs-fp-math1(i32 %i) [[NO_INFS_FPMATH_FALSE]] { -; CHECK-NEXT: ret i32 -} - -define i32 @test_no-infs-fp-math2(i32 %i) "no-infs-fp-math"="true" { - %1 = call i32 @no-infs-fp-math_callee0(i32 %i) - ret i32 %1 -; CHECK: @test_no-infs-fp-math2(i32 %i) [[NO_INFS_FPMATH_FALSE]] { -; CHECK-NEXT: ret i32 -} - -define i32 @test_no-infs-fp-math3(i32 %i) "no-infs-fp-math"="true" { - %1 = call i32 @no-infs-fp-math_callee1(i32 %i) - ret i32 %1 -; CHECK: @test_no-infs-fp-math3(i32 %i) [[NO_INFS_FPMATH_TRUE]] { -; CHECK-NEXT: ret i32 -} - define i32 @no-nans-fp-math_callee0(i32 %i) "no-nans-fp-math"="false" { ret i32 %i ; CHECK: @no-nans-fp-math_callee0(i32 %i) [[NO_NANS_FPMATH_FALSE:#[0-9]+]] { @@ -646,8 +606,6 @@ define i32 @loader_replaceable_caller() { ; CHECK: attributes [[NOIMPLICITFLOAT]] = { noimplicitfloat } ; CHECK: attributes [[NOUSEJUMPTABLES]] = { "no-jump-tables"="true" } ; CHECK: attributes [[NULLPOINTERISVALID]] = { null_pointer_is_valid } -; CHECK: attributes [[NO_INFS_FPMATH_FALSE]] = { "no-infs-fp-math"="false" } -; CHECK: attributes [[NO_INFS_FPMATH_TRUE]] = { "no-infs-fp-math"="true" } ; CHECK: attributes [[NO_NANS_FPMATH_FALSE]] = { "no-nans-fp-math"="false" } ; CHECK: attributes [[NO_NANS_FPMATH_TRUE]] = { "no-nans-fp-math"="true" } ; CHECK: attributes [[NO_SIGNED_ZEROS_FPMATH_FALSE]] = { "no-signed-zeros-fp-math"="false" } diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td index c57d0a15c404a..6323c0cc6a60a 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -1985,7 +1985,6 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [ OptionalAttr<StrAttr>:$reciprocal_estimates, OptionalAttr<StrAttr>:$prefer_vector_width, OptionalAttr<LLVM_TargetFeaturesAttr>:$target_features, - OptionalAttr<BoolAttr>:$no_infs_fp_math, OptionalAttr<BoolAttr>:$no_nans_fp_math, OptionalAttr<BoolAttr>:$no_signed_zeros_fp_math, OptionalAttr<LLVM_DenormalFPEnvAttr>:$denormal_fpenv, diff --git a/mlir/lib/Target/LLVMIR/ModuleImport.cpp b/mlir/lib/Target/LLVMIR/ModuleImport.cpp index 1653c2e358d6a..058b220ea0910 100644 --- a/mlir/lib/Target/LLVMIR/ModuleImport.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleImport.cpp @@ -2689,7 +2689,6 @@ static constexpr std::array kExplicitLLVMFuncOpAttributes{ StringLiteral("modular-format"), StringLiteral("memory"), StringLiteral("no_caller_saved_registers"), - StringLiteral("no-infs-fp-math"), StringLiteral("no-nans-fp-math"), StringLiteral("no-signed-zeros-fp-math"), StringLiteral("no-builtins"), @@ -2873,10 +2872,6 @@ void ModuleImport::processFunctionAttributes(llvm::Function *func, attr.isStringAttribute()) funcOp.setPreferVectorWidth(attr.getValueAsString()); - if (llvm::Attribute attr = func->getFnAttribute("no-infs-fp-math"); - attr.isStringAttribute()) - funcOp.setNoInfsFpMath(attr.getValueAsBool()); - if (llvm::Attribute attr = func->getFnAttribute("no-nans-fp-math"); attr.isStringAttribute()) funcOp.setNoNansFpMath(attr.getValueAsBool()); diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index 7115386c18c13..217f398593e51 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -1569,9 +1569,6 @@ LogicalResult ModuleTranslation::convertOneFunction(LLVMFuncOp func) { getLLVMContext(), attr->getMinRange().getInt(), attr->getMaxRange().getInt())); - if (auto noInfsFpMath = func.getNoInfsFpMath()) - llvmFunc->addFnAttr("no-infs-fp-math", llvm::toStringRef(*noInfsFpMath)); - if (auto noNansFpMath = func.getNoNansFpMath()) llvmFunc->addFnAttr("no-nans-fp-math", llvm::toStringRef(*noNansFpMath)); diff --git a/mlir/test/Target/LLVMIR/Import/function-attributes.ll b/mlir/test/Target/LLVMIR/Import/function-attributes.ll index 6b04f6e5c5622..6a9a1cffab4e8 100644 --- a/mlir/test/Target/LLVMIR/Import/function-attributes.ll +++ b/mlir/test/Target/LLVMIR/Import/function-attributes.ll @@ -303,18 +303,6 @@ declare void @align_decl() align 64 ; // ----- -; CHECK-LABEL: @func_attr_no_infs_fp_math_true -; CHECK-SAME: attributes {no_infs_fp_math = true} -declare void @func_attr_no_infs_fp_math_true() "no-infs-fp-math"="true" - -; // ----- - -; CHECK-LABEL: @func_attr_no_infs_fp_math_false -; CHECK-SAME: attributes {no_infs_fp_math = false} -declare void @func_attr_no_infs_fp_math_false() "no-infs-fp-math"="false" - -; // ----- - ; CHECK-LABEL: @func_attr_no_nans_fp_math_true ; CHECK-SAME: attributes {no_nans_fp_math = true} declare void @func_attr_no_nans_fp_math_true() "no-nans-fp-math"="true" diff --git a/mlir/test/Target/LLVMIR/fp-math-function-attributes.mlir b/mlir/test/Target/LLVMIR/fp-math-function-attributes.mlir index 6d563e46c62b3..19317a16467dd 100644 --- a/mlir/test/Target/LLVMIR/fp-math-function-attributes.mlir +++ b/mlir/test/Target/LLVMIR/fp-math-function-attributes.mlir @@ -1,23 +1,5 @@ // RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s -// CHECK-LABEL: define void @no_infs_fp_math_func_true() -// CHECK-SAME: #[[ATTRS:[0-9]+]] -llvm.func @no_infs_fp_math_func_true() attributes {no_infs_fp_math = true} { - llvm.return -} -// CHECK: attributes #[[ATTRS]] = { "no-infs-fp-math"="true" } - -// ----- - -// CHECK-LABEL: define void @no_infs_fp_math_func_false() -// CHECK-SAME: #[[ATTRS:[0-9]+]] -llvm.func @no_infs_fp_math_func_false() attributes {no_infs_fp_math = false} { - llvm.return -} -// CHECK: attributes #[[ATTRS]] = { "no-infs-fp-math"="false" } - -// ----- - // CHECK-LABEL: define void @no_nans_fp_math_func_true() // CHECK-SAME: #[[ATTRS:[0-9]+]] llvm.func @no_nans_fp_math_func_true() attributes {no_nans_fp_math = true} { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
