From 413a187856a6dde568df38ab755e68a1c8dda04b Mon Sep 17 00:00:00 2001 From: Michele Scandale Date: Wed, 24 Jun 2020 17:47:03 -0700 Subject: [PATCH] [Inliner] Handle 'no-signed-zeros-fp-math' function attribute. All other floating point math optimization related attribute are merged in a conservative way during function inlining. This commit adds the merge rule for the 'no-signed-zeros-fp-math' attribute. Differential Revision: https://reviews.llvm.org/D81714 --- llvm/include/llvm/IR/Attributes.td | 2 + llvm/test/Transforms/Inline/attributes.ll | 168 ++++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+) diff --git a/llvm/include/llvm/IR/Attributes.td b/llvm/include/llvm/IR/Attributes.td index ee48f40..3516ce2 100644 --- a/llvm/include/llvm/IR/Attributes.td +++ b/llvm/include/llvm/IR/Attributes.td @@ -233,6 +233,7 @@ def ZExt : EnumAttr<"zeroext">; 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 UnsafeFPMath : StrBoolAttr<"unsafe-fp-math">; def NoJumpTables : StrBoolAttr<"no-jump-tables">; def NoInlineLineTables : StrBoolAttr<"no-inline-line-tables">; @@ -270,6 +271,7 @@ class MergeRule { def : MergeRule<"setAND">; def : MergeRule<"setAND">; def : MergeRule<"setAND">; +def : MergeRule<"setAND">; def : MergeRule<"setAND">; def : MergeRule<"setOR">; def : MergeRule<"setOR">; diff --git a/llvm/test/Transforms/Inline/attributes.ll b/llvm/test/Transforms/Inline/attributes.ll index 5f27ac5..07d1b36 100644 --- a/llvm/test/Transforms/Inline/attributes.ll +++ b/llvm/test/Transforms/Inline/attributes.ll @@ -440,9 +440,177 @@ 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]+]] { +; CHECK-NEXT: ret i32 +} + +define i32 @no-nans-fp-math_callee1(i32 %i) "no-nans-fp-math"="true" { + ret i32 %i +; CHECK: @no-nans-fp-math_callee1(i32 %i) [[NO_NANS_FPMATH_TRUE:#[0-9]+]] { +; CHECK-NEXT: ret i32 +} + +define i32 @test_no-nans-fp-math0(i32 %i) "no-nans-fp-math"="false" { + %1 = call i32 @no-nans-fp-math_callee0(i32 %i) + ret i32 %1 +; CHECK: @test_no-nans-fp-math0(i32 %i) [[NO_NANS_FPMATH_FALSE]] { +; CHECK-NEXT: ret i32 +} + +define i32 @test_no-nans-fp-math1(i32 %i) "no-nans-fp-math"="false" { + %1 = call i32 @no-nans-fp-math_callee1(i32 %i) + ret i32 %1 +; CHECK: @test_no-nans-fp-math1(i32 %i) [[NO_NANS_FPMATH_FALSE]] { +; CHECK-NEXT: ret i32 +} + +define i32 @test_no-nans-fp-math2(i32 %i) "no-nans-fp-math"="true" { + %1 = call i32 @no-nans-fp-math_callee0(i32 %i) + ret i32 %1 +; CHECK: @test_no-nans-fp-math2(i32 %i) [[NO_NANS_FPMATH_FALSE]] { +; CHECK-NEXT: ret i32 +} + +define i32 @test_no-nans-fp-math3(i32 %i) "no-nans-fp-math"="true" { + %1 = call i32 @no-nans-fp-math_callee1(i32 %i) + ret i32 %1 +; CHECK: @test_no-nans-fp-math3(i32 %i) [[NO_NANS_FPMATH_TRUE]] { +; CHECK-NEXT: ret i32 +} + +define i32 @no-signed-zeros-fp-math_callee0(i32 %i) "no-signed-zeros-fp-math"="false" { + ret i32 %i +; CHECK: @no-signed-zeros-fp-math_callee0(i32 %i) [[NO_SIGNED_ZEROS_FPMATH_FALSE:#[0-9]+]] { +; CHECK-NEXT: ret i32 +} + +define i32 @no-signed-zeros-fp-math_callee1(i32 %i) "no-signed-zeros-fp-math"="true" { + ret i32 %i +; CHECK: @no-signed-zeros-fp-math_callee1(i32 %i) [[NO_SIGNED_ZEROS_FPMATH_TRUE:#[0-9]+]] { +; CHECK-NEXT: ret i32 +} + +define i32 @test_no-signed-zeros-fp-math0(i32 %i) "no-signed-zeros-fp-math"="false" { + %1 = call i32 @no-signed-zeros-fp-math_callee0(i32 %i) + ret i32 %1 +; CHECK: @test_no-signed-zeros-fp-math0(i32 %i) [[NO_SIGNED_ZEROS_FPMATH_FALSE]] { +; CHECK-NEXT: ret i32 +} + +define i32 @test_no-signed-zeros-fp-math1(i32 %i) "no-signed-zeros-fp-math"="false" { + %1 = call i32 @no-signed-zeros-fp-math_callee1(i32 %i) + ret i32 %1 +; CHECK: @test_no-signed-zeros-fp-math1(i32 %i) [[NO_SIGNED_ZEROS_FPMATH_FALSE]] { +; CHECK-NEXT: ret i32 +} + +define i32 @test_no-signed-zeros-fp-math2(i32 %i) "no-signed-zeros-fp-math"="true" { + %1 = call i32 @no-signed-zeros-fp-math_callee0(i32 %i) + ret i32 %1 +; CHECK: @test_no-signed-zeros-fp-math2(i32 %i) [[NO_SIGNED_ZEROS_FPMATH_FALSE]] { +; CHECK-NEXT: ret i32 +} + +define i32 @test_no-signed-zeros-fp-math3(i32 %i) "no-signed-zeros-fp-math"="true" { + %1 = call i32 @no-signed-zeros-fp-math_callee1(i32 %i) + ret i32 %1 +; CHECK: @test_no-signed-zeros-fp-math3(i32 %i) [[NO_SIGNED_ZEROS_FPMATH_TRUE]] { +; CHECK-NEXT: ret i32 +} + +define i32 @unsafe-fp-math_callee0(i32 %i) "unsafe-fp-math"="false" { + ret i32 %i +; CHECK: @unsafe-fp-math_callee0(i32 %i) [[UNSAFE_FPMATH_FALSE:#[0-9]+]] { +; CHECK-NEXT: ret i32 +} + +define i32 @unsafe-fp-math_callee1(i32 %i) "unsafe-fp-math"="true" { + ret i32 %i +; CHECK: @unsafe-fp-math_callee1(i32 %i) [[UNSAFE_FPMATH_TRUE:#[0-9]+]] { +; CHECK-NEXT: ret i32 +} + +define i32 @test_unsafe-fp-math0(i32 %i) "unsafe-fp-math"="false" { + %1 = call i32 @unsafe-fp-math_callee0(i32 %i) + ret i32 %1 +; CHECK: @test_unsafe-fp-math0(i32 %i) [[UNSAFE_FPMATH_FALSE]] { +; CHECK-NEXT: ret i32 +} + +define i32 @test_unsafe-fp-math1(i32 %i) "unsafe-fp-math"="false" { + %1 = call i32 @unsafe-fp-math_callee1(i32 %i) + ret i32 %1 +; CHECK: @test_unsafe-fp-math1(i32 %i) [[UNSAFE_FPMATH_FALSE]] { +; CHECK-NEXT: ret i32 +} + +define i32 @test_unsafe-fp-math2(i32 %i) "unsafe-fp-math"="true" { + %1 = call i32 @unsafe-fp-math_callee0(i32 %i) + ret i32 %1 +; CHECK: @test_unsafe-fp-math2(i32 %i) [[UNSAFE_FPMATH_FALSE]] { +; CHECK-NEXT: ret i32 +} + +define i32 @test_unsafe-fp-math3(i32 %i) "unsafe-fp-math"="true" { + %1 = call i32 @unsafe-fp-math_callee1(i32 %i) + ret i32 %1 +; CHECK: @test_unsafe-fp-math3(i32 %i) [[UNSAFE_FPMATH_TRUE]] { +; CHECK-NEXT: ret i32 +} + ; CHECK: attributes [[SLH]] = { speculative_load_hardening } ; CHECK: attributes [[FPMAD_FALSE]] = { "less-precise-fpmad"="false" } ; CHECK: attributes [[FPMAD_TRUE]] = { "less-precise-fpmad"="true" } ; 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" } +; CHECK: attributes [[NO_SIGNED_ZEROS_FPMATH_TRUE]] = { "no-signed-zeros-fp-math"="true" } +; CHECK: attributes [[UNSAFE_FPMATH_FALSE]] = { "unsafe-fp-math"="false" } +; CHECK: attributes [[UNSAFE_FPMATH_TRUE]] = { "unsafe-fp-math"="true" } -- 2.7.4