mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
switch AttrListPtr::get to take an ArrayRef, simplifying a lot of clients.
llvm-svn: 157556
This commit is contained in:
parent
8467ec2e35
commit
afebb9fced
@ -16,6 +16,7 @@
|
||||
#define LLVM_ATTRIBUTES_H
|
||||
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
@ -268,16 +269,8 @@ public:
|
||||
// Attribute List Construction and Mutation
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
/// get - Return a Attributes list with the specified parameter in it.
|
||||
static AttrListPtr get(const AttributeWithIndex *Attr, unsigned NumAttrs);
|
||||
|
||||
/// get - Return a Attribute list with the parameters specified by the
|
||||
/// consecutive random access iterator range.
|
||||
template <typename Iter>
|
||||
static AttrListPtr get(const Iter &I, const Iter &E) {
|
||||
if (I == E) return AttrListPtr(); // Empty list.
|
||||
return get(&*I, static_cast<unsigned>(E-I));
|
||||
}
|
||||
/// get - Return a Attributes list with the specified parameters in it.
|
||||
static AttrListPtr get(ArrayRef<AttributeWithIndex> Attrs);
|
||||
|
||||
/// addAttr - Add the specified attribute at the specified index to this
|
||||
/// attribute list. Since attribute lists are immutable, this
|
||||
|
@ -2692,7 +2692,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
|
||||
if (FuncAttrs != Attribute::None)
|
||||
Attrs.push_back(AttributeWithIndex::get(~0, FuncAttrs));
|
||||
|
||||
AttrListPtr PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
|
||||
AttrListPtr PAL = AttrListPtr::get(Attrs);
|
||||
|
||||
if (PAL.paramHasAttr(1, Attribute::StructRet) && !RetType->isVoidTy())
|
||||
return Error(RetTypeLoc, "functions with 'sret' argument must return void");
|
||||
@ -3239,7 +3239,7 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
Attrs.push_back(AttributeWithIndex::get(~0, FnAttrs));
|
||||
|
||||
// Finish off the Attributes and check them
|
||||
AttrListPtr PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
|
||||
AttrListPtr PAL = AttrListPtr::get(Attrs);
|
||||
|
||||
InvokeInst *II = InvokeInst::Create(Callee, NormalBB, UnwindBB, Args);
|
||||
II->setCallingConv(CC);
|
||||
@ -3635,7 +3635,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
|
||||
Attrs.push_back(AttributeWithIndex::get(~0, FnAttrs));
|
||||
|
||||
// Finish off the Attributes and check them
|
||||
AttrListPtr PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
|
||||
AttrListPtr PAL = AttrListPtr::get(Attrs);
|
||||
|
||||
CallInst *CI = CallInst::Create(Callee, Args);
|
||||
CI->setTailCall(isTail);
|
||||
|
@ -486,7 +486,7 @@ bool BitcodeReader::ParseAttributeBlock() {
|
||||
Attributes(Record[i+1])));
|
||||
}
|
||||
|
||||
MAttributes.push_back(AttrListPtr::get(Attrs.begin(), Attrs.end()));
|
||||
MAttributes.push_back(AttrListPtr::get(Attrs));
|
||||
Attrs.clear();
|
||||
break;
|
||||
}
|
||||
|
@ -616,8 +616,7 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
||||
|
||||
// Recompute the parameter attributes list based on the new arguments for
|
||||
// the function.
|
||||
NF->setAttributes(AttrListPtr::get(AttributesVec.begin(),
|
||||
AttributesVec.end()));
|
||||
NF->setAttributes(AttrListPtr::get(AttributesVec));
|
||||
AttributesVec.clear();
|
||||
|
||||
F->getParent()->getFunctionList().insert(F, NF);
|
||||
@ -734,13 +733,11 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
|
||||
New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
|
||||
Args, "", Call);
|
||||
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
|
||||
cast<InvokeInst>(New)->setAttributes(AttrListPtr::get(AttributesVec.begin(),
|
||||
AttributesVec.end()));
|
||||
cast<InvokeInst>(New)->setAttributes(AttrListPtr::get(AttributesVec));
|
||||
} else {
|
||||
New = CallInst::Create(NF, Args, "", Call);
|
||||
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
|
||||
cast<CallInst>(New)->setAttributes(AttrListPtr::get(AttributesVec.begin(),
|
||||
AttributesVec.end()));
|
||||
cast<CallInst>(New)->setAttributes(AttrListPtr::get(AttributesVec));
|
||||
if (cast<CallInst>(Call)->isTailCall())
|
||||
cast<CallInst>(New)->setTailCall();
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
|
||||
AttributesVec.push_back(PAL.getSlot(i));
|
||||
if (Attributes FnAttrs = PAL.getFnAttributes())
|
||||
AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
|
||||
PAL = AttrListPtr::get(AttributesVec.begin(), AttributesVec.end());
|
||||
PAL = AttrListPtr::get(AttributesVec);
|
||||
}
|
||||
|
||||
Instruction *New;
|
||||
@ -753,8 +753,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
||||
AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
|
||||
|
||||
// Reconstruct the AttributesList based on the vector we constructed.
|
||||
AttrListPtr NewPAL = AttrListPtr::get(AttributesVec.begin(),
|
||||
AttributesVec.end());
|
||||
AttrListPtr NewPAL = AttrListPtr::get(AttributesVec);
|
||||
|
||||
// Create the new function type based on the recomputed parameters.
|
||||
FunctionType *NFTy = FunctionType::get(NRetTy, Params, FTy->isVarArg());
|
||||
@ -816,8 +815,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
|
||||
AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs));
|
||||
|
||||
// Reconstruct the AttributesList based on the vector we constructed.
|
||||
AttrListPtr NewCallPAL = AttrListPtr::get(AttributesVec.begin(),
|
||||
AttributesVec.end());
|
||||
AttrListPtr NewCallPAL = AttrListPtr::get(AttributesVec);
|
||||
|
||||
Instruction *New;
|
||||
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
|
||||
|
@ -1251,8 +1251,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
||||
if (NewRetTy->isVoidTy())
|
||||
Caller->setName(""); // Void type should not have a name.
|
||||
|
||||
const AttrListPtr &NewCallerPAL = AttrListPtr::get(attrVec.begin(),
|
||||
attrVec.end());
|
||||
const AttrListPtr &NewCallerPAL = AttrListPtr::get(attrVec);
|
||||
|
||||
Instruction *NC;
|
||||
if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
|
||||
@ -1424,8 +1423,7 @@ InstCombiner::transformCallThroughTrampoline(CallSite CS,
|
||||
NestF->getType() == PointerType::getUnqual(NewFTy) ?
|
||||
NestF : ConstantExpr::getBitCast(NestF,
|
||||
PointerType::getUnqual(NewFTy));
|
||||
const AttrListPtr &NewPAL = AttrListPtr::get(NewAttrs.begin(),
|
||||
NewAttrs.end());
|
||||
const AttrListPtr &NewPAL = AttrListPtr::get(NewAttrs);
|
||||
|
||||
Instruction *NewCaller;
|
||||
if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
|
||||
|
@ -42,7 +42,7 @@ Value *llvm::EmitStrLen(Value *Ptr, IRBuilder<> &B, const TargetData *TD) {
|
||||
Attribute::NoUnwind);
|
||||
|
||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||
Constant *StrLen = M->getOrInsertFunction("strlen", AttrListPtr::get(AWI, 2),
|
||||
Constant *StrLen = M->getOrInsertFunction("strlen", AttrListPtr::get(AWI),
|
||||
TD->getIntPtrType(Context),
|
||||
B.getInt8PtrTy(),
|
||||
NULL);
|
||||
@ -64,7 +64,7 @@ Value *llvm::EmitStrChr(Value *Ptr, char C, IRBuilder<> &B,
|
||||
|
||||
Type *I8Ptr = B.getInt8PtrTy();
|
||||
Type *I32Ty = B.getInt32Ty();
|
||||
Constant *StrChr = M->getOrInsertFunction("strchr", AttrListPtr::get(&AWI, 1),
|
||||
Constant *StrChr = M->getOrInsertFunction("strchr", AttrListPtr::get(AWI),
|
||||
I8Ptr, I8Ptr, I32Ty, NULL);
|
||||
CallInst *CI = B.CreateCall2(StrChr, CastToCStr(Ptr, B),
|
||||
ConstantInt::get(I32Ty, C), "strchr");
|
||||
@ -84,7 +84,7 @@ Value *llvm::EmitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len,
|
||||
Attribute::NoUnwind);
|
||||
|
||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||
Value *StrNCmp = M->getOrInsertFunction("strncmp", AttrListPtr::get(AWI, 3),
|
||||
Value *StrNCmp = M->getOrInsertFunction("strncmp", AttrListPtr::get(AWI),
|
||||
B.getInt32Ty(),
|
||||
B.getInt8PtrTy(),
|
||||
B.getInt8PtrTy(),
|
||||
@ -107,7 +107,7 @@ Value *llvm::EmitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B,
|
||||
AWI[0] = AttributeWithIndex::get(2, Attribute::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(~0u, Attribute::NoUnwind);
|
||||
Type *I8Ptr = B.getInt8PtrTy();
|
||||
Value *StrCpy = M->getOrInsertFunction(Name, AttrListPtr::get(AWI, 2),
|
||||
Value *StrCpy = M->getOrInsertFunction(Name, AttrListPtr::get(AWI),
|
||||
I8Ptr, I8Ptr, I8Ptr, NULL);
|
||||
CallInst *CI = B.CreateCall2(StrCpy, CastToCStr(Dst, B), CastToCStr(Src, B),
|
||||
Name);
|
||||
@ -125,7 +125,7 @@ Value *llvm::EmitStrNCpy(Value *Dst, Value *Src, Value *Len,
|
||||
AWI[0] = AttributeWithIndex::get(2, Attribute::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(~0u, Attribute::NoUnwind);
|
||||
Type *I8Ptr = B.getInt8PtrTy();
|
||||
Value *StrNCpy = M->getOrInsertFunction(Name, AttrListPtr::get(AWI, 2),
|
||||
Value *StrNCpy = M->getOrInsertFunction(Name, AttrListPtr::get(AWI),
|
||||
I8Ptr, I8Ptr, I8Ptr,
|
||||
Len->getType(), NULL);
|
||||
CallInst *CI = B.CreateCall3(StrNCpy, CastToCStr(Dst, B), CastToCStr(Src, B),
|
||||
@ -145,7 +145,7 @@ Value *llvm::EmitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize,
|
||||
AWI = AttributeWithIndex::get(~0u, Attribute::NoUnwind);
|
||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||
Value *MemCpy = M->getOrInsertFunction("__memcpy_chk",
|
||||
AttrListPtr::get(&AWI, 1),
|
||||
AttrListPtr::get(AWI),
|
||||
B.getInt8PtrTy(),
|
||||
B.getInt8PtrTy(),
|
||||
B.getInt8PtrTy(),
|
||||
@ -167,7 +167,7 @@ Value *llvm::EmitMemChr(Value *Ptr, Value *Val,
|
||||
AttributeWithIndex AWI;
|
||||
AWI = AttributeWithIndex::get(~0u, Attribute::ReadOnly | Attribute::NoUnwind);
|
||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||
Value *MemChr = M->getOrInsertFunction("memchr", AttrListPtr::get(&AWI, 1),
|
||||
Value *MemChr = M->getOrInsertFunction("memchr", AttrListPtr::get(AWI),
|
||||
B.getInt8PtrTy(),
|
||||
B.getInt8PtrTy(),
|
||||
B.getInt32Ty(),
|
||||
@ -192,7 +192,7 @@ Value *llvm::EmitMemCmp(Value *Ptr1, Value *Ptr2,
|
||||
Attribute::NoUnwind);
|
||||
|
||||
LLVMContext &Context = B.GetInsertBlock()->getContext();
|
||||
Value *MemCmp = M->getOrInsertFunction("memcmp", AttrListPtr::get(AWI, 3),
|
||||
Value *MemCmp = M->getOrInsertFunction("memcmp", AttrListPtr::get(AWI),
|
||||
B.getInt32Ty(),
|
||||
B.getInt8PtrTy(),
|
||||
B.getInt8PtrTy(),
|
||||
@ -260,7 +260,7 @@ void llvm::EmitPutS(Value *Str, IRBuilder<> &B, const TargetData *TD) {
|
||||
AWI[0] = AttributeWithIndex::get(1, Attribute::NoCapture);
|
||||
AWI[1] = AttributeWithIndex::get(~0u, Attribute::NoUnwind);
|
||||
|
||||
Value *PutS = M->getOrInsertFunction("puts", AttrListPtr::get(AWI, 2),
|
||||
Value *PutS = M->getOrInsertFunction("puts", AttrListPtr::get(AWI),
|
||||
B.getInt32Ty(),
|
||||
B.getInt8PtrTy(),
|
||||
NULL);
|
||||
@ -280,7 +280,7 @@ void llvm::EmitFPutC(Value *Char, Value *File, IRBuilder<> &B,
|
||||
AWI[1] = AttributeWithIndex::get(~0u, Attribute::NoUnwind);
|
||||
Constant *F;
|
||||
if (File->getType()->isPointerTy())
|
||||
F = M->getOrInsertFunction("fputc", AttrListPtr::get(AWI, 2),
|
||||
F = M->getOrInsertFunction("fputc", AttrListPtr::get(AWI),
|
||||
B.getInt32Ty(),
|
||||
B.getInt32Ty(), File->getType(),
|
||||
NULL);
|
||||
@ -309,7 +309,7 @@ void llvm::EmitFPutS(Value *Str, Value *File, IRBuilder<> &B,
|
||||
StringRef FPutsName = TLI->getName(LibFunc::fputs);
|
||||
Constant *F;
|
||||
if (File->getType()->isPointerTy())
|
||||
F = M->getOrInsertFunction(FPutsName, AttrListPtr::get(AWI, 3),
|
||||
F = M->getOrInsertFunction(FPutsName, AttrListPtr::get(AWI),
|
||||
B.getInt32Ty(),
|
||||
B.getInt8PtrTy(),
|
||||
File->getType(), NULL);
|
||||
@ -337,7 +337,7 @@ void llvm::EmitFWrite(Value *Ptr, Value *Size, Value *File,
|
||||
StringRef FWriteName = TLI->getName(LibFunc::fwrite);
|
||||
Constant *F;
|
||||
if (File->getType()->isPointerTy())
|
||||
F = M->getOrInsertFunction(FWriteName, AttrListPtr::get(AWI, 3),
|
||||
F = M->getOrInsertFunction(FWriteName, AttrListPtr::get(AWI),
|
||||
TD->getIntPtrType(Context),
|
||||
B.getInt8PtrTy(),
|
||||
TD->getIntPtrType(Context),
|
||||
|
@ -131,8 +131,8 @@ class AttributeListImpl : public FoldingSetNode {
|
||||
public:
|
||||
SmallVector<AttributeWithIndex, 4> Attrs;
|
||||
|
||||
AttributeListImpl(const AttributeWithIndex *Attr, unsigned NumAttrs)
|
||||
: Attrs(Attr, Attr+NumAttrs) {
|
||||
AttributeListImpl(ArrayRef<AttributeWithIndex> attrs)
|
||||
: Attrs(attrs.begin(), attrs.end()) {
|
||||
RefCount = 0;
|
||||
}
|
||||
|
||||
@ -150,13 +150,12 @@ public:
|
||||
}
|
||||
|
||||
void Profile(FoldingSetNodeID &ID) const {
|
||||
Profile(ID, Attrs.data(), Attrs.size());
|
||||
Profile(ID, Attrs);
|
||||
}
|
||||
static void Profile(FoldingSetNodeID &ID, const AttributeWithIndex *Attr,
|
||||
unsigned NumAttrs) {
|
||||
for (unsigned i = 0; i != NumAttrs; ++i) {
|
||||
ID.AddInteger(Attr[i].Attrs.Raw());
|
||||
ID.AddInteger(Attr[i].Index);
|
||||
static void Profile(FoldingSetNodeID &ID, ArrayRef<AttributeWithIndex> Attrs){
|
||||
for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
|
||||
ID.AddInteger(Attrs[i].Attrs.Raw());
|
||||
ID.AddInteger(Attrs[i].Index);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -168,13 +167,13 @@ AttributeListImpl::~AttributeListImpl() {
|
||||
}
|
||||
|
||||
|
||||
AttrListPtr AttrListPtr::get(const AttributeWithIndex *Attrs, unsigned NumAttrs) {
|
||||
AttrListPtr AttrListPtr::get(ArrayRef<AttributeWithIndex> Attrs) {
|
||||
// If there are no attributes then return a null AttributesList pointer.
|
||||
if (NumAttrs == 0)
|
||||
if (Attrs.empty())
|
||||
return AttrListPtr();
|
||||
|
||||
#ifndef NDEBUG
|
||||
for (unsigned i = 0; i != NumAttrs; ++i) {
|
||||
for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
|
||||
assert(Attrs[i].Attrs != Attribute::None &&
|
||||
"Pointless attribute!");
|
||||
assert((!i || Attrs[i-1].Index < Attrs[i].Index) &&
|
||||
@ -184,7 +183,7 @@ AttrListPtr AttrListPtr::get(const AttributeWithIndex *Attrs, unsigned NumAttrs)
|
||||
|
||||
// Otherwise, build a key to look up the existing attributes.
|
||||
FoldingSetNodeID ID;
|
||||
AttributeListImpl::Profile(ID, Attrs, NumAttrs);
|
||||
AttributeListImpl::Profile(ID, Attrs);
|
||||
void *InsertPos;
|
||||
|
||||
sys::SmartScopedLock<true> Lock(*ALMutex);
|
||||
@ -195,7 +194,7 @@ AttrListPtr AttrListPtr::get(const AttributeWithIndex *Attrs, unsigned NumAttrs)
|
||||
// If we didn't find any existing attributes of the same shape then
|
||||
// create a new one and insert it.
|
||||
if (!PAL) {
|
||||
PAL = new AttributeListImpl(Attrs, NumAttrs);
|
||||
PAL = new AttributeListImpl(Attrs);
|
||||
AttributesLists->InsertNode(PAL, InsertPos);
|
||||
}
|
||||
|
||||
@ -308,7 +307,7 @@ AttrListPtr AttrListPtr::addAttr(unsigned Idx, Attributes Attrs) const {
|
||||
OldAttrList.begin()+i, OldAttrList.end());
|
||||
}
|
||||
|
||||
return get(NewAttrList.data(), NewAttrList.size());
|
||||
return get(NewAttrList);
|
||||
}
|
||||
|
||||
AttrListPtr AttrListPtr::removeAttr(unsigned Idx, Attributes Attrs) const {
|
||||
@ -343,7 +342,7 @@ AttrListPtr AttrListPtr::removeAttr(unsigned Idx, Attributes Attrs) const {
|
||||
NewAttrList.insert(NewAttrList.end(),
|
||||
OldAttrList.begin()+i, OldAttrList.end());
|
||||
|
||||
return get(NewAttrList.data(), NewAttrList.size());
|
||||
return get(NewAttrList);
|
||||
}
|
||||
|
||||
void AttrListPtr::dump() const {
|
||||
|
@ -590,7 +590,8 @@ EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS) {
|
||||
|
||||
OS << " }\n";
|
||||
OS << " }\n";
|
||||
OS << " return AttrListPtr::get(AWI, NumAttrs);\n";
|
||||
OS << " return AttrListPtr::get(ArrayRef<AttributeWithIndex>(AWI, "
|
||||
"NumAttrs));\n";
|
||||
OS << "}\n";
|
||||
OS << "#endif // GET_INTRINSIC_ATTRIBUTES\n\n";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user