summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/AsmWriter.cpp58
-rw-r--r--llvm/lib/IR/BasicBlock.cpp2
-rw-r--r--llvm/lib/IR/Instruction.cpp14
-rw-r--r--llvm/lib/IR/Instructions.cpp321
-rw-r--r--llvm/lib/IR/Verifier.cpp78
5 files changed, 469 insertions, 4 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index adc620db897..a866828c31b 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -2848,8 +2848,66 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
writeOperand(LPI->getClause(i), true);
}
+ } else if (const auto *CBI = dyn_cast<CatchBlockInst>(&I)) {
+ Out << ' ';
+ TypePrinter.print(I.getType(), Out);
+
+ Out << " [";
+ for (unsigned Op = 0, NumOps = CBI->getNumArgOperands(); Op < NumOps;
+ ++Op) {
+ if (Op > 0)
+ Out << ", ";
+ writeOperand(CBI->getArgOperand(Op), /*PrintType=*/true);
+ }
+ Out << "] to ";
+ writeOperand(CBI->getNormalDest(), /*PrintType=*/true);
+ Out << " unwind ";
+ writeOperand(CBI->getUnwindDest(), /*PrintType=*/true);
+ } else if (const auto *TBI = dyn_cast<TerminateBlockInst>(&I)) {
+ Out << " [";
+ for (unsigned Op = 0, NumOps = TBI->getNumArgOperands(); Op < NumOps;
+ ++Op) {
+ if (Op > 0)
+ Out << ", ";
+ writeOperand(TBI->getArgOperand(Op), /*PrintType=*/true);
+ }
+ Out << "] unwind ";
+ if (TBI->hasUnwindDest())
+ writeOperand(TBI->getUnwindDest(), /*PrintType=*/true);
+ else
+ Out << "to caller";
+ } else if (const auto *CBI = dyn_cast<CleanupBlockInst>(&I)) {
+ Out << ' ';
+ TypePrinter.print(I.getType(), Out);
+
+ Out << " [";
+ for (unsigned Op = 0, NumOps = CBI->getNumOperands(); Op < NumOps; ++Op) {
+ if (Op > 0)
+ Out << ", ";
+ writeOperand(CBI->getOperand(Op), /*PrintType=*/true);
+ }
+ Out << "]";
} else if (isa<ReturnInst>(I) && !Operand) {
Out << " void";
+ } else if (const auto *CRI = dyn_cast<CleanupReturnInst>(&I)) {
+ if (CRI->hasReturnValue()) {
+ Out << ' ';
+ writeOperand(CRI->getReturnValue(), /*PrintType=*/true);
+ } else {
+ Out << " void";
+ }
+
+ Out << " unwind ";
+ if (CRI->hasUnwindDest())
+ writeOperand(CRI->getUnwindDest(), /*PrintType=*/true);
+ else
+ Out << "to caller";
+ } else if (const auto *CEBI = dyn_cast<CatchEndBlockInst>(&I)) {
+ Out << " unwind ";
+ if (CEBI->hasUnwindDest())
+ writeOperand(CEBI->getUnwindDest(), /*PrintType=*/true);
+ else
+ Out << "to caller";
} else if (const CallInst *CI = dyn_cast<CallInst>(&I)) {
// Print the calling convention being used.
if (CI->getCallingConv() != CallingConv::C) {
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 0a0449434a7..658c5e24216 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -197,7 +197,7 @@ BasicBlock::iterator BasicBlock::getFirstInsertionPt() {
return end();
iterator InsertPt = FirstNonPHI;
- if (isa<LandingPadInst>(InsertPt)) ++InsertPt;
+ if (InsertPt->isEHBlock()) ++InsertPt;
return InsertPt;
}
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index c57ba16cf6c..124bf089321 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -196,6 +196,11 @@ const char *Instruction::getOpcodeName(unsigned OpCode) {
case Invoke: return "invoke";
case Resume: return "resume";
case Unreachable: return "unreachable";
+ case CleanupRet: return "cleanupret";
+ case CatchEndBlock: return "catchendblock";
+ case CatchRet: return "catchret";
+ case CatchBlock: return "catchblock";
+ case TerminateBlock: return "terminateblock";
// Standard binary operators...
case Add: return "add";
@@ -256,6 +261,7 @@ const char *Instruction::getOpcodeName(unsigned OpCode) {
case ExtractValue: return "extractvalue";
case InsertValue: return "insertvalue";
case LandingPad: return "landingpad";
+ case CleanupBlock: return "cleanupblock";
default: return "<Invalid operator> ";
}
@@ -407,6 +413,8 @@ bool Instruction::mayReadFromMemory() const {
case Instruction::Fence: // FIXME: refine definition of mayReadFromMemory
case Instruction::AtomicCmpXchg:
case Instruction::AtomicRMW:
+ case Instruction::CatchRet:
+ case Instruction::TerminateBlock:
return true;
case Instruction::Call:
return !cast<CallInst>(this)->doesNotAccessMemory();
@@ -427,6 +435,8 @@ bool Instruction::mayWriteToMemory() const {
case Instruction::VAArg:
case Instruction::AtomicCmpXchg:
case Instruction::AtomicRMW:
+ case Instruction::CatchRet:
+ case Instruction::TerminateBlock:
return true;
case Instruction::Call:
return !cast<CallInst>(this)->onlyReadsMemory();
@@ -455,6 +465,10 @@ bool Instruction::isAtomic() const {
bool Instruction::mayThrow() const {
if (const CallInst *CI = dyn_cast<CallInst>(this))
return !CI->doesNotThrow();
+ if (const auto *CRI = dyn_cast<CleanupReturnInst>(this))
+ return CRI->unwindsToCaller();
+ if (const auto *CEBI = dyn_cast<CatchEndBlockInst>(this))
+ return CEBI->unwindsToCaller();
return isa<ResumeInst>(this);
}
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 86c921aeda8..02cb1205da9 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -671,6 +671,303 @@ BasicBlock *ResumeInst::getSuccessorV(unsigned idx) const {
}
//===----------------------------------------------------------------------===//
+// CleanupReturnInst Implementation
+//===----------------------------------------------------------------------===//
+
+CleanupReturnInst::CleanupReturnInst(const CleanupReturnInst &CRI)
+ : TerminatorInst(CRI.getType(), Instruction::CleanupRet,
+ OperandTraits<CleanupReturnInst>::op_end(this) -
+ CRI.getNumOperands(),
+ CRI.getNumOperands()) {
+ SubclassOptionalData = CRI.SubclassOptionalData;
+ if (Value *RetVal = CRI.getReturnValue())
+ setReturnValue(RetVal);
+ if (BasicBlock *UnwindDest = CRI.getUnwindDest())
+ setUnwindDest(UnwindDest);
+}
+
+void CleanupReturnInst::init(Value *RetVal, BasicBlock *UnwindBB) {
+ SubclassOptionalData = 0;
+ if (UnwindBB)
+ setInstructionSubclassData(getSubclassDataFromInstruction() | 1);
+ if (RetVal)
+ setInstructionSubclassData(getSubclassDataFromInstruction() | 2);
+
+ if (UnwindBB)
+ setUnwindDest(UnwindBB);
+ if (RetVal)
+ setReturnValue(RetVal);
+}
+
+CleanupReturnInst::CleanupReturnInst(LLVMContext &C, Value *RetVal,
+ BasicBlock *UnwindBB, unsigned Values,
+ Instruction *InsertBefore)
+ : TerminatorInst(Type::getVoidTy(C), Instruction::CleanupRet,
+ OperandTraits<CleanupReturnInst>::op_end(this) - Values,
+ Values, InsertBefore) {
+ init(RetVal, UnwindBB);
+}
+
+CleanupReturnInst::CleanupReturnInst(LLVMContext &C, Value *RetVal,
+ BasicBlock *UnwindBB, unsigned Values,
+ BasicBlock *InsertAtEnd)
+ : TerminatorInst(Type::getVoidTy(C), Instruction::CleanupRet,
+ OperandTraits<CleanupReturnInst>::op_end(this) - Values,
+ Values, InsertAtEnd) {
+ init(RetVal, UnwindBB);
+}
+
+BasicBlock *CleanupReturnInst::getUnwindDest() const {
+ if (hasUnwindDest())
+ return cast<BasicBlock>(getOperand(getUnwindLabelOpIdx()));
+ return nullptr;
+}
+void CleanupReturnInst::setUnwindDest(BasicBlock *NewDest) {
+ assert(NewDest);
+ setOperand(getUnwindLabelOpIdx(), NewDest);
+}
+
+BasicBlock *CleanupReturnInst::getSuccessorV(unsigned Idx) const {
+ assert(Idx == 0);
+ return getUnwindDest();
+}
+unsigned CleanupReturnInst::getNumSuccessorsV() const {
+ return getNumSuccessors();
+}
+void CleanupReturnInst::setSuccessorV(unsigned Idx, BasicBlock *B) {
+ assert(Idx == 0);
+ setUnwindDest(B);
+}
+
+//===----------------------------------------------------------------------===//
+// CatchEndBlockInst Implementation
+//===----------------------------------------------------------------------===//
+
+CatchEndBlockInst::CatchEndBlockInst(const CatchEndBlockInst &CRI)
+ : TerminatorInst(CRI.getType(), Instruction::CatchEndBlock,
+ OperandTraits<CatchEndBlockInst>::op_end(this) -
+ CRI.getNumOperands(),
+ CRI.getNumOperands()) {
+ SubclassOptionalData = CRI.SubclassOptionalData;
+ if (BasicBlock *UnwindDest = CRI.getUnwindDest())
+ setUnwindDest(UnwindDest);
+}
+
+void CatchEndBlockInst::init(BasicBlock *UnwindBB) {
+ SubclassOptionalData = 0;
+ if (UnwindBB) {
+ setInstructionSubclassData(getSubclassDataFromInstruction() | 1);
+ setUnwindDest(UnwindBB);
+ }
+}
+
+CatchEndBlockInst::CatchEndBlockInst(LLVMContext &C, BasicBlock *UnwindBB,
+ unsigned Values, Instruction *InsertBefore)
+ : TerminatorInst(Type::getVoidTy(C), Instruction::CatchEndBlock,
+ OperandTraits<CatchEndBlockInst>::op_end(this) - Values,
+ Values, InsertBefore) {
+ init(UnwindBB);
+}
+
+CatchEndBlockInst::CatchEndBlockInst(LLVMContext &C, BasicBlock *UnwindBB,
+ unsigned Values, BasicBlock *InsertAtEnd)
+ : TerminatorInst(Type::getVoidTy(C), Instruction::CatchEndBlock,
+ OperandTraits<CatchEndBlockInst>::op_end(this) - Values,
+ Values, InsertAtEnd) {
+ init(UnwindBB);
+}
+
+BasicBlock *CatchEndBlockInst::getSuccessorV(unsigned Idx) const {
+ assert(Idx == 0);
+ return getUnwindDest();
+}
+unsigned CatchEndBlockInst::getNumSuccessorsV() const {
+ return getNumSuccessors();
+}
+void CatchEndBlockInst::setSuccessorV(unsigned Idx, BasicBlock *B) {
+ assert(Idx == 0);
+ setUnwindDest(B);
+}
+
+//===----------------------------------------------------------------------===//
+// CatchReturnInst Implementation
+//===----------------------------------------------------------------------===//
+
+CatchReturnInst::CatchReturnInst(const CatchReturnInst &CRI)
+ : TerminatorInst(Type::getVoidTy(CRI.getContext()), Instruction::CatchRet,
+ OperandTraits<CatchReturnInst>::op_end(this) -
+ CRI.getNumOperands(),
+ CRI.getNumOperands()) {
+ Op<0>() = CRI.Op<0>();
+}
+
+CatchReturnInst::CatchReturnInst(BasicBlock *BB, Instruction *InsertBefore)
+ : TerminatorInst(Type::getVoidTy(BB->getContext()), Instruction::CatchRet,
+ OperandTraits<CatchReturnInst>::op_begin(this), 1,
+ InsertBefore) {
+ Op<0>() = BB;
+}
+
+CatchReturnInst::CatchReturnInst(BasicBlock *BB, BasicBlock *InsertAtEnd)
+ : TerminatorInst(Type::getVoidTy(BB->getContext()), Instruction::CatchRet,
+ OperandTraits<CatchReturnInst>::op_begin(this), 1,
+ InsertAtEnd) {
+ Op<0>() = BB;
+}
+
+BasicBlock *CatchReturnInst::getSuccessorV(unsigned Idx) const {
+ assert(Idx == 0);
+ return getSuccessor();
+}
+unsigned CatchReturnInst::getNumSuccessorsV() const {
+ return getNumSuccessors();
+}
+void CatchReturnInst::setSuccessorV(unsigned Idx, BasicBlock *B) {
+ assert(Idx == 0);
+ setSuccessor(B);
+}
+
+//===----------------------------------------------------------------------===//
+// CatchBlockInst Implementation
+//===----------------------------------------------------------------------===//
+void CatchBlockInst::init(BasicBlock *IfNormal, BasicBlock *IfException,
+ ArrayRef<Value *> Args, const Twine &NameStr) {
+ assert(getNumOperands() == 2 + Args.size() && "NumOperands not set up?");
+ Op<-2>() = IfNormal;
+ Op<-1>() = IfException;
+ std::copy(Args.begin(), Args.end(), op_begin());
+ setName(NameStr);
+}
+
+CatchBlockInst::CatchBlockInst(const CatchBlockInst &CBI)
+ : TerminatorInst(CBI.getType(), Instruction::CatchBlock,
+ OperandTraits<CatchBlockInst>::op_end(this) -
+ CBI.getNumOperands(),
+ CBI.getNumOperands()) {
+ std::copy(CBI.op_begin(), CBI.op_end(), op_begin());
+}
+
+CatchBlockInst::CatchBlockInst(Type *RetTy, BasicBlock *IfNormal,
+ BasicBlock *IfException, ArrayRef<Value *> Args,
+ unsigned Values, const Twine &NameStr,
+ Instruction *InsertBefore)
+ : TerminatorInst(RetTy, Instruction::CatchBlock,
+ OperandTraits<CatchBlockInst>::op_end(this) - Values,
+ Values, InsertBefore) {
+ init(IfNormal, IfException, Args, NameStr);
+}
+
+CatchBlockInst::CatchBlockInst(Type *RetTy, BasicBlock *IfNormal,
+ BasicBlock *IfException, ArrayRef<Value *> Args,
+ unsigned Values, const Twine &NameStr,
+ BasicBlock *InsertAtEnd)
+ : TerminatorInst(RetTy, Instruction::CatchBlock,
+ OperandTraits<CatchBlockInst>::op_end(this) - Values,
+ Values, InsertAtEnd) {
+ init(IfNormal, IfException, Args, NameStr);
+}
+
+BasicBlock *CatchBlockInst::getSuccessorV(unsigned Idx) const {
+ return getSuccessor(Idx);
+}
+unsigned CatchBlockInst::getNumSuccessorsV() const {
+ return getNumSuccessors();
+}
+void CatchBlockInst::setSuccessorV(unsigned Idx, BasicBlock *B) {
+ return setSuccessor(Idx, B);
+}
+
+//===----------------------------------------------------------------------===//
+// TerminateBlockInst Implementation
+//===----------------------------------------------------------------------===//
+void TerminateBlockInst::init(BasicBlock *BB, ArrayRef<Value *> Args,
+ const Twine &NameStr) {
+ SubclassOptionalData = 0;
+ if (BB)
+ setInstructionSubclassData(getSubclassDataFromInstruction() | 1);
+ if (BB)
+ Op<-1>() = BB;
+ std::copy(Args.begin(), Args.end(), op_begin());
+ setName(NameStr);
+}
+
+TerminateBlockInst::TerminateBlockInst(const TerminateBlockInst &TBI)
+ : TerminatorInst(TBI.getType(), Instruction::TerminateBlock,
+ OperandTraits<TerminateBlockInst>::op_end(this) -
+ TBI.getNumOperands(),
+ TBI.getNumOperands()) {
+ SubclassOptionalData = TBI.SubclassOptionalData;
+ std::copy(TBI.op_begin(), TBI.op_end(), op_begin());
+}
+
+TerminateBlockInst::TerminateBlockInst(LLVMContext &C, BasicBlock *BB,
+ ArrayRef<Value *> Args, unsigned Values,
+ const Twine &NameStr,
+ Instruction *InsertBefore)
+ : TerminatorInst(Type::getVoidTy(C), Instruction::TerminateBlock,
+ OperandTraits<TerminateBlockInst>::op_end(this) - Values,
+ Values, InsertBefore) {
+ init(BB, Args, NameStr);
+}
+
+TerminateBlockInst::TerminateBlockInst(LLVMContext &C, BasicBlock *BB,
+ ArrayRef<Value *> Args, unsigned Values,
+ const Twine &NameStr,
+ BasicBlock *InsertAtEnd)
+ : TerminatorInst(Type::getVoidTy(C), Instruction::TerminateBlock,
+ OperandTraits<TerminateBlockInst>::op_end(this) - Values,
+ Values, InsertAtEnd) {
+ init(BB, Args, NameStr);
+}
+
+BasicBlock *TerminateBlockInst::getSuccessorV(unsigned Idx) const {
+ assert(Idx == 0);
+ return getUnwindDest();
+}
+unsigned TerminateBlockInst::getNumSuccessorsV() const {
+ return getNumSuccessors();
+}
+void TerminateBlockInst::setSuccessorV(unsigned Idx, BasicBlock *B) {
+ assert(Idx == 0);
+ return setUnwindDest(B);
+}
+
+//===----------------------------------------------------------------------===//
+// CleanupBlockInst Implementation
+//===----------------------------------------------------------------------===//
+void CleanupBlockInst::init(ArrayRef<Value *> Args, const Twine &NameStr) {
+ assert(getNumOperands() == Args.size() && "NumOperands not set up?");
+ std::copy(Args.begin(), Args.end(), op_begin());
+ setName(NameStr);
+}
+
+CleanupBlockInst::CleanupBlockInst(const CleanupBlockInst &CBI)
+ : Instruction(CBI.getType(), Instruction::CleanupBlock,
+ OperandTraits<CleanupBlockInst>::op_end(this) -
+ CBI.getNumOperands(),
+ CBI.getNumOperands()) {
+ std::copy(CBI.op_begin(), CBI.op_end(), op_begin());
+}
+
+CleanupBlockInst::CleanupBlockInst(Type *RetTy, ArrayRef<Value *> Args,
+ const Twine &NameStr,
+ Instruction *InsertBefore)
+ : Instruction(RetTy, Instruction::CleanupBlock,
+ OperandTraits<CleanupBlockInst>::op_end(this) - Args.size(),
+ Args.size(), InsertBefore) {
+ init(Args, NameStr);
+}
+
+CleanupBlockInst::CleanupBlockInst(Type *RetTy, ArrayRef<Value *> Args,
+ const Twine &NameStr,
+ BasicBlock *InsertAtEnd)
+ : Instruction(RetTy, Instruction::CleanupBlock,
+ OperandTraits<CleanupBlockInst>::op_end(this) - Args.size(),
+ Args.size(), InsertAtEnd) {
+ init(Args, NameStr);
+}
+
+//===----------------------------------------------------------------------===//
// UnreachableInst Implementation
//===----------------------------------------------------------------------===//
@@ -3618,6 +3915,30 @@ InvokeInst *InvokeInst::cloneImpl() const {
ResumeInst *ResumeInst::cloneImpl() const { return new (1) ResumeInst(*this); }
+CleanupReturnInst *CleanupReturnInst::cloneImpl() const {
+ return new (getNumOperands()) CleanupReturnInst(*this);
+}
+
+CatchEndBlockInst *CatchEndBlockInst::cloneImpl() const {
+ return new (getNumOperands()) CatchEndBlockInst(*this);
+}
+
+CatchReturnInst *CatchReturnInst::cloneImpl() const {
+ return new (1) CatchReturnInst(*this);
+}
+
+CatchBlockInst *CatchBlockInst::cloneImpl() const {
+ return new (getNumOperands()) CatchBlockInst(*this);
+}
+
+TerminateBlockInst *TerminateBlockInst::cloneImpl() const {
+ return new (getNumOperands()) TerminateBlockInst(*this);
+}
+
+CleanupBlockInst *CleanupBlockInst::cloneImpl() const {
+ return new (getNumOperands()) CleanupBlockInst(*this);
+}
+
UnreachableInst *UnreachableInst::cloneImpl() const {
LLVMContext &Context = getContext();
return new UnreachableInst(Context);
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 647920f23da..b6df70869b5 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -380,6 +380,10 @@ private:
void visitExtractValueInst(ExtractValueInst &EVI);
void visitInsertValueInst(InsertValueInst &IVI);
void visitLandingPadInst(LandingPadInst &LPI);
+ void visitCatchBlockInst(CatchBlockInst &CBI);
+ void visitCatchEndBlockInst(CatchEndBlockInst &CEBI);
+ void visitCleanupBlockInst(CleanupBlockInst &CBI);
+ void visitTerminateBlockInst(TerminateBlockInst &TBI);
void VerifyCallSite(CallSite CS);
void verifyMustTailCall(CallInst &CI);
@@ -2404,10 +2408,12 @@ void Verifier::visitCallInst(CallInst &CI) {
void Verifier::visitInvokeInst(InvokeInst &II) {
VerifyCallSite(&II);
- // Verify that there is a landingpad instruction as the first non-PHI
+ // Verify that there is an exception block instruction is the first non-PHI
// instruction of the 'unwind' destination.
- Assert(II.getUnwindDest()->isLandingPad(),
- "The unwind destination does not have a landingpad instruction!", &II);
+ Assert(
+ II.getUnwindDest()->isEHBlock(),
+ "The unwind destination does not have an exception handling instruction!",
+ &II);
visitTerminatorInst(II);
}
@@ -2818,6 +2824,72 @@ void Verifier::visitLandingPadInst(LandingPadInst &LPI) {
visitInstruction(LPI);
}
+void Verifier::visitCatchBlockInst(CatchBlockInst &CBI) {
+ BasicBlock *BB = CBI.getParent();
+
+ Function *F = BB->getParent();
+ Assert(F->hasPersonalityFn(),
+ "CatchBlockInst needs to be in a function with a personality.", &CBI);
+
+ // The catchblock instruction must be the first non-PHI instruction in the
+ // block.
+ Assert(BB->getFirstNonPHI() == &CBI,
+ "CatchBlockInst not the first non-PHI instruction in the block.",
+ &CBI);
+
+ visitTerminatorInst(CBI);
+}
+
+void Verifier::visitCatchEndBlockInst(CatchEndBlockInst &CEBI) {
+ BasicBlock *BB = CEBI.getParent();
+
+ Function *F = BB->getParent();
+ Assert(F->hasPersonalityFn(),
+ "CatchEndBlockInst needs to be in a function with a personality.",
+ &CEBI);
+
+ // The catchendblock instruction must be the first non-PHI instruction in the
+ // block.
+ Assert(BB->getFirstNonPHI() == &CEBI,
+ "CatchEndBlockInst not the first non-PHI instruction in the block.",
+ &CEBI);
+
+ visitTerminatorInst(CEBI);
+}
+
+void Verifier::visitCleanupBlockInst(CleanupBlockInst &CBI) {
+ BasicBlock *BB = CBI.getParent();
+
+ Function *F = BB->getParent();
+ Assert(F->hasPersonalityFn(),
+ "CleanupBlockInst needs to be in a function with a personality.", &CBI);
+
+ // The cleanupblock instruction must be the first non-PHI instruction in the
+ // block.
+ Assert(BB->getFirstNonPHI() == &CBI,
+ "CleanupBlockInst not the first non-PHI instruction in the block.",
+ &CBI);
+
+ visitInstruction(CBI);
+}
+
+void Verifier::visitTerminateBlockInst(TerminateBlockInst &TBI) {
+ BasicBlock *BB = TBI.getParent();
+
+ Function *F = BB->getParent();
+ Assert(F->hasPersonalityFn(),
+ "TerminateBlockInst needs to be in a function with a personality.",
+ &TBI);
+
+ // The terminateblock instruction must be the first non-PHI instruction in the
+ // block.
+ Assert(BB->getFirstNonPHI() == &TBI,
+ "TerminateBlockInst not the first non-PHI instruction in the block.",
+ &TBI);
+
+ visitTerminatorInst(TBI);
+}
+
void Verifier::verifyDominatesUse(Instruction &I, unsigned i) {
Instruction *Op = cast<Instruction>(I.getOperand(i));
// If the we have an invalid invoke, don't try to compute the dominance.
OpenPOWER on IntegriCloud