Skip to content

Commit

Permalink
[NFC] Turn the StrictFP attribute check to a CompatRule. (#82600)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielKristofKiss authored Feb 25, 2024
1 parent 9e7c0b1 commit 8eb6757
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions llvm/include/llvm/IR/Attributes.td
Original file line number Diff line number Diff line change
Expand Up @@ -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">;
Expand Down
7 changes: 7 additions & 0 deletions llvm/lib/IR/Attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) ==
Expand Down
7 changes: 0 additions & 7 deletions llvm/lib/Transforms/Utils/InlineFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 8eb6757

Please sign in to comment.