[llvm-commits] [llvm] r92302 - in /llvm/trunk/lib/AsmParser: LLParser.cpp LLParser.h
Chris Lattner
sabre at nondot.org
Tue Dec 29 21:48:36 PST 2009
Author: lattner
Date: Tue Dec 29 23:48:36 2009
New Revision: 92302
URL: http://llvm.org/viewvc/llvm-project?rev=92302&view=rev
Log:
now that instruction metadata is only parsed in one place, eliminate the
parser-global MDsOnInst vector and make ParseInstructionMetadata return
its result by-ref through an argument like the entire rest of the parser.
Modified:
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/AsmParser/LLParser.h
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=92302&r1=92301&r2=92302&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Dec 29 23:48:36 2009
@@ -1065,7 +1065,9 @@
/// ParseInstructionMetadata
/// ::= !dbg !42 (',' !dbg !57)*
-bool LLParser::ParseInstructionMetadata() {
+bool LLParser::
+ParseInstructionMetadata(SmallVectorImpl<std::pair<unsigned,
+ MDNode *> > &Result){
do {
if (Lex.getKind() != lltok::MetadataVar)
return TokError("expected metadata after comma");
@@ -1079,7 +1081,7 @@
return true;
unsigned MDK = M->getMDKindID(Name.c_str());
- MDsOnInst.push_back(std::make_pair(MDK, Node));
+ Result.push_back(std::make_pair(MDK, Node));
// If this is the end of the list, we're done.
} while (EatIfPresent(lltok::comma));
@@ -2794,6 +2796,7 @@
// Parse the instructions in this block until we get a terminator.
Instruction *Inst;
+ SmallVector<std::pair<unsigned, MDNode *>, 4> MetadataOnInst;
do {
// This instruction may have three possibilities for a name: a) none
// specified, b) name specified "%foo =", c) number specified: "%4 =".
@@ -2822,22 +2825,21 @@
// With a normal result, we check to see if the instruction is followed by
// a comma and metadata.
if (EatIfPresent(lltok::comma))
- if (ParseInstructionMetadata())
+ if (ParseInstructionMetadata(MetadataOnInst))
return true;
break;
case InstExtraComma:
// If the instruction parser ate an extra comma at the end of it, it
// *must* be followed by metadata.
- if (ParseInstructionMetadata())
+ if (ParseInstructionMetadata(MetadataOnInst))
return true;
break;
}
// Set metadata attached with this instruction.
- for (SmallVector<std::pair<unsigned, MDNode *>, 2>::iterator
- MDI = MDsOnInst.begin(), MDE = MDsOnInst.end(); MDI != MDE; ++MDI)
- Inst->setMetadata(MDI->first, MDI->second);
- MDsOnInst.clear();
+ for (unsigned i = 0, e = MetadataOnInst.size(); i != e; ++i)
+ Inst->setMetadata(MetadataOnInst[i].first, MetadataOnInst[i].second);
+ MetadataOnInst.clear();
BB->getInstList().push_back(Inst);
Modified: llvm/trunk/lib/AsmParser/LLParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=92302&r1=92301&r2=92302&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.h (original)
+++ llvm/trunk/lib/AsmParser/LLParser.h Tue Dec 29 23:48:36 2009
@@ -83,7 +83,6 @@
std::vector<PATypeHolder> NumberedTypes;
std::vector<TrackingVH<MDNode> > NumberedMetadata;
std::map<unsigned, std::pair<TrackingVH<MDNode>, LocTy> > ForwardRefMDNodes;
- SmallVector<std::pair<unsigned, MDNode *>, 2> MDsOnInst;
struct UpRefRecord {
/// Loc - This is the location of the upref.
LocTy Loc;
@@ -171,7 +170,8 @@
bool ParseOptionalVisibility(unsigned &Visibility);
bool ParseOptionalCallingConv(CallingConv::ID &CC);
bool ParseOptionalAlignment(unsigned &Alignment);
- bool ParseInstructionMetadata();
+ bool ParseInstructionMetadata(SmallVectorImpl<std::pair<unsigned,
+ MDNode *> > &);
bool ParseOptionalCommaAlign(unsigned &Alignment, bool &AteExtraComma);
bool ParseIndexList(SmallVectorImpl<unsigned> &Indices,bool &AteExtraComma);
bool ParseIndexList(SmallVectorImpl<unsigned> &Indices) {
More information about the llvm-commits
mailing list