forked from OSchip/llvm-project
[IR] Prefer hasFnAttribute() where possible (NFC)
When checking for an enum function attribute, use hasFnAttribute() rather than hasAttribute() at FunctionIndex, because it is significantly faster (and more concise to boot).
This commit is contained in:
parent
51541c068a
commit
7cac7e0cfc
|
@ -4861,8 +4861,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
|
|||
CannotThrow = true;
|
||||
} else {
|
||||
// Otherwise, nounwind call sites will never throw.
|
||||
CannotThrow = Attrs.hasAttribute(llvm::AttributeList::FunctionIndex,
|
||||
llvm::Attribute::NoUnwind);
|
||||
CannotThrow = Attrs.hasFnAttribute(llvm::Attribute::NoUnwind);
|
||||
}
|
||||
|
||||
// If we made a temporary, be sure to clean up after ourselves. Note that we
|
||||
|
|
|
@ -2128,7 +2128,7 @@ private:
|
|||
bool hasFnAttrOnCalledFunction(StringRef Kind) const;
|
||||
|
||||
template <typename AttrKind> bool hasFnAttrImpl(AttrKind Kind) const {
|
||||
if (Attrs.hasAttribute(AttributeList::FunctionIndex, Kind))
|
||||
if (Attrs.hasFnAttribute(Kind))
|
||||
return true;
|
||||
|
||||
// Operand bundles override attributes on the called function, but don't
|
||||
|
|
|
@ -330,13 +330,13 @@ bool CallBase::paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
|
|||
|
||||
bool CallBase::hasFnAttrOnCalledFunction(Attribute::AttrKind Kind) const {
|
||||
if (const Function *F = getCalledFunction())
|
||||
return F->getAttributes().hasAttribute(AttributeList::FunctionIndex, Kind);
|
||||
return F->getAttributes().hasFnAttribute(Kind);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CallBase::hasFnAttrOnCalledFunction(StringRef Kind) const {
|
||||
if (const Function *F = getCalledFunction())
|
||||
return F->getAttributes().hasAttribute(AttributeList::FunctionIndex, Kind);
|
||||
return F->getAttributes().hasFnAttribute(Kind);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -2957,15 +2957,14 @@ void Verifier::visitCallBase(CallBase &Call) {
|
|||
Function *Callee =
|
||||
dyn_cast<Function>(Call.getCalledOperand()->stripPointerCasts());
|
||||
|
||||
if (Attrs.hasAttribute(AttributeList::FunctionIndex, Attribute::Speculatable)) {
|
||||
if (Attrs.hasFnAttribute(Attribute::Speculatable)) {
|
||||
// Don't allow speculatable on call sites, unless the underlying function
|
||||
// declaration is also speculatable.
|
||||
Assert(Callee && Callee->isSpeculatable(),
|
||||
"speculatable attribute may not apply to call sites", Call);
|
||||
}
|
||||
|
||||
if (Attrs.hasAttribute(AttributeList::FunctionIndex,
|
||||
Attribute::Preallocated)) {
|
||||
if (Attrs.hasFnAttribute(Attribute::Preallocated)) {
|
||||
Assert(Call.getCalledFunction()->getIntrinsicID() ==
|
||||
Intrinsic::call_preallocated_arg,
|
||||
"preallocated as a call site attribute can only be on "
|
||||
|
|
|
@ -14537,8 +14537,7 @@ bool AArch64TargetLowering::isIntDivCheap(EVT VT, AttributeList Attr) const {
|
|||
// integer division, leaving the division as-is is a loss even in terms of
|
||||
// size, because it will have to be scalarized, while the alternative code
|
||||
// sequence can be performed in vector form.
|
||||
bool OptSize =
|
||||
Attr.hasAttribute(AttributeList::FunctionIndex, Attribute::MinSize);
|
||||
bool OptSize = Attr.hasFnAttribute(Attribute::MinSize);
|
||||
return OptSize && !VT.isVector();
|
||||
}
|
||||
|
||||
|
|
|
@ -49486,8 +49486,7 @@ bool X86TargetLowering::isIntDivCheap(EVT VT, AttributeList Attr) const {
|
|||
// integer division, leaving the division as-is is a loss even in terms of
|
||||
// size, because it will have to be scalarized, while the alternative code
|
||||
// sequence can be performed in vector form.
|
||||
bool OptSize =
|
||||
Attr.hasAttribute(AttributeList::FunctionIndex, Attribute::MinSize);
|
||||
bool OptSize = Attr.hasFnAttribute(Attribute::MinSize);
|
||||
return OptSize && !VT.isVector();
|
||||
}
|
||||
|
||||
|
|
|
@ -92,9 +92,7 @@ static bool IsCallReturnTwice(llvm::MachineOperand &MOp) {
|
|||
if (!CalleeFn)
|
||||
return false;
|
||||
AttributeList Attrs = CalleeFn->getAttributes();
|
||||
if (Attrs.hasAttribute(AttributeList::FunctionIndex, Attribute::ReturnsTwice))
|
||||
return true;
|
||||
return false;
|
||||
return Attrs.hasFnAttribute(Attribute::ReturnsTwice);
|
||||
}
|
||||
|
||||
bool X86IndirectBranchTrackingPass::runOnMachineFunction(MachineFunction &MF) {
|
||||
|
|
Loading…
Reference in New Issue