[NFC] Rename AttributeList::getParam/Ret/FnAttributes() -> get*Attributes()

This is more consistent with similar methods.
This commit is contained in:
Arthur Eubanks 2021-08-13 11:16:52 -07:00
parent 92ce6db9ee
commit 80ea2bb574
32 changed files with 117 additions and 120 deletions

View File

@ -4749,7 +4749,7 @@ static void replaceUsesOfNonProtoConstant(llvm::Constant *old,
}
// Add any parameter attributes.
newArgAttrs.push_back(oldAttrs.getParamAttributes(argNo));
newArgAttrs.push_back(oldAttrs.getParamAttrs(argNo));
argNo++;
}
if (dontTransform)
@ -4777,9 +4777,9 @@ static void replaceUsesOfNonProtoConstant(llvm::Constant *old,
if (!newCall->getType()->isVoidTy())
newCall->takeName(callSite);
newCall->setAttributes(llvm::AttributeList::get(
newFn->getContext(), oldAttrs.getFnAttributes(),
oldAttrs.getRetAttributes(), newArgAttrs));
newCall->setAttributes(
llvm::AttributeList::get(newFn->getContext(), oldAttrs.getFnAttrs(),
oldAttrs.getRetAttrs(), newArgAttrs));
newCall->setCallingConv(callSite->getCallingConv());
// Finally, remove the old call, replacing any uses with the new one.

View File

@ -238,7 +238,7 @@ public:
else {
// Disable individual libc/libm calls in TargetLibraryInfo.
LibFunc LF;
AttributeSet FnAttrs = (*F)->getAttributes().getFnAttributes();
AttributeSet FnAttrs = (*F)->getAttributes().getFnAttrs();
for (const Attribute &Attr : FnAttrs) {
if (!Attr.isStringAttribute())
continue;

View File

@ -620,13 +620,13 @@ public:
/// The attributes for the argument or parameter at the given index are
/// returned.
AttributeSet getParamAttributes(unsigned ArgNo) const;
AttributeSet getParamAttrs(unsigned ArgNo) const;
/// The attributes for the ret value are returned.
AttributeSet getRetAttributes() const;
AttributeSet getRetAttrs() const;
/// The function attributes are returned.
AttributeSet getFnAttributes() const;
AttributeSet getFnAttrs() const;
/// Return true if the attribute exists at the given index.
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const;

View File

@ -140,7 +140,7 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
if (Function *Fn = dyn_cast<Function>(V)) {
AttributeList AS = Fn->getAttributes();
AttrBuilder FnAttrs(AS.getFnAttributes());
AttrBuilder FnAttrs(AS.getFnAttrs());
AS = AS.removeAttributes(Context, AttributeList::FunctionIndex);
FnAttrs.merge(B);
@ -157,7 +157,7 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
Fn->setAttributes(AS);
} else if (CallInst *CI = dyn_cast<CallInst>(V)) {
AttributeList AS = CI->getAttributes();
AttrBuilder FnAttrs(AS.getFnAttributes());
AttrBuilder FnAttrs(AS.getFnAttrs());
AS = AS.removeAttributes(Context, AttributeList::FunctionIndex);
FnAttrs.merge(B);
AS = AS.addAttributes(Context, AttributeList::FunctionIndex,
@ -165,7 +165,7 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
CI->setAttributes(AS);
} else if (InvokeInst *II = dyn_cast<InvokeInst>(V)) {
AttributeList AS = II->getAttributes();
AttrBuilder FnAttrs(AS.getFnAttributes());
AttrBuilder FnAttrs(AS.getFnAttrs());
AS = AS.removeAttributes(Context, AttributeList::FunctionIndex);
FnAttrs.merge(B);
AS = AS.addAttributes(Context, AttributeList::FunctionIndex,
@ -173,7 +173,7 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
II->setAttributes(AS);
} else if (CallBrInst *CBI = dyn_cast<CallBrInst>(V)) {
AttributeList AS = CBI->getAttributes();
AttrBuilder FnAttrs(AS.getFnAttributes());
AttrBuilder FnAttrs(AS.getFnAttrs());
AS = AS.removeAttributes(Context, AttributeList::FunctionIndex);
FnAttrs.merge(B);
AS = AS.addAttributes(Context, AttributeList::FunctionIndex,

View File

@ -3270,7 +3270,7 @@ Error BitcodeReader::parseGlobalVarRecord(ArrayRef<uint64_t> Record) {
}
if (Record.size() > 12) {
auto AS = getAttributes(Record[12]).getFnAttributes();
auto AS = getAttributes(Record[12]).getFnAttrs();
NewGV->setAttributes(AS);
}

View File

@ -44,11 +44,11 @@ void OpenMPIRBuilder::addAttributes(omp::RuntimeFunction FnID, Function &Fn) {
// Get the function's current attributes.
auto Attrs = Fn.getAttributes();
auto FnAttrs = Attrs.getFnAttributes();
auto RetAttrs = Attrs.getRetAttributes();
auto FnAttrs = Attrs.getFnAttrs();
auto RetAttrs = Attrs.getRetAttrs();
SmallVector<AttributeSet, 4> ArgAttrs;
for (size_t ArgNo = 0; ArgNo < Fn.arg_size(); ++ArgNo)
ArgAttrs.emplace_back(Attrs.getParamAttributes(ArgNo));
ArgAttrs.emplace_back(Attrs.getParamAttrs(ArgNo));
#define OMP_ATTRS_SET(VarName, AttrSet) AttributeSet VarName = AttrSet;
#include "llvm/Frontend/OpenMP/OMPKinds.def"

View File

@ -988,7 +988,7 @@ void SlotTracker::processModule() {
// Add all the function attributes to the table.
// FIXME: Add attributes of other objects?
AttributeSet FnAttrs = F.getAttributes().getFnAttributes();
AttributeSet FnAttrs = F.getAttributes().getFnAttrs();
if (FnAttrs.hasAttributes())
CreateAttributeSetSlot(FnAttrs);
}
@ -1029,7 +1029,7 @@ void SlotTracker::processFunction() {
// target may not be linked into the optimizer.
if (const auto *Call = dyn_cast<CallBase>(&I)) {
// Add all the call attributes to the table.
AttributeSet Attrs = Call->getAttributes().getFnAttributes();
AttributeSet Attrs = Call->getAttributes().getFnAttrs();
if (Attrs.hasAttributes())
CreateAttributeSetSlot(Attrs);
}
@ -3683,7 +3683,7 @@ void AssemblyWriter::printFunction(const Function *F) {
const AttributeList &Attrs = F->getAttributes();
if (Attrs.hasAttributes(AttributeList::FunctionIndex)) {
AttributeSet AS = Attrs.getFnAttributes();
AttributeSet AS = Attrs.getFnAttrs();
std::string AttrStr;
for (const Attribute &Attr : AS) {
@ -3737,7 +3737,7 @@ void AssemblyWriter::printFunction(const Function *F) {
// Output type...
TypePrinter.print(FT->getParamType(I), Out);
AttributeSet ArgAttrs = Attrs.getParamAttributes(I);
AttributeSet ArgAttrs = Attrs.getParamAttrs(I);
if (ArgAttrs.hasAttributes()) {
Out << ' ';
writeAttributeSet(ArgAttrs);
@ -3749,7 +3749,7 @@ void AssemblyWriter::printFunction(const Function *F) {
// Insert commas as we go... the first arg doesn't get a comma
if (Arg.getArgNo() != 0)
Out << ", ";
printArgument(&Arg, Attrs.getParamAttributes(Arg.getArgNo()));
printArgument(&Arg, Attrs.getParamAttrs(Arg.getArgNo()));
}
}
@ -3770,7 +3770,7 @@ void AssemblyWriter::printFunction(const Function *F) {
Mod->getDataLayout().getProgramAddressSpace() != 0)
Out << " addrspace(" << F->getAddressSpace() << ")";
if (Attrs.hasAttributes(AttributeList::FunctionIndex))
Out << " #" << Machine.getAttributeGroupSlot(Attrs.getFnAttributes());
Out << " #" << Machine.getAttributeGroupSlot(Attrs.getFnAttrs());
if (F->hasSection()) {
Out << " section \"";
printEscapedString(F->getSection(), Out);
@ -4144,7 +4144,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
for (unsigned op = 0, Eop = CI->getNumArgOperands(); op < Eop; ++op) {
if (op > 0)
Out << ", ";
writeParamOperand(CI->getArgOperand(op), PAL.getParamAttributes(op));
writeParamOperand(CI->getArgOperand(op), PAL.getParamAttrs(op));
}
// Emit an ellipsis if this is a musttail call in a vararg function. This
@ -4156,7 +4156,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
Out << ')';
if (PAL.hasAttributes(AttributeList::FunctionIndex))
Out << " #" << Machine.getAttributeGroupSlot(PAL.getFnAttributes());
Out << " #" << Machine.getAttributeGroupSlot(PAL.getFnAttrs());
writeOperandBundles(CI);
} else if (const InvokeInst *II = dyn_cast<InvokeInst>(&I)) {
@ -4189,12 +4189,12 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
for (unsigned op = 0, Eop = II->getNumArgOperands(); op < Eop; ++op) {
if (op)
Out << ", ";
writeParamOperand(II->getArgOperand(op), PAL.getParamAttributes(op));
writeParamOperand(II->getArgOperand(op), PAL.getParamAttrs(op));
}
Out << ')';
if (PAL.hasAttributes(AttributeList::FunctionIndex))
Out << " #" << Machine.getAttributeGroupSlot(PAL.getFnAttributes());
Out << " #" << Machine.getAttributeGroupSlot(PAL.getFnAttrs());
writeOperandBundles(II);
@ -4229,12 +4229,12 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
for (unsigned op = 0, Eop = CBI->getNumArgOperands(); op < Eop; ++op) {
if (op)
Out << ", ";
writeParamOperand(CBI->getArgOperand(op), PAL.getParamAttributes(op));
writeParamOperand(CBI->getArgOperand(op), PAL.getParamAttrs(op));
}
Out << ')';
if (PAL.hasAttributes(AttributeList::FunctionIndex))
Out << " #" << Machine.getAttributeGroupSlot(PAL.getFnAttributes());
Out << " #" << Machine.getAttributeGroupSlot(PAL.getFnAttrs());
writeOperandBundles(CBI);

View File

@ -1372,15 +1372,15 @@ AttributeList AttributeList::addVScaleRangeAttr(LLVMContext &C, unsigned Index,
// AttributeList Accessor Methods
//===----------------------------------------------------------------------===//
AttributeSet AttributeList::getParamAttributes(unsigned ArgNo) const {
AttributeSet AttributeList::getParamAttrs(unsigned ArgNo) const {
return getAttributes(ArgNo + FirstArgIndex);
}
AttributeSet AttributeList::getRetAttributes() const {
AttributeSet AttributeList::getRetAttrs() const {
return getAttributes(ReturnIndex);
}
AttributeSet AttributeList::getFnAttributes() const {
AttributeSet AttributeList::getFnAttrs() const {
return getAttributes(FunctionIndex);
}

View File

@ -177,7 +177,7 @@ static Type *getMemoryParamAllocType(AttributeSet ParamAttrs, Type *ArgTy) {
uint64_t Argument::getPassPointeeByValueCopySize(const DataLayout &DL) const {
AttributeSet ParamAttrs =
getParent()->getAttributes().getParamAttributes(getArgNo());
getParent()->getAttributes().getParamAttrs(getArgNo());
if (Type *MemTy = getMemoryParamAllocType(ParamAttrs, getType()))
return DL.getTypeAllocSize(MemTy);
return 0;
@ -185,7 +185,7 @@ uint64_t Argument::getPassPointeeByValueCopySize(const DataLayout &DL) const {
Type *Argument::getPointeeInMemoryValueType() const {
AttributeSet ParamAttrs =
getParent()->getAttributes().getParamAttributes(getArgNo());
getParent()->getAttributes().getParamAttrs(getArgNo());
return getMemoryParamAllocType(ParamAttrs, getType());
}

View File

@ -1861,7 +1861,7 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
bool SawSwiftError = false;
// Verify return value attributes.
AttributeSet RetAttrs = Attrs.getRetAttributes();
AttributeSet RetAttrs = Attrs.getRetAttrs();
for (Attribute RetAttr : RetAttrs)
Assert(RetAttr.isStringAttribute() ||
Attribute::canUseAsRetAttr(RetAttr.getKindAsEnum()),
@ -1874,7 +1874,7 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
// Verify parameter attributes.
for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
Type *Ty = FT->getParamType(i);
AttributeSet ArgAttrs = Attrs.getParamAttributes(i);
AttributeSet ArgAttrs = Attrs.getParamAttrs(i);
if (!IsIntrinsic) {
Assert(!ArgAttrs.hasAttribute(Attribute::ImmArg),
@ -1931,8 +1931,8 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
if (!Attrs.hasAttributes(AttributeList::FunctionIndex))
return;
verifyAttributeTypes(Attrs.getFnAttributes(), V);
for (Attribute FnAttr : Attrs.getFnAttributes())
verifyAttributeTypes(Attrs.getFnAttrs(), V);
for (Attribute FnAttr : Attrs.getFnAttrs())
Assert(FnAttr.isStringAttribute() ||
Attribute::canUseAsFnAttr(FnAttr.getKindAsEnum()),
"Attribute '" + FnAttr.getAsString() +
@ -2168,7 +2168,7 @@ void Verifier::verifyStatepoint(const CallBase &Call) {
Call);
if (TargetFuncType->isVarArg()) {
AttributeSet ArgAttrs = Attrs.getParamAttributes(5 + i);
AttributeSet ArgAttrs = Attrs.getParamAttrs(5 + i);
Assert(!ArgAttrs.hasAttribute(Attribute::StructRet),
"Attribute 'sret' cannot be used for vararg call arguments!",
Call);
@ -3159,7 +3159,7 @@ void Verifier::visitCallBase(CallBase &Call) {
// Check attributes on the varargs part.
for (unsigned Idx = FTy->getNumParams(); Idx < Call.arg_size(); ++Idx) {
Type *Ty = Call.getArgOperand(Idx)->getType();
AttributeSet ArgAttrs = Attrs.getParamAttributes(Idx);
AttributeSet ArgAttrs = Attrs.getParamAttrs(Idx);
verifyParameterAttrs(ArgAttrs, Ty, &Call);
if (ArgAttrs.hasAttribute(Attribute::Nest)) {
@ -3323,7 +3323,7 @@ static AttrBuilder getParameterABIAttributes(int I, AttributeList Attrs) {
Attribute::ByRef};
AttrBuilder Copy;
for (auto AK : ABIAttrs) {
Attribute Attr = Attrs.getParamAttributes(I).getAttribute(AK);
Attribute Attr = Attrs.getParamAttrs(I).getAttribute(AK);
if (Attr.isValid())
Copy.addAttribute(Attr);
}

View File

@ -5241,8 +5241,7 @@ PPCInstrInfo::isSignOrZeroExtended(const MachineInstr &MI, bool SignExt,
return false;
const IntegerType *IntTy =
dyn_cast<IntegerType>(CalleeFn->getReturnType());
const AttributeSet &Attrs =
CalleeFn->getAttributes().getRetAttributes();
const AttributeSet &Attrs = CalleeFn->getAttributes().getRetAttrs();
if (IntTy && IntTy->getBitWidth() <= 32)
return Attrs.hasAttribute(SignExt ? Attribute::SExt :
Attribute::ZExt);

View File

@ -450,9 +450,9 @@ Value *WebAssemblyLowerEmscriptenEHSjLj::wrapInvoke(CallBase *CI) {
ArgAttributes.push_back(AttributeSet());
// Copy the argument attributes from the original
for (unsigned I = 0, E = CI->getNumArgOperands(); I < E; ++I)
ArgAttributes.push_back(InvokeAL.getParamAttributes(I));
ArgAttributes.push_back(InvokeAL.getParamAttrs(I));
AttrBuilder FnAttrs(InvokeAL.getFnAttributes());
AttrBuilder FnAttrs(InvokeAL.getFnAttrs());
if (FnAttrs.contains(Attribute::AllocSize)) {
// The allocsize attribute (if any) referes to parameters by index and needs
// to be adjusted.
@ -466,9 +466,8 @@ Value *WebAssemblyLowerEmscriptenEHSjLj::wrapInvoke(CallBase *CI) {
}
// Reconstruct the AttributesList based on the vector we constructed.
AttributeList NewCallAL =
AttributeList::get(C, AttributeSet::get(C, FnAttrs),
InvokeAL.getRetAttributes(), ArgAttributes);
AttributeList NewCallAL = AttributeList::get(
C, AttributeSet::get(C, FnAttrs), InvokeAL.getRetAttrs(), ArgAttributes);
NewCall->setAttributes(NewCallAL);
CI->replaceAllUsesWith(NewCall);

View File

@ -907,7 +907,7 @@ void CoroCloner::create() {
// Bootstrap attributes by copying function attributes from the
// original function. This should include optimization settings and so on.
NewAttrs = NewAttrs.addAttributes(Context, AttributeList::FunctionIndex,
OrigAttrs.getFnAttributes());
OrigAttrs.getFnAttrs());
addFramePointerAttrs(NewAttrs, Context, 0,
Shape.FrameSize, Shape.FrameAlign);
@ -929,7 +929,7 @@ void CoroCloner::create() {
}
// Transfer the original function's attributes.
auto FnAttrs = OrigF.getAttributes().getFnAttributes();
auto FnAttrs = OrigF.getAttributes().getFnAttrs();
NewAttrs =
NewAttrs.addAttributes(Context, AttributeList::FunctionIndex, FnAttrs);
break;

View File

@ -148,7 +148,7 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
} else if (!ArgsToPromote.count(&*I)) {
// Unchanged argument
Params.push_back(I->getType());
ArgAttrVec.push_back(PAL.getParamAttributes(ArgNo));
ArgAttrVec.push_back(PAL.getParamAttrs(ArgNo));
} else if (I->use_empty()) {
// Dead argument (which are always marked as promotable)
++NumArgumentsDead;
@ -231,8 +231,8 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
// Recompute the parameter attributes list based on the new arguments for
// the function.
NF->setAttributes(AttributeList::get(F->getContext(), PAL.getFnAttributes(),
PAL.getRetAttributes(), ArgAttrVec));
NF->setAttributes(AttributeList::get(F->getContext(), PAL.getFnAttrs(),
PAL.getRetAttrs(), ArgAttrVec));
ArgAttrVec.clear();
F->getParent()->getFunctionList().insert(F->getIterator(), NF);
@ -257,7 +257,7 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
++I, ++AI, ++ArgNo)
if (!ArgsToPromote.count(&*I) && !ByValArgsToTransform.count(&*I)) {
Args.push_back(*AI); // Unmodified argument
ArgAttrVec.push_back(CallPAL.getParamAttributes(ArgNo));
ArgAttrVec.push_back(CallPAL.getParamAttrs(ArgNo));
} else if (ByValArgsToTransform.count(&*I)) {
// Emit a GEP and load for each element of the struct.
Type *AgTy = I->getParamByValType();
@ -325,7 +325,7 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
// Push any varargs arguments on the list.
for (; AI != CB.arg_end(); ++AI, ++ArgNo) {
Args.push_back(*AI);
ArgAttrVec.push_back(CallPAL.getParamAttributes(ArgNo));
ArgAttrVec.push_back(CallPAL.getParamAttrs(ArgNo));
}
SmallVector<OperandBundleDef, 1> OpBundles;
@ -341,9 +341,9 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
NewCS = NewCall;
}
NewCS->setCallingConv(CB.getCallingConv());
NewCS->setAttributes(
AttributeList::get(F->getContext(), CallPAL.getFnAttributes(),
CallPAL.getRetAttributes(), ArgAttrVec));
NewCS->setAttributes(AttributeList::get(F->getContext(),
CallPAL.getFnAttrs(),
CallPAL.getRetAttrs(), ArgAttrVec));
NewCS->copyMetadata(CB, {LLVMContext::MD_prof, LLVMContext::MD_dbg});
Args.clear();
ArgAttrVec.clear();

View File

@ -2159,7 +2159,7 @@ ChangeStatus Attributor::rewriteFunctionSignatures(
} else {
NewArgumentTypes.push_back(Arg.getType());
NewArgumentAttributes.push_back(
OldFnAttributeList.getParamAttributes(Arg.getArgNo()));
OldFnAttributeList.getParamAttrs(Arg.getArgNo()));
}
}
@ -2190,8 +2190,8 @@ ChangeStatus Attributor::rewriteFunctionSignatures(
// the function.
LLVMContext &Ctx = OldFn->getContext();
NewFn->setAttributes(AttributeList::get(
Ctx, OldFnAttributeList.getFnAttributes(),
OldFnAttributeList.getRetAttributes(), NewArgumentAttributes));
Ctx, OldFnAttributeList.getFnAttrs(), OldFnAttributeList.getRetAttrs(),
NewArgumentAttributes));
// Since we have now created the new function, splice the body of the old
// function right into the new function, leaving the old rotting hulk of the
@ -2236,7 +2236,7 @@ ChangeStatus Attributor::rewriteFunctionSignatures(
} else {
NewArgOperands.push_back(ACS.getCallArgOperand(OldArgNum));
NewArgOperandAttributes.push_back(
OldCallAttributeList.getParamAttributes(OldArgNum));
OldCallAttributeList.getParamAttrs(OldArgNum));
}
}
@ -2266,8 +2266,8 @@ ChangeStatus Attributor::rewriteFunctionSignatures(
NewCB->setCallingConv(OldCB->getCallingConv());
NewCB->takeName(OldCB);
NewCB->setAttributes(AttributeList::get(
Ctx, OldCallAttributeList.getFnAttributes(),
OldCallAttributeList.getRetAttributes(), NewArgOperandAttributes));
Ctx, OldCallAttributeList.getFnAttrs(),
OldCallAttributeList.getRetAttrs(), NewArgOperandAttributes));
CallSitePairs.push_back({OldCB, NewCB});
return true;

View File

@ -188,9 +188,9 @@ bool DeadArgumentEliminationPass::DeleteDeadVarargs(Function &Fn) {
if (!PAL.isEmpty()) {
SmallVector<AttributeSet, 8> ArgAttrs;
for (unsigned ArgNo = 0; ArgNo < NumArgs; ++ArgNo)
ArgAttrs.push_back(PAL.getParamAttributes(ArgNo));
PAL = AttributeList::get(Fn.getContext(), PAL.getFnAttributes(),
PAL.getRetAttributes(), ArgAttrs);
ArgAttrs.push_back(PAL.getParamAttrs(ArgNo));
PAL = AttributeList::get(Fn.getContext(), PAL.getFnAttrs(),
PAL.getRetAttrs(), ArgAttrs);
}
SmallVector<OperandBundleDef, 1> OpBundles;
@ -762,7 +762,7 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
if (LiveValues.erase(Arg)) {
Params.push_back(I->getType());
ArgAlive[ArgI] = true;
ArgAttrVec.push_back(PAL.getParamAttributes(ArgI));
ArgAttrVec.push_back(PAL.getParamAttrs(ArgI));
HasLiveReturnedArg |= PAL.hasParamAttr(ArgI, Attribute::Returned);
} else {
++NumArgumentsEliminated;
@ -838,7 +838,7 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
assert(NRetTy && "No new return type found?");
// The existing function return attributes.
AttrBuilder RAttrs(PAL.getRetAttributes());
AttrBuilder RAttrs(PAL.getRetAttrs());
// Remove any incompatible attributes, but only if we removed all return
// values. Otherwise, ensure that we don't have any conflicting attributes
@ -853,8 +853,8 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
AttributeSet RetAttrs = AttributeSet::get(F->getContext(), RAttrs);
// Strip allocsize attributes. They might refer to the deleted arguments.
AttributeSet FnAttrs = PAL.getFnAttributes().removeAttribute(
F->getContext(), Attribute::AllocSize);
AttributeSet FnAttrs =
PAL.getFnAttrs().removeAttribute(F->getContext(), Attribute::AllocSize);
// Reconstruct the AttributesList based on the vector we constructed.
assert(ArgAttrVec.size() == Params.size());
@ -889,7 +889,7 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
// Adjust the call return attributes in case the function was changed to
// return void.
AttrBuilder RAttrs(CallPAL.getRetAttributes());
AttrBuilder RAttrs(CallPAL.getRetAttrs());
RAttrs.remove(AttributeFuncs::typeIncompatible(NRetTy));
AttributeSet RetAttrs = AttributeSet::get(F->getContext(), RAttrs);
@ -903,7 +903,7 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
if (ArgAlive[Pi]) {
Args.push_back(*I);
// Get original parameter attributes, but skip return attributes.
AttributeSet Attrs = CallPAL.getParamAttributes(Pi);
AttributeSet Attrs = CallPAL.getParamAttrs(Pi);
if (NRetTy != RetTy && Attrs.hasAttribute(Attribute::Returned)) {
// If the return type has changed, then get rid of 'returned' on the
// call site. The alternative is to make all 'returned' attributes on
@ -922,7 +922,7 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
// Push any varargs arguments on the list. Don't forget their attributes.
for (auto E = CB.arg_end(); I != E; ++I, ++Pi) {
Args.push_back(*I);
ArgAttrVec.push_back(CallPAL.getParamAttributes(Pi));
ArgAttrVec.push_back(CallPAL.getParamAttrs(Pi));
}
// Reconstruct the AttributesList based on the vector we constructed.
@ -930,7 +930,7 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
// Again, be sure to remove any allocsize attributes, since their indices
// may now be incorrect.
AttributeSet FnAttrs = CallPAL.getFnAttributes().removeAttribute(
AttributeSet FnAttrs = CallPAL.getFnAttrs().removeAttribute(
F->getContext(), Attribute::AllocSize);
AttributeList NewCallPAL = AttributeList::get(

View File

@ -1231,8 +1231,7 @@ static void fillOverallFunction(Module &M, OutlinableGroup &CurrentGroup,
*CurrentGroup.OutlinedFunction);
// Transfer the attributes from the function to the new function.
for (Attribute A :
CurrentOS->ExtractedFunction->getAttributes().getFnAttributes())
for (Attribute A : CurrentOS->ExtractedFunction->getAttributes().getFnAttrs())
CurrentGroup.OutlinedFunction->addFnAttr(A);
// Create an output block for the first extracted function.

View File

@ -1063,7 +1063,7 @@ private:
// Forward parameter attributes from the callback to the callee.
for (unsigned U = CallbackFirstArgOperand, E = CI->getNumArgOperands();
U < E; ++U)
for (const Attribute &A : CI->getAttributes().getParamAttributes(U))
for (const Attribute &A : CI->getAttributes().getParamAttrs(U))
NewCI->addParamAttr(
U - (CallbackFirstArgOperand - CallbackCalleeOperand), A);

View File

@ -181,9 +181,9 @@ void simplifyExternals(Module &M) {
F.getAddressSpace(), "", &M);
NewF->copyAttributesFrom(&F);
// Only copy function attribtues.
NewF->setAttributes(
AttributeList::get(M.getContext(), AttributeList::FunctionIndex,
F.getAttributes().getFnAttributes()));
NewF->setAttributes(AttributeList::get(M.getContext(),
AttributeList::FunctionIndex,
F.getAttributes().getFnAttrs()));
NewF->takeName(&F);
F.replaceAllUsesWith(ConstantExpr::getBitCast(NewF, F.getType()));
F.eraseFromParent();

View File

@ -1361,10 +1361,10 @@ void DevirtModule::applyICallBranchFunnel(VTableSlotInfo &SlotInfo,
M.getContext(), ArrayRef<Attribute>{Attribute::get(
M.getContext(), Attribute::Nest)}));
for (unsigned I = 0; I + 2 < Attrs.getNumAttrSets(); ++I)
NewArgAttrs.push_back(Attrs.getParamAttributes(I));
NewArgAttrs.push_back(Attrs.getParamAttrs(I));
NewCS->setAttributes(
AttributeList::get(M.getContext(), Attrs.getFnAttributes(),
Attrs.getRetAttributes(), NewArgAttrs));
AttributeList::get(M.getContext(), Attrs.getFnAttrs(),
Attrs.getRetAttrs(), NewArgAttrs));
CB.replaceAllUsesWith(NewCS);
CB.eraseFromParent();

View File

@ -2829,7 +2829,7 @@ bool InstCombinerImpl::transformConstExprCastCall(CallBase &Call) {
if (!CastInst::isBitOrNoopPointerCastable(ActTy, ParamTy, DL))
return false; // Cannot transform this parameter value.
if (AttrBuilder(CallerPAL.getParamAttributes(i))
if (AttrBuilder(CallerPAL.getParamAttrs(i))
.overlaps(AttributeFuncs::typeIncompatible(ParamTy)))
return false; // Attribute not compatible with transformed value.
@ -2912,11 +2912,11 @@ bool InstCombinerImpl::transformConstExprCastCall(CallBase &Call) {
// Add any parameter attributes.
if (CallerPAL.hasParamAttr(i, Attribute::ByVal)) {
AttrBuilder AB(CallerPAL.getParamAttributes(i));
AttrBuilder AB(CallerPAL.getParamAttrs(i));
AB.addByValAttr(NewArg->getType()->getPointerElementType());
ArgAttrs.push_back(AttributeSet::get(Ctx, AB));
} else
ArgAttrs.push_back(CallerPAL.getParamAttributes(i));
ArgAttrs.push_back(CallerPAL.getParamAttrs(i));
}
// If the function takes more arguments than the call was taking, add them
@ -2943,12 +2943,12 @@ bool InstCombinerImpl::transformConstExprCastCall(CallBase &Call) {
Args.push_back(NewArg);
// Add any parameter attributes.
ArgAttrs.push_back(CallerPAL.getParamAttributes(i));
ArgAttrs.push_back(CallerPAL.getParamAttrs(i));
}
}
}
AttributeSet FnAttrs = CallerPAL.getFnAttributes();
AttributeSet FnAttrs = CallerPAL.getFnAttrs();
if (NewRetTy->isVoidTy())
Caller->setName(""); // Void type should not have a name.
@ -3049,7 +3049,7 @@ InstCombinerImpl::transformCallThroughTrampoline(CallBase &Call,
for (FunctionType::param_iterator I = NestFTy->param_begin(),
E = NestFTy->param_end();
I != E; ++NestArgNo, ++I) {
AttributeSet AS = NestAttrs.getParamAttributes(NestArgNo);
AttributeSet AS = NestAttrs.getParamAttrs(NestArgNo);
if (AS.hasAttribute(Attribute::Nest)) {
// Record the parameter type and any other attributes.
NestTy = *I;
@ -3085,7 +3085,7 @@ InstCombinerImpl::transformCallThroughTrampoline(CallBase &Call,
// Add the original argument and attributes.
NewArgs.push_back(*I);
NewArgAttrs.push_back(Attrs.getParamAttributes(ArgNo));
NewArgAttrs.push_back(Attrs.getParamAttrs(ArgNo));
++ArgNo;
++I;
@ -3131,8 +3131,8 @@ InstCombinerImpl::transformCallThroughTrampoline(CallBase &Call,
NestF : ConstantExpr::getBitCast(NestF,
PointerType::getUnqual(NewFTy));
AttributeList NewPAL =
AttributeList::get(FTy->getContext(), Attrs.getFnAttributes(),
Attrs.getRetAttributes(), NewArgAttrs);
AttributeList::get(FTy->getContext(), Attrs.getFnAttrs(),
Attrs.getRetAttrs(), NewArgAttrs);
SmallVector<OperandBundleDef, 1> OpBundles;
Call.getOperandBundlesAsDefs(OpBundles);

View File

@ -349,18 +349,18 @@ transformFunctionAttributes(const TransformedFunction &TransformedFunction,
for (unsigned I = 0, IE = TransformedFunction.ArgumentIndexMapping.size();
I < IE; ++I) {
unsigned TransformedIndex = TransformedFunction.ArgumentIndexMapping[I];
ArgumentAttributes[TransformedIndex] = CallSiteAttrs.getParamAttributes(I);
ArgumentAttributes[TransformedIndex] = CallSiteAttrs.getParamAttrs(I);
}
// Copy annotations on varargs arguments.
for (unsigned I = TransformedFunction.OriginalType->getNumParams(),
IE = CallSiteAttrs.getNumAttrSets();
I < IE; ++I) {
ArgumentAttributes.push_back(CallSiteAttrs.getParamAttributes(I));
ArgumentAttributes.push_back(CallSiteAttrs.getParamAttrs(I));
}
return AttributeList::get(Ctx, CallSiteAttrs.getFnAttributes(),
CallSiteAttrs.getRetAttributes(),
return AttributeList::get(Ctx, CallSiteAttrs.getFnAttrs(),
CallSiteAttrs.getRetAttrs(),
llvm::makeArrayRef(ArgumentAttributes));
}

View File

@ -4176,7 +4176,7 @@ struct VarArgAMD64Helper : public VarArgHelper {
MemorySanitizerVisitor &MSV)
: F(F), MS(MS), MSV(MSV) {
AMD64FpEndOffset = AMD64FpEndOffsetSSE;
for (const auto &Attr : F.getAttributes().getFnAttributes()) {
for (const auto &Attr : F.getAttributes().getFnAttrs()) {
if (Attr.isStringAttribute() &&
(Attr.getKindAsString() == "target-features")) {
if (Attr.getValueAsString().contains("-sse"))

View File

@ -1377,11 +1377,11 @@ static AttributeList legalizeCallAttributes(LLVMContext &Ctx,
return AL;
// Remove the readonly, readnone, and statepoint function attributes.
AttrBuilder FnAttrs = AL.getFnAttributes();
AttrBuilder FnAttrs = AL.getFnAttrs();
for (auto Attr : FnAttrsToStrip)
FnAttrs.removeAttribute(Attr);
for (Attribute A : AL.getFnAttributes()) {
for (Attribute A : AL.getFnAttrs()) {
if (isStatepointDirectiveAttr(A))
FnAttrs.remove(A);
}
@ -1801,7 +1801,7 @@ makeStatepointExplicitImpl(CallBase *Call, /* to replace */
CallInst *GCResult = Builder.CreateGCResult(Token, Call->getType(), Name);
GCResult->setAttributes(
AttributeList::get(GCResult->getContext(), AttributeList::ReturnIndex,
Call->getAttributes().getRetAttributes()));
Call->getAttributes().getRetAttrs()));
// We cannot RAUW or delete CS.getInstruction() because it could be in the
// live set of some other safepoint, in which case that safepoint's

View File

@ -212,7 +212,7 @@ struct AssumeBuilderState {
if (!IsPoisonAttr || Call->isPassingUndefUB(Idx - 1))
addAttribute(Attr, Call->getArgOperand(Idx - 1));
}
for (Attribute Attr : AttrList.getFnAttributes())
for (Attribute Attr : AttrList.getFnAttrs())
addAttribute(Attr, nullptr);
};
addAttrList(Call->getAttributes());

View File

@ -485,7 +485,7 @@ CallBase &llvm::promoteCall(CallBase &CB, Function *Callee,
CB.setArgOperand(ArgNo, Cast);
// Remove any incompatible attributes for the argument.
AttrBuilder ArgAttrs(CallerPAL.getParamAttributes(ArgNo));
AttrBuilder ArgAttrs(CallerPAL.getParamAttrs(ArgNo));
ArgAttrs.remove(AttributeFuncs::typeIncompatible(FormalTy));
// If byval is used, this must be a pointer type, and the byval type must
@ -496,7 +496,7 @@ CallBase &llvm::promoteCall(CallBase &CB, Function *Callee,
NewArgAttrs.push_back(AttributeSet::get(Ctx, ArgAttrs));
AttributeChanged = true;
} else
NewArgAttrs.push_back(CallerPAL.getParamAttributes(ArgNo));
NewArgAttrs.push_back(CallerPAL.getParamAttrs(ArgNo));
}
// If the return type of the call site doesn't match that of the callee, cast
@ -511,7 +511,7 @@ CallBase &llvm::promoteCall(CallBase &CB, Function *Callee,
// Set the new callsite attribute.
if (AttributeChanged)
CB.setAttributes(AttributeList::get(Ctx, CallerPAL.getFnAttributes(),
CB.setAttributes(AttributeList::get(Ctx, CallerPAL.getFnAttrs(),
AttributeSet::get(Ctx, RAttrs),
NewArgAttrs));

View File

@ -116,13 +116,13 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
for (const Argument &OldArg : OldFunc->args()) {
if (Argument *NewArg = dyn_cast<Argument>(VMap[&OldArg])) {
NewArgAttrs[NewArg->getArgNo()] =
OldAttrs.getParamAttributes(OldArg.getArgNo());
OldAttrs.getParamAttrs(OldArg.getArgNo());
}
}
NewFunc->setAttributes(
AttributeList::get(NewFunc->getContext(), OldAttrs.getFnAttributes(),
OldAttrs.getRetAttributes(), NewArgAttrs));
AttributeList::get(NewFunc->getContext(), OldAttrs.getFnAttrs(),
OldAttrs.getRetAttrs(), NewArgAttrs));
// Everything else beyond this point deals with function instructions,
// so if we are dealing with a function declaration, we're done.

View File

@ -885,7 +885,7 @@ Function *CodeExtractor::constructFunction(const ValueSet &inputs,
// "target-features" attribute allowing it to be lowered.
// FIXME: This should be changed to check to see if a specific
// attribute can not be inherited.
for (const auto &Attr : oldFunction->getAttributes().getFnAttributes()) {
for (const auto &Attr : oldFunction->getAttributes().getFnAttrs()) {
if (Attr.isStringAttribute()) {
if (Attr.getKindAsString() == "thunk")
continue;

View File

@ -2102,7 +2102,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
for (unsigned i = CalledFunc->getFunctionType()->getNumParams();
i < CB.getNumArgOperands(); i++) {
VarArgsToForward.push_back(CB.getArgOperand(i));
VarArgsAttrs.push_back(CB.getAttributes().getParamAttributes(i));
VarArgsAttrs.push_back(CB.getAttributes().getParamAttrs(i));
}
bool InlinedMustTailCalls = false, InlinedDeoptimizeCalls = false;
@ -2135,13 +2135,13 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
if (!Attrs.isEmpty() || !VarArgsAttrs.empty()) {
for (unsigned ArgNo = 0;
ArgNo < CI->getFunctionType()->getNumParams(); ++ArgNo)
ArgAttrs.push_back(Attrs.getParamAttributes(ArgNo));
ArgAttrs.push_back(Attrs.getParamAttrs(ArgNo));
}
// Add VarArg attributes.
ArgAttrs.append(VarArgsAttrs.begin(), VarArgsAttrs.end());
Attrs = AttributeList::get(CI->getContext(), Attrs.getFnAttributes(),
Attrs.getRetAttributes(), ArgAttrs);
Attrs = AttributeList::get(CI->getContext(), Attrs.getFnAttrs(),
Attrs.getRetAttrs(), ArgAttrs);
// Add VarArgs to existing parameters.
SmallVector<Value *, 6> Params(CI->arg_operands());
Params.append(VarArgsToForward.begin(), VarArgsToForward.end());

View File

@ -577,9 +577,9 @@ Value *LibCallSimplifier::optimizeStrNCpy(CallInst *CI, IRBuilderBase &B) {
if (SrcLen == 0) {
// strncpy(x, "", y) -> memset(x, '\0', y)
Align MemSetAlign =
CI->getAttributes().getParamAttributes(0).getAlignment().valueOrOne();
CI->getAttributes().getParamAttrs(0).getAlignment().valueOrOne();
CallInst *NewCI = B.CreateMemSet(Dst, B.getInt8('\0'), Size, MemSetAlign);
AttrBuilder ArgAttrs(CI->getAttributes().getParamAttributes(0));
AttrBuilder ArgAttrs(CI->getAttributes().getParamAttrs(0));
NewCI->setAttributes(NewCI->getAttributes().addParamAttributes(
CI->getContext(), 0, ArgAttrs));
return Dst;

View File

@ -375,7 +375,7 @@ bool ReduceCrashingFunctionAttributes::TestFuncAttrs(
// Pass along the set of attributes that caused the crash.
Attrs.clear();
for (Attribute A : NewAttrs.getFnAttributes()) {
for (Attribute A : NewAttrs.getFnAttrs()) {
Attrs.push_back(A);
}
return true;
@ -1232,7 +1232,7 @@ static Error DebugACrash(BugDriver &BD, BugTester TestFn) {
assert(Fn && "Could not find function?");
std::vector<Attribute> Attrs;
for (Attribute A : Fn->getAttributes().getFnAttributes())
for (Attribute A : Fn->getAttributes().getFnAttrs())
Attrs.push_back(A);
OldSize += Attrs.size();

View File

@ -289,13 +289,13 @@ TEST_F(IRBuilderTest, ConstrainedFP) {
EXPECT_EQ(II->getIntrinsicID(), Intrinsic::experimental_constrained_fpext);
// Verify attributes on the call are created automatically.
AttributeSet CallAttrs = II->getAttributes().getFnAttributes();
AttributeSet CallAttrs = II->getAttributes().getFnAttrs();
EXPECT_EQ(CallAttrs.hasAttribute(Attribute::StrictFP), true);
// Verify attributes on the containing function are created when requested.
Builder.setConstrainedFPFunctionAttr();
AttributeList Attrs = BB->getParent()->getAttributes();
AttributeSet FnAttrs = Attrs.getFnAttributes();
AttributeSet FnAttrs = Attrs.getFnAttrs();
EXPECT_EQ(FnAttrs.hasAttribute(Attribute::StrictFP), true);
// Verify the codepaths for setting and overriding the default metadata.
@ -392,8 +392,8 @@ TEST_F(IRBuilderTest, ConstrainedFPFunctionCall) {
CallInst *FCall = Builder.CreateCall(Callee, None);
// Check the attributes to verify the strictfp attribute is on the call.
EXPECT_TRUE(FCall->getAttributes().getFnAttributes().hasAttribute(
Attribute::StrictFP));
EXPECT_TRUE(
FCall->getAttributes().getFnAttrs().hasAttribute(Attribute::StrictFP));
Builder.CreateRetVoid();
EXPECT_FALSE(verifyModule(*M));