diff options
author | Reid Kleckner <rnk@google.com> | 2017-04-10 20:34:19 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2017-04-10 20:34:19 +0000 |
commit | 211b1f324fec79eddecccc4cb43a284bd3324cd5 (patch) | |
tree | 79b6b6a51d322e61e42c702acf10511de901cee7 /llvm/lib/AsmParser | |
parent | d972949b10ef0b10fd73d5b153084217c535bb15 (diff) | |
download | bcm5719-llvm-211b1f324fec79eddecccc4cb43a284bd3324cd5.tar.gz bcm5719-llvm-211b1f324fec79eddecccc4cb43a284bd3324cd5.zip |
Revert "[IR] Make AttributeSetNode public, avoid temporary AttributeList copies"
This reverts r299875. A Linux bot came back with a test failure:
http://bb.pgr.jp/builders/test-clang-i686-linux-RA/builds/741/steps/test_clang/logs/Clang%20%3A%3A%20CodeGen__2006-05-19-SingleEltReturn.c
llvm-svn: 299878
Diffstat (limited to 'llvm/lib/AsmParser')
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 88 | ||||
-rw-r--r-- | llvm/lib/AsmParser/LLParser.h | 8 |
2 files changed, 62 insertions, 34 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 78de0d65f25..d8f6c1c5146 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -19,7 +19,6 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/AsmParser/SlotMapping.h" #include "llvm/IR/Argument.h" -#include "llvm/IR/AttributeSetNode.h" #include "llvm/IR/AutoUpgrade.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/CallingConv.h" @@ -132,8 +131,9 @@ bool LLParser::ValidateEndOfModule() { if (Function *Fn = dyn_cast<Function>(V)) { AttributeList AS = Fn->getAttributes(); - AttrBuilder FnAttrs(AS.getFnAttributes()); - AS = AS.removeAttributes(Context, AttributeList::FunctionIndex); + AttrBuilder FnAttrs(AS.getFnAttributes(), AttributeList::FunctionIndex); + AS = AS.removeAttributes(Context, AttributeList::FunctionIndex, + AS.getFnAttributes()); FnAttrs.merge(B); @@ -150,8 +150,9 @@ bool LLParser::ValidateEndOfModule() { Fn->setAttributes(AS); } else if (CallInst *CI = dyn_cast<CallInst>(V)) { AttributeList AS = CI->getAttributes(); - AttrBuilder FnAttrs(AS.getFnAttributes()); - AS = AS.removeAttributes(Context, AttributeList::FunctionIndex); + AttrBuilder FnAttrs(AS.getFnAttributes(), AttributeList::FunctionIndex); + AS = AS.removeAttributes(Context, AttributeList::FunctionIndex, + AS.getFnAttributes()); FnAttrs.merge(B); AS = AS.addAttributes( Context, AttributeList::FunctionIndex, @@ -159,8 +160,9 @@ bool LLParser::ValidateEndOfModule() { CI->setAttributes(AS); } else if (InvokeInst *II = dyn_cast<InvokeInst>(V)) { AttributeList AS = II->getAttributes(); - AttrBuilder FnAttrs(AS.getFnAttributes()); - AS = AS.removeAttributes(Context, AttributeList::FunctionIndex); + AttrBuilder FnAttrs(AS.getFnAttributes(), AttributeList::FunctionIndex); + AS = AS.removeAttributes(Context, AttributeList::FunctionIndex, + AS.getFnAttributes()); FnAttrs.merge(B); AS = AS.addAttributes( Context, AttributeList::FunctionIndex, @@ -2093,6 +2095,7 @@ bool LLParser::ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList, if (ParseToken(lltok::lparen, "expected '(' in call")) return true; + unsigned AttrIndex = 1; while (Lex.getKind() != lltok::rparen) { // If this isn't the first argument, we need a comma. if (!ArgList.empty() && @@ -2127,7 +2130,7 @@ bool LLParser::ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList, return true; } ArgList.push_back(ParamInfo( - ArgLoc, V, AttributeSetNode::get(V->getContext(), ArgAttrs))); + ArgLoc, V, AttributeList::get(V->getContext(), AttrIndex++, ArgAttrs))); } if (IsMustTailCall && InVarArgsFunc) @@ -2232,8 +2235,9 @@ bool LLParser::ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList, if (!FunctionType::isValidArgumentType(ArgTy)) return Error(TypeLoc, "invalid type for function argument"); - ArgList.emplace_back(TypeLoc, ArgTy, - AttributeSetNode::get(ArgTy->getContext(), Attrs), + unsigned AttrIndex = 1; + ArgList.emplace_back(TypeLoc, ArgTy, AttributeList::get(ArgTy->getContext(), + AttrIndex++, Attrs), std::move(Name)); while (EatIfPresent(lltok::comma)) { @@ -2260,9 +2264,10 @@ bool LLParser::ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList, if (!ArgTy->isFirstClassType()) return Error(TypeLoc, "invalid type for function argument"); - ArgList.emplace_back(TypeLoc, ArgTy, - AttributeSetNode::get(ArgTy->getContext(), Attrs), - std::move(Name)); + ArgList.emplace_back( + TypeLoc, ArgTy, + AttributeList::get(ArgTy->getContext(), AttrIndex++, Attrs), + std::move(Name)); } } @@ -2286,7 +2291,7 @@ bool LLParser::ParseFunctionType(Type *&Result) { for (unsigned i = 0, e = ArgList.size(); i != e; ++i) { if (!ArgList[i].Name.empty()) return Error(ArgList[i].Loc, "argument name invalid in function type"); - if (ArgList[i].Attrs) + if (ArgList[i].Attrs.hasAttributes(i + 1)) return Error(ArgList[i].Loc, "argument attributes invalid in function type"); } @@ -4735,16 +4740,23 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) { // Okay, if we got here, the function is syntactically valid. Convert types // and do semantic checks. std::vector<Type*> ParamTypeList; - SmallVector<AttributeSetNode *, 8> Attrs; + SmallVector<AttributeList, 8> Attrs; - Attrs.push_back(AttributeSetNode::get(Context, RetAttrs)); + if (RetAttrs.hasAttributes()) + Attrs.push_back(AttributeList::get(RetType->getContext(), + AttributeList::ReturnIndex, RetAttrs)); for (unsigned i = 0, e = ArgList.size(); i != e; ++i) { ParamTypeList.push_back(ArgList[i].Ty); - Attrs.push_back(ArgList[i].Attrs); + if (ArgList[i].Attrs.hasAttributes(i + 1)) { + AttrBuilder B(ArgList[i].Attrs, i + 1); + Attrs.push_back(AttributeList::get(RetType->getContext(), i + 1, B)); + } } - Attrs.push_back(AttributeSetNode::get(Context, FuncAttrs)); + if (FuncAttrs.hasAttributes()) + Attrs.push_back(AttributeList::get( + RetType->getContext(), AttributeList::FunctionIndex, FuncAttrs)); AttributeList PAL = AttributeList::get(Context, Attrs); @@ -5356,8 +5368,10 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) { return true; // Set up the Attribute for the function. - SmallVector<AttributeSetNode *, 8> Attrs; - Attrs.push_back(AttributeSetNode::get(Context, RetAttrs)); + SmallVector<AttributeList, 8> Attrs; + if (RetAttrs.hasAttributes()) + Attrs.push_back(AttributeList::get(RetType->getContext(), + AttributeList::ReturnIndex, RetAttrs)); SmallVector<Value*, 8> Args; @@ -5377,16 +5391,22 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) { return Error(ArgList[i].Loc, "argument is not of expected type '" + getTypeString(ExpectedTy) + "'"); Args.push_back(ArgList[i].V); - Attrs.push_back(ArgList[i].Attrs); + if (ArgList[i].Attrs.hasAttributes(i + 1)) { + AttrBuilder B(ArgList[i].Attrs, i + 1); + Attrs.push_back(AttributeList::get(RetType->getContext(), i + 1, B)); + } } if (I != E) return Error(CallLoc, "not enough parameters specified for call"); - if (FnAttrs.hasAlignmentAttr()) - return Error(CallLoc, "invoke instructions may not have an alignment"); + if (FnAttrs.hasAttributes()) { + if (FnAttrs.hasAlignmentAttr()) + return Error(CallLoc, "invoke instructions may not have an alignment"); - Attrs.push_back(AttributeSetNode::get(Context, FnAttrs)); + Attrs.push_back(AttributeList::get(RetType->getContext(), + AttributeList::FunctionIndex, FnAttrs)); + } // Finish off the Attribute and check them AttributeList PAL = AttributeList::get(Context, Attrs); @@ -5950,8 +5970,10 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS, return true; // Set up the Attribute for the function. - SmallVector<AttributeSetNode *, 8> Attrs; - Attrs.push_back(AttributeSetNode::get(Context, RetAttrs)); + SmallVector<AttributeList, 8> Attrs; + if (RetAttrs.hasAttributes()) + Attrs.push_back(AttributeList::get(RetType->getContext(), + AttributeList::ReturnIndex, RetAttrs)); SmallVector<Value*, 8> Args; @@ -5971,16 +5993,22 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS, return Error(ArgList[i].Loc, "argument is not of expected type '" + getTypeString(ExpectedTy) + "'"); Args.push_back(ArgList[i].V); - Attrs.push_back(ArgList[i].Attrs); + if (ArgList[i].Attrs.hasAttributes(i + 1)) { + AttrBuilder B(ArgList[i].Attrs, i + 1); + Attrs.push_back(AttributeList::get(RetType->getContext(), i + 1, B)); + } } if (I != E) return Error(CallLoc, "not enough parameters specified for call"); - if (FnAttrs.hasAlignmentAttr()) - return Error(CallLoc, "call instructions may not have an alignment"); + if (FnAttrs.hasAttributes()) { + if (FnAttrs.hasAlignmentAttr()) + return Error(CallLoc, "call instructions may not have an alignment"); - Attrs.push_back(AttributeSetNode::get(Context, FnAttrs)); + Attrs.push_back(AttributeList::get(RetType->getContext(), + AttributeList::FunctionIndex, FnAttrs)); + } // Finish off the Attribute and check them AttributeList PAL = AttributeList::get(Context, Attrs); diff --git a/llvm/lib/AsmParser/LLParser.h b/llvm/lib/AsmParser/LLParser.h index f3e1cc85c8b..3a794142172 100644 --- a/llvm/lib/AsmParser/LLParser.h +++ b/llvm/lib/AsmParser/LLParser.h @@ -395,8 +395,8 @@ namespace llvm { struct ParamInfo { LocTy Loc; Value *V; - AttributeSetNode *Attrs; - ParamInfo(LocTy loc, Value *v, AttributeSetNode *attrs) + AttributeList Attrs; + ParamInfo(LocTy loc, Value *v, AttributeList attrs) : Loc(loc), V(v), Attrs(attrs) {} }; bool ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList, @@ -448,9 +448,9 @@ namespace llvm { struct ArgInfo { LocTy Loc; Type *Ty; - AttributeSetNode *Attrs; + AttributeList Attrs; std::string Name; - ArgInfo(LocTy L, Type *ty, AttributeSetNode *Attr, const std::string &N) + ArgInfo(LocTy L, Type *ty, AttributeList Attr, const std::string &N) : Loc(L), Ty(ty), Attrs(Attr), Name(N) {} }; bool ParseArgumentList(SmallVectorImpl<ArgInfo> &ArgList, bool &isVarArg); |