[llvm] 8eb6757 - [NFC] Turn the StrictFP attribute check to a CompatRule. (#82600)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 25 06:50:09 PST 2024
Author: Dani
Date: 2024-02-25T15:50:05+01:00
New Revision: 8eb6757564ccea8f9fc3bb75480f1c1d1784415a
URL: https://github.com/llvm/llvm-project/commit/8eb6757564ccea8f9fc3bb75480f1c1d1784415a
DIFF: https://github.com/llvm/llvm-project/commit/8eb6757564ccea8f9fc3bb75480f1c1d1784415a.diff
LOG: [NFC] Turn the StrictFP attribute check to a CompatRule. (#82600)
Added:
Modified:
llvm/include/llvm/IR/Attributes.td
llvm/lib/IR/Attributes.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Attributes.td b/llvm/include/llvm/IR/Attributes.td
index d22eb76d2292d5..08afecf3201512 100644
--- a/llvm/include/llvm/IR/Attributes.td
+++ b/llvm/include/llvm/IR/Attributes.td
@@ -371,6 +371,7 @@ def : CompatRule<"isEqual<ShadowCallStackAttr>">;
def : CompatRule<"isEqual<UseSampleProfileAttr>">;
def : CompatRule<"isEqual<NoProfileAttr>">;
def : CompatRule<"checkDenormMode">;
+def : CompatRule<"checkStrictFP">;
def : CompatRuleStrAttr<"isEqual", "sign-return-address">;
def : CompatRuleStrAttr<"isEqual", "sign-return-address-key">;
def : CompatRuleStrAttr<"isEqual", "branch-protection-pauth-lr">;
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index 19076771ff2eaf..00acbbe7989d8a 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 78317df8a9caec..f68fdb26f28173 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