[llvm] [NFC] Turn the StrictFP attribute check to a CompatRule. (PR #82600)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 22 00:25:10 PST 2024
https://github.com/DanielKristofKiss created https://github.com/llvm/llvm-project/pull/82600
None
>From 2b4dfb10614708f16ecbfdeaf908fc6133f897b1 Mon Sep 17 00:00:00 2001
From: Daniel Kiss <daniel.kiss at arm.com>
Date: Thu, 22 Feb 2024 08:57:50 +0100
Subject: [PATCH] [NFC] Turn the StrictFP attribute check to a CompatRule.
---
llvm/include/llvm/IR/Attributes.td | 2 +-
llvm/lib/IR/Attributes.cpp | 7 +++++++
llvm/lib/Transforms/Utils/InlineFunction.cpp | 7 -------
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/llvm/include/llvm/IR/Attributes.td b/llvm/include/llvm/IR/Attributes.td
index 864f87f3383891..135eb09709313c 100644
--- a/llvm/include/llvm/IR/Attributes.td
+++ b/llvm/include/llvm/IR/Attributes.td
@@ -359,7 +359,7 @@ def : CompatRule<"isEqual<ShadowCallStackAttr>">;
def : CompatRule<"isEqual<UseSampleProfileAttr>">;
def : CompatRule<"isEqual<NoProfileAttr>">;
def : CompatRule<"checkDenormMode">;
-
+def : CompatRule<"checkStrictFP">;
class MergeRule<string F> {
// The name of the function called to merge the attributes of the caller and
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index fd5160209506f2..e6ffb231efbf42 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -2039,6 +2039,13 @@ static bool checkDenormMode(const Function &Caller, const Function &Callee) {
return false;
}
+static bool checkStrictFP(const Function &Caller, const Function &Callee) {
+ // Do not inline strictfp function into non-strictfp one. It would require
+ // conversion of all FP operations in host function to constrained intrinsics.
+ return !(Callee.getAttributes().hasFnAttr(Attribute::StrictFP) &&
+ !Caller.getAttributes().hasFnAttr(Attribute::StrictFP));
+}
+
template<typename AttrClass>
static bool isEqual(const Function &Caller, const Function &Callee) {
return Caller.getFnAttribute(AttrClass::getKind()) ==
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index d4d4bf5ebdf36e..6ea68497d7a6ed 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -2103,13 +2103,6 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
BasicBlock *OrigBB = CB.getParent();
Function *Caller = OrigBB->getParent();
- // Do not inline strictfp function into non-strictfp one. It would require
- // conversion of all FP operations in host function to constrained intrinsics.
- if (CalledFunc->getAttributes().hasFnAttr(Attribute::StrictFP) &&
- !Caller->getAttributes().hasFnAttr(Attribute::StrictFP)) {
- return InlineResult::failure("incompatible strictfp attributes");
- }
-
// GC poses two hazards to inlining, which only occur when the callee has GC:
// 1. If the caller has no GC, then the callee's GC must be propagated to the
// caller.
More information about the llvm-commits
mailing list