From a354cd3ea58b9623c046b71b41d9badc97c0b15e Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sun, 23 Aug 2015 19:22:31 +0000 Subject: [PATCH] [IR] Cleanup EH instructions a little bit Just a cosmetic change, no functionality change is intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245818 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Instructions.h | 13 +++---------- lib/Bitcode/Reader/BitcodeReader.cpp | 3 +-- lib/IR/Instructions.cpp | 10 ++-------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h index f29639f95dc..f08ea713351 100644 --- a/include/llvm/IR/Instructions.h +++ b/include/llvm/IR/Instructions.h @@ -3574,9 +3574,9 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ResumeInst, Value) //===----------------------------------------------------------------------===// class CatchEndPadInst : public TerminatorInst { +private: CatchEndPadInst(const CatchEndPadInst &RI); -private: void init(BasicBlock *UnwindBB); CatchEndPadInst(LLVMContext &C, BasicBlock *UnwindBB, unsigned Values, Instruction *InsertBefore = nullptr); @@ -3630,7 +3630,6 @@ private: unsigned getNumSuccessorsV() const override; void setSuccessorV(unsigned Idx, BasicBlock *B) override; -private: // Shadow Instruction::setInstructionSubclassData with a private forwarding // method so that subclasses cannot accidentally use it. void setInstructionSubclassData(unsigned short D) { @@ -3928,10 +3927,9 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CleanupPadInst, Value) class CatchReturnInst : public TerminatorInst { CatchReturnInst(const CatchReturnInst &RI); -private: void init(CatchPadInst *CatchPad, BasicBlock *BB); CatchReturnInst(CatchPadInst *CatchPad, BasicBlock *BB, - Instruction *InsertBefore = nullptr); + Instruction *InsertBefore); CatchReturnInst(CatchPadInst *CatchPad, BasicBlock *BB, BasicBlock *InsertAtEnd); @@ -3996,20 +3994,15 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CatchReturnInst, Value) //===----------------------------------------------------------------------===// class CleanupReturnInst : public TerminatorInst { +private: CleanupReturnInst(const CleanupReturnInst &RI); -private: void init(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB); CleanupReturnInst(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB, unsigned Values, Instruction *InsertBefore = nullptr); CleanupReturnInst(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB, unsigned Values, BasicBlock *InsertAtEnd); - int getUnwindLabelOpIdx() const { - assert(hasUnwindDest()); - return 0; - } - protected: // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 7ede794bc76..5cedfe86c1b 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -3876,8 +3876,7 @@ std::error_code BitcodeReader::parseFunctionBody(Function *F) { } break; } - // CLEANUPRET: [val] or [val,bb#] - case bitc::FUNC_CODE_INST_CLEANUPRET: { + case bitc::FUNC_CODE_INST_CLEANUPRET: { // CLEANUPRET: [val] or [val,bb#] if (Record.size() != 1 && Record.size() != 2) return error("Invalid record"); unsigned Idx = 0; diff --git a/lib/IR/Instructions.cpp b/lib/IR/Instructions.cpp index e79fa415ffb..6b2cd6dac22 100644 --- a/lib/IR/Instructions.cpp +++ b/lib/IR/Instructions.cpp @@ -682,7 +682,6 @@ CleanupReturnInst::CleanupReturnInst(const CleanupReturnInst &CRI) OperandTraits::op_end(this) - CRI.getNumOperands(), CRI.getNumOperands()) { - SubclassOptionalData = CRI.SubclassOptionalData; setInstructionSubclassData(CRI.getSubclassDataFromInstruction()); Op<-1>() = CRI.Op<-1>(); if (CRI.hasUnwindDest()) @@ -690,7 +689,6 @@ CleanupReturnInst::CleanupReturnInst(const CleanupReturnInst &CRI) } void CleanupReturnInst::init(CleanupPadInst *CleanupPad, BasicBlock *UnwindBB) { - SubclassOptionalData = 0; if (UnwindBB) setInstructionSubclassData(getSubclassDataFromInstruction() | 1); @@ -740,14 +738,12 @@ CatchEndPadInst::CatchEndPadInst(const CatchEndPadInst &CRI) OperandTraits::op_end(this) - CRI.getNumOperands(), CRI.getNumOperands()) { - SubclassOptionalData = CRI.SubclassOptionalData; setInstructionSubclassData(CRI.getSubclassDataFromInstruction()); if (BasicBlock *UnwindDest = CRI.getUnwindDest()) setUnwindDest(UnwindDest); } void CatchEndPadInst::init(BasicBlock *UnwindBB) { - SubclassOptionalData = 0; if (UnwindBB) { setInstructionSubclassData(getSubclassDataFromInstruction() | 1); setUnwindDest(UnwindBB); @@ -814,14 +810,14 @@ CatchReturnInst::CatchReturnInst(CatchPadInst *CatchPad, BasicBlock *BB, } BasicBlock *CatchReturnInst::getSuccessorV(unsigned Idx) const { - assert(Idx == 0); + assert(Idx < getNumSuccessors() && "Successor # out of range for catchret!"); return getSuccessor(); } unsigned CatchReturnInst::getNumSuccessorsV() const { return getNumSuccessors(); } void CatchReturnInst::setSuccessorV(unsigned Idx, BasicBlock *B) { - assert(Idx == 0); + assert(Idx < getNumSuccessors() && "Successor # out of range for catchret!"); setSuccessor(B); } @@ -879,7 +875,6 @@ void CatchPadInst::setSuccessorV(unsigned Idx, BasicBlock *B) { // TerminatePadInst Implementation //===----------------------------------------------------------------------===// void TerminatePadInst::init(BasicBlock *BB, ArrayRef Args) { - SubclassOptionalData = 0; if (BB) setInstructionSubclassData(getSubclassDataFromInstruction() | 1); if (BB) @@ -892,7 +887,6 @@ TerminatePadInst::TerminatePadInst(const TerminatePadInst &TPI) OperandTraits::op_end(this) - TPI.getNumOperands(), TPI.getNumOperands()) { - SubclassOptionalData = TPI.SubclassOptionalData; setInstructionSubclassData(TPI.getSubclassDataFromInstruction()); std::copy(TPI.op_begin(), TPI.op_end(), op_begin()); } -- 2.34.1