Index: include/llvm/MC/MCParser/MCAsmParser.h =================================================================== --- include/llvm/MC/MCParser/MCAsmParser.h +++ include/llvm/MC/MCParser/MCAsmParser.h @@ -114,6 +114,8 @@ SmallVectorImpl > &OpDecls, SmallVectorImpl &Constraints, SmallVectorImpl &Clobbers, + SmallVectorImpl &BranchTargets, + SmallVectorImpl &LabelsDefined, const MCInstrInfo *MII, const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) = 0; Index: lib/MC/MCParser/AsmParser.cpp =================================================================== --- lib/MC/MCParser/AsmParser.cpp +++ lib/MC/MCParser/AsmParser.cpp @@ -96,6 +96,9 @@ /// \brief The parsed operands from the last parsed statement. SmallVector, 8> ParsedOperands; + /// \brief The name of a label, in case one was encountered. + StringRef LabelName; + /// \brief The opcode from the last parsed instruction. unsigned Opcode; @@ -219,6 +222,8 @@ SmallVectorImpl > &OpDecls, SmallVectorImpl &Constraints, SmallVectorImpl &Clobbers, + SmallVectorImpl &BranchTargets, + SmallVectorImpl &LabelsDefined, const MCInstrInfo *MII, const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) override; @@ -1303,6 +1308,7 @@ assert(RewrittenLabel.size() && "We should have an internal name here."); Info.AsmRewrites->push_back(AsmRewrite(AOK_Label, IDLoc, IDVal.size(), RewrittenLabel)); + Info.LabelName = IDVal; IDVal = RewrittenLabel; } Sym = getContext().GetOrCreateSymbol(IDVal); @@ -4530,7 +4536,10 @@ void *AsmLoc, std::string &AsmString, unsigned &NumOutputs, unsigned &NumInputs, SmallVectorImpl > &OpDecls, SmallVectorImpl &Constraints, - SmallVectorImpl &Clobbers, const MCInstrInfo *MII, + SmallVectorImpl &Clobbers, + SmallVectorImpl &BranchTargets, + SmallVectorImpl &LabelsDefined, + const MCInstrInfo *MII, const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) { SmallVector InputDecls; SmallVector OutputDecls; @@ -4556,6 +4565,9 @@ if (Info.ParseError) return true; + if (!Info.LabelName.empty()) + LabelsDefined.push_back(Info.LabelName); + if (Info.Opcode == ~0U) continue; @@ -4584,6 +4596,10 @@ if (SymName.empty()) continue; + // Build the list of branch targets. + if (Desc.isBranch() && Operand.isMem()) + BranchTargets.push_back(SymName); + void *OpDecl = Operand.getOpDecl(); if (!OpDecl) continue;