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/Bitcode | |
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/Bitcode')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 19 | ||||
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 8 |
2 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index b9604af3bc8..be39b88b822 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -3999,6 +3999,25 @@ std::error_code BitcodeReader::parseFunctionBody(Function *F) { InstructionList.push_back(I); break; } + case bitc::FUNC_CODE_INST_CLEANUPENDPAD: { // CLEANUPENDPADINST: [val] or [val,bb#] + if (Record.size() != 1 && Record.size() != 2) + return error("Invalid record"); + unsigned Idx = 0; + Value *CleanupPad = getValue(Record, Idx++, NextValueNo, + Type::getTokenTy(Context), OC_CleanupPad); + if (!CleanupPad) + return error("Invalid record"); + + BasicBlock *BB = nullptr; + if (Record.size() == 2) { + BB = getBasicBlock(Record[Idx++]); + if (!BB) + return error("Invalid record"); + } + I = CleanupEndPadInst::Create(cast<CleanupPadInst>(CleanupPad), BB); + InstructionList.push_back(I); + break; + } case bitc::FUNC_CODE_INST_SWITCH: { // SWITCH: [opty, op0, op1, ...] // Check magic if ((Record[0] >> 16) == SWITCH_INST_MAGIC) { diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index c0eb5d497bc..9986718f08b 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -1906,6 +1906,14 @@ static void WriteInstruction(const Instruction &I, unsigned InstID, Vals.push_back(VE.getValueID(CEPI.getUnwindDest())); break; } + case Instruction::CleanupEndPad: { + Code = bitc::FUNC_CODE_INST_CLEANUPENDPAD; + const auto &CEPI = cast<CleanupEndPadInst>(I); + pushValue(CEPI.getCleanupPad(), InstID, Vals, VE); + if (CEPI.hasUnwindDest()) + Vals.push_back(VE.getValueID(CEPI.getUnwindDest())); + break; + } case Instruction::Unreachable: Code = bitc::FUNC_CODE_INST_UNREACHABLE; AbbrevToUse = FUNCTION_INST_UNREACHABLE_ABBREV; |