Skip to content

Commit 8eb6757

Browse files
[NFC] Turn the StrictFP attribute check to a CompatRule. (#82600)
1 parent 9e7c0b1 commit 8eb6757

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

llvm/include/llvm/IR/Attributes.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ def : CompatRule<"isEqual<ShadowCallStackAttr>">;
371371
def : CompatRule<"isEqual<UseSampleProfileAttr>">;
372372
def : CompatRule<"isEqual<NoProfileAttr>">;
373373
def : CompatRule<"checkDenormMode">;
374+
def : CompatRule<"checkStrictFP">;
374375
def : CompatRuleStrAttr<"isEqual", "sign-return-address">;
375376
def : CompatRuleStrAttr<"isEqual", "sign-return-address-key">;
376377
def : CompatRuleStrAttr<"isEqual", "branch-protection-pauth-lr">;

llvm/lib/IR/Attributes.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,6 +2039,13 @@ static bool checkDenormMode(const Function &Caller, const Function &Callee) {
20392039
return false;
20402040
}
20412041

2042+
static bool checkStrictFP(const Function &Caller, const Function &Callee) {
2043+
// Do not inline strictfp function into non-strictfp one. It would require
2044+
// conversion of all FP operations in host function to constrained intrinsics.
2045+
return !Callee.getAttributes().hasFnAttr(Attribute::StrictFP) ||
2046+
Caller.getAttributes().hasFnAttr(Attribute::StrictFP);
2047+
}
2048+
20422049
template<typename AttrClass>
20432050
static bool isEqual(const Function &Caller, const Function &Callee) {
20442051
return Caller.getFnAttribute(AttrClass::getKind()) ==

llvm/lib/Transforms/Utils/InlineFunction.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,13 +2103,6 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
21032103
BasicBlock *OrigBB = CB.getParent();
21042104
Function *Caller = OrigBB->getParent();
21052105

2106-
// Do not inline strictfp function into non-strictfp one. It would require
2107-
// conversion of all FP operations in host function to constrained intrinsics.
2108-
if (CalledFunc->getAttributes().hasFnAttr(Attribute::StrictFP) &&
2109-
!Caller->getAttributes().hasFnAttr(Attribute::StrictFP)) {
2110-
return InlineResult::failure("incompatible strictfp attributes");
2111-
}
2112-
21132106
// GC poses two hazards to inlining, which only occur when the callee has GC:
21142107
// 1. If the caller has no GC, then the callee's GC must be propagated to the
21152108
// caller.

0 commit comments

Comments
 (0)