diff options
author | Joseph Tremoulet <jotrem@microsoft.com> | 2015-09-03 09:09:43 +0000 |
---|---|---|
committer | Joseph Tremoulet <jotrem@microsoft.com> | 2015-09-03 09:09:43 +0000 |
commit | 9ce71f76b9497d3b50bc267b2ba9a92de48f13e2 (patch) | |
tree | 7323a60f5c30c9b8e7ffde38dfb29d19b0de19c5 /llvm/lib/AsmParser | |
parent | 0dcd8bcf2407caa5c6a9705c8b7d0cdda4824dba (diff) | |
download | bcm5719-llvm-9ce71f76b9497d3b50bc267b2ba9a92de48f13e2.tar.gz bcm5719-llvm-9ce71f76b9497d3b50bc267b2ba9a92de48f13e2.zip |
[WinEH] Add cleanupendpad instruction
Summary:
Add a `cleanupendpad` instruction, used to mark exceptional exits out of
cleanups (for languages/targets that can abort a cleanup with another
exception). The `cleanupendpad` instruction is similar to the `catchendpad`
instruction in that it is an EH pad which is the target of unwind edges in
the handler and which itself has an unwind edge to the next EH action.
The `cleanupendpad` instruction, similar to `cleanupret` has a `cleanuppad`
argument indicating which cleanup it exits. The unwind successors of a
`cleanuppad`'s `cleanupendpad`s must agree with each other and with its
`cleanupret`s.
Update WinEHPrepare (and docs/tests) to accomodate `cleanupendpad`.
Reviewers: rnk, andrew.w.kaylor, majnemer
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D12433
llvm-svn: 246751
Diffstat (limited to 'llvm/lib/AsmParser')
-rw-r--r-- | llvm/lib/AsmParser/LLLexer.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 30 | ||||
-rw-r--r-- | llvm/lib/AsmParser/LLParser.h | 1 | ||||
-rw-r--r-- | llvm/lib/AsmParser/LLToken.h | 2 |
4 files changed, 33 insertions, 1 deletions
diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp index af7705c5666..b166c17b124 100644 --- a/llvm/lib/AsmParser/LLLexer.cpp +++ b/llvm/lib/AsmParser/LLLexer.cpp @@ -757,6 +757,7 @@ lltok::Kind LLLexer::LexIdentifier() { INSTKEYWORD(terminatepad, TerminatePad); INSTKEYWORD(cleanuppad, CleanupPad); INSTKEYWORD(catchendpad, CatchEndPad); + INSTKEYWORD(cleanupendpad, CleanupEndPad); #undef INSTKEYWORD #define DWKEYWORD(TYPE, TOKEN) \ diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index c8390d44cca..df34ba8697f 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -4686,6 +4686,7 @@ int LLParser::ParseInstruction(Instruction *&Inst, BasicBlock *BB, case lltok::kw_terminatepad: return ParseTerminatePad(Inst, PFS); case lltok::kw_cleanuppad: return ParseCleanupPad(Inst, PFS); case lltok::kw_catchendpad: return ParseCatchEndPad(Inst, PFS); + case lltok::kw_cleanupendpad: return ParseCleanupEndPad(Inst, PFS); // Binary Operators. case lltok::kw_add: case lltok::kw_sub: @@ -5243,6 +5244,35 @@ bool LLParser::ParseCatchEndPad(Instruction *&Inst, PerFunctionState &PFS) { return false; } +/// ParseCatchEndPad +/// ::= 'cleanupendpad' Value unwind ('to' 'caller' | TypeAndValue) +bool LLParser::ParseCleanupEndPad(Instruction *&Inst, PerFunctionState &PFS) { + Value *CleanupPad = nullptr; + + if (ParseValue(Type::getTokenTy(Context), CleanupPad, PFS, OC_CleanupPad)) + return true; + + if (ParseToken(lltok::kw_unwind, "expected 'unwind' in catchendpad")) + return true; + + BasicBlock *UnwindBB = nullptr; + if (Lex.getKind() == lltok::kw_to) { + Lex.Lex(); + if (Lex.getKind() == lltok::kw_caller) { + Lex.Lex(); + } else { + return true; + } + } else { + if (ParseTypeAndBasicBlock(UnwindBB, PFS)) { + return true; + } + } + + Inst = CleanupEndPadInst::Create(cast<CleanupPadInst>(CleanupPad), UnwindBB); + return false; +} + //===----------------------------------------------------------------------===// // Binary Operators. //===----------------------------------------------------------------------===// diff --git a/llvm/lib/AsmParser/LLParser.h b/llvm/lib/AsmParser/LLParser.h index 8b7e9560a69..e161f95248c 100644 --- a/llvm/lib/AsmParser/LLParser.h +++ b/llvm/lib/AsmParser/LLParser.h @@ -475,6 +475,7 @@ namespace llvm { bool ParseTerminatePad(Instruction *&Inst, PerFunctionState &PFS); bool ParseCleanupPad(Instruction *&Inst, PerFunctionState &PFS); bool ParseCatchEndPad(Instruction *&Inst, PerFunctionState &PFS); + bool ParseCleanupEndPad(Instruction *&Inst, PerFunctionState &PFS); bool ParseArithmetic(Instruction *&I, PerFunctionState &PFS, unsigned Opc, unsigned OperandType); diff --git a/llvm/lib/AsmParser/LLToken.h b/llvm/lib/AsmParser/LLToken.h index 19bf7e4e4c1..b83ca2c652f 100644 --- a/llvm/lib/AsmParser/LLToken.h +++ b/llvm/lib/AsmParser/LLToken.h @@ -179,7 +179,7 @@ namespace lltok { kw_ret, kw_br, kw_switch, kw_indirectbr, kw_invoke, kw_resume, kw_unreachable, kw_cleanupret, kw_catchret, kw_catchpad, - kw_terminatepad, kw_cleanuppad, kw_catchendpad, + kw_terminatepad, kw_cleanuppad, kw_catchendpad, kw_cleanupendpad, kw_alloca, kw_load, kw_store, kw_fence, kw_cmpxchg, kw_atomicrmw, kw_getelementptr, |