diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/MIRParser/MILexer.cpp | 7 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MIRParser/MILexer.h | 1 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIParser.cpp | 24 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MIRPrinter.cpp | 7 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 5 |
5 files changed, 39 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.cpp b/llvm/lib/CodeGen/MIRParser/MILexer.cpp index ad5c617623f..21511586ff1 100644 --- a/llvm/lib/CodeGen/MIRParser/MILexer.cpp +++ b/llvm/lib/CodeGen/MIRParser/MILexer.cpp @@ -252,6 +252,7 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) { .Case("shufflemask", MIToken::kw_shufflemask) .Case("pre-instr-symbol", MIToken::kw_pre_instr_symbol) .Case("post-instr-symbol", MIToken::kw_post_instr_symbol) + .Case("heap-alloc-marker", MIToken::kw_heap_alloc_marker) .Case("unknown-size", MIToken::kw_unknown_size) .Default(MIToken::Identifier); } @@ -582,8 +583,8 @@ static MIToken::TokenKind getMetadataKeywordKind(StringRef Identifier) { .Default(MIToken::Error); } -static Cursor maybeLexExlaim(Cursor C, MIToken &Token, - ErrorCallbackType ErrorCallback) { +static Cursor maybeLexExclaim(Cursor C, MIToken &Token, + ErrorCallbackType ErrorCallback) { if (C.peek() != '!') return None; auto Range = C; @@ -719,7 +720,7 @@ StringRef llvm::lexMIToken(StringRef Source, MIToken &Token, return R.remaining(); if (Cursor R = maybeLexNumericalLiteral(C, Token)) return R.remaining(); - if (Cursor R = maybeLexExlaim(C, Token, ErrorCallback)) + if (Cursor R = maybeLexExclaim(C, Token, ErrorCallback)) return R.remaining(); if (Cursor R = maybeLexSymbol(C, Token)) return R.remaining(); diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.h b/llvm/lib/CodeGen/MIRParser/MILexer.h index 200f9d026cc..1e2eba91ceb 100644 --- a/llvm/lib/CodeGen/MIRParser/MILexer.h +++ b/llvm/lib/CodeGen/MIRParser/MILexer.h @@ -120,6 +120,7 @@ struct MIToken { kw_shufflemask, kw_pre_instr_symbol, kw_post_instr_symbol, + kw_heap_alloc_marker, kw_unknown_size, // Named metadata keywords diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index 6498acc9fa5..525c70016a0 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -471,6 +471,7 @@ public: bool parseOptionalAtomicOrdering(AtomicOrdering &Order); bool parseMachineMemoryOperand(MachineMemOperand *&Dest); bool parsePreOrPostInstrSymbol(MCSymbol *&Symbol); + bool parseHeapAllocMarker(MDNode *&Node); private: /// Convert the integer literal in the current token into an unsigned integer. @@ -906,6 +907,7 @@ bool MIParser::parse(MachineInstr *&MI) { // Parse the remaining machine operands. while (!Token.isNewlineOrEOF() && Token.isNot(MIToken::kw_pre_instr_symbol) && Token.isNot(MIToken::kw_post_instr_symbol) && + Token.isNot(MIToken::kw_heap_alloc_marker) && Token.isNot(MIToken::kw_debug_location) && Token.isNot(MIToken::coloncolon) && Token.isNot(MIToken::lbrace)) { auto Loc = Token.location(); @@ -932,6 +934,10 @@ bool MIParser::parse(MachineInstr *&MI) { if (Token.is(MIToken::kw_post_instr_symbol)) if (parsePreOrPostInstrSymbol(PostInstrSymbol)) return true; + MDNode *HeapAllocMarker = nullptr; + if (Token.is(MIToken::kw_heap_alloc_marker)) + if (parseHeapAllocMarker(HeapAllocMarker)) + return true; DebugLoc DebugLocation; if (Token.is(MIToken::kw_debug_location)) { @@ -985,6 +991,8 @@ bool MIParser::parse(MachineInstr *&MI) { MI->setPreInstrSymbol(MF, PreInstrSymbol); if (PostInstrSymbol) MI->setPostInstrSymbol(MF, PostInstrSymbol); + if (HeapAllocMarker) + MI->setHeapAllocMarker(MF, HeapAllocMarker); if (!MemOperands.empty()) MI->setMemRefs(MF, MemOperands); return false; @@ -2956,6 +2964,22 @@ bool MIParser::parsePreOrPostInstrSymbol(MCSymbol *&Symbol) { return false; } +bool MIParser::parseHeapAllocMarker(MDNode *&Node) { + assert(Token.is(MIToken::kw_heap_alloc_marker) && + "Invalid token for a heap alloc marker!"); + lex(); + parseMDNode(Node); + if (!Node) + return error("expected a MDNode after 'heap-alloc-marker'"); + if (Token.isNewlineOrEOF() || Token.is(MIToken::coloncolon) || + Token.is(MIToken::lbrace)) + return false; + if (Token.isNot(MIToken::comma)) + return error("expected ',' before the next machine operand"); + lex(); + return false; +} + static void initSlots2BasicBlocks( const Function &F, DenseMap<unsigned, const BasicBlock *> &Slots2BasicBlocks) { diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp index 1a4e21ac06a..b06e34a809f 100644 --- a/llvm/lib/CodeGen/MIRPrinter.cpp +++ b/llvm/lib/CodeGen/MIRPrinter.cpp @@ -784,6 +784,13 @@ void MIPrinter::print(const MachineInstr &MI) { MachineOperand::printSymbol(OS, *PostInstrSymbol); NeedComma = true; } + if (MDNode *HeapAllocMarker = MI.getHeapAllocMarker()) { + if (NeedComma) + OS << ','; + OS << " heap-alloc-marker "; + HeapAllocMarker->printAsOperand(OS, MST); + NeedComma = true; + } if (const DebugLoc &DL = MI.getDebugLoc()) { if (NeedComma) diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 397c1239d85..276a0a4aef6 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -1701,12 +1701,13 @@ void MachineInstr::print(raw_ostream &OS, ModuleSlotTracker &MST, OS << " post-instr-symbol "; MachineOperand::printSymbol(OS, *PostInstrSymbol); } - if (/*MDNode *HeapAllocMarker =*/getHeapAllocMarker()) { + if (MDNode *HeapAllocMarker = getHeapAllocMarker()) { if (!FirstOp) { FirstOp = false; OS << ','; } - OS << " heap-alloc-marker"; + OS << " heap-alloc-marker "; + HeapAllocMarker->printAsOperand(OS, MST); } if (!SkipDebugLoc) { |