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.cpp16
-rw-r--r--llvm/lib/IR/Instructions.cpp321
-rw-r--r--llvm/lib/IR/Verifier.cpp156
5 files changed, 6 insertions, 547 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index a866828c31b..adc620db897 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -2848,66 +2848,8 @@ 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 658c5e24216..0a0449434a7 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 (InsertPt->isEHBlock()) ++InsertPt;
+ if (isa<LandingPadInst>(InsertPt)) ++InsertPt;
return InsertPt;
}
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index 2b09e551b79..c57ba16cf6c 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -196,11 +196,6 @@ 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";
@@ -261,7 +256,6 @@ 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> ";
}
@@ -413,8 +407,6 @@ 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();
@@ -435,8 +427,6 @@ 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();
@@ -465,12 +455,6 @@ 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();
- if (const auto *TBI = dyn_cast<TerminateBlockInst>(this))
- return TBI->unwindsToCaller();
return isa<ResumeInst>(this);
}
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 02cb1205da9..86c921aeda8 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -671,303 +671,6 @@ 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
//===----------------------------------------------------------------------===//
@@ -3915,30 +3618,6 @@ 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 c85be99bc24..647920f23da 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -184,9 +184,6 @@ class Verifier : public InstVisitor<Verifier>, VerifierSupport {
/// \brief Track unresolved string-based type references.
SmallDenseMap<const MDString *, const MDNode *, 32> UnresolvedTypeRefs;
- /// \brief The result value from the personality function.
- Type *PersonalityFnResultTy;
-
/// \brief Whether we've seen a call to @llvm.localescape in this function
/// already.
bool SawFrameEscape;
@@ -197,8 +194,7 @@ class Verifier : public InstVisitor<Verifier>, VerifierSupport {
public:
explicit Verifier(raw_ostream &OS)
- : VerifierSupport(OS), Context(nullptr), PersonalityFnResultTy(nullptr),
- SawFrameEscape(false) {}
+ : VerifierSupport(OS), Context(nullptr), SawFrameEscape(false) {}
bool verify(const Function &F) {
M = F.getParent();
@@ -232,7 +228,6 @@ public:
// FIXME: We strip const here because the inst visitor strips const.
visit(const_cast<Function &>(F));
InstsInThisBlock.clear();
- PersonalityFnResultTy = nullptr;
SawFrameEscape = false;
return !Broken;
@@ -385,11 +380,6 @@ 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 visitCleanupReturnInst(CleanupReturnInst &CRI);
- void visitTerminateBlockInst(TerminateBlockInst &TBI);
void VerifyCallSite(CallSite CS);
void verifyMustTailCall(CallInst &CI);
@@ -2414,12 +2404,10 @@ void Verifier::visitCallInst(CallInst &CI) {
void Verifier::visitInvokeInst(InvokeInst &II) {
VerifyCallSite(&II);
- // Verify that the first non-PHI instruction of the unwind destination is an
- // exception handling instruction.
- Assert(
- II.getUnwindDest()->isEHBlock(),
- "The unwind destination does not have an exception handling instruction!",
- &II);
+ // Verify that there is a landingpad instruction as the first non-PHI
+ // instruction of the 'unwind' destination.
+ Assert(II.getUnwindDest()->isLandingPad(),
+ "The unwind destination does not have a landingpad instruction!", &II);
visitTerminatorInst(II);
}
@@ -2805,14 +2793,6 @@ void Verifier::visitLandingPadInst(LandingPadInst &LPI) {
&LPI);
}
- if (!PersonalityFnResultTy)
- PersonalityFnResultTy = LPI.getType();
- else
- Assert(PersonalityFnResultTy == LPI.getType(),
- "The personality routine should have a consistent result type "
- "inside a function.",
- &LPI);
-
Function *F = LPI.getParent()->getParent();
Assert(F->hasPersonalityFn(),
"LandingPadInst needs to be in a function with a personality.", &LPI);
@@ -2838,132 +2818,6 @@ void Verifier::visitLandingPadInst(LandingPadInst &LPI) {
visitInstruction(LPI);
}
-void Verifier::visitCatchBlockInst(CatchBlockInst &CBI) {
- BasicBlock *BB = CBI.getParent();
-
- if (!PersonalityFnResultTy)
- PersonalityFnResultTy = CBI.getType();
- else
- Assert(PersonalityFnResultTy == CBI.getType(),
- "The personality routine should have a consistent result type "
- "inside a function.",
- &CBI);
-
- 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);
-
- BasicBlock *UnwindDest = CBI.getUnwindDest();
- Instruction *I = UnwindDest->getFirstNonPHI();
- Assert(
- isa<CatchBlockInst>(I) || isa<CatchEndBlockInst>(I),
- "CatchBlockInst must unwind to a CatchBlockInst or a CatchEndBlockInst.",
- &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);
-
- unsigned CatchBlocksSeen = 0;
- for (BasicBlock *PredBB : predecessors(BB))
- if (isa<CatchBlockInst>(PredBB->getTerminator()))
- ++CatchBlocksSeen;
-
- Assert(CatchBlocksSeen <= 1, "CatchEndBlockInst must have no more than one "
- "CatchBlockInst predecessor.",
- &CEBI);
-
- if (BasicBlock *UnwindDest = CEBI.getUnwindDest()) {
- Instruction *I = UnwindDest->getFirstNonPHI();
- Assert(
- I->isEHBlock() && !isa<LandingPadInst>(I),
- "CatchEndBlock must unwind to an EH block which is not a landingpad.",
- &CEBI);
- }
-
- visitTerminatorInst(CEBI);
-}
-
-void Verifier::visitCleanupBlockInst(CleanupBlockInst &CBI) {
- BasicBlock *BB = CBI.getParent();
-
- if (!PersonalityFnResultTy)
- PersonalityFnResultTy = CBI.getType();
- else
- Assert(PersonalityFnResultTy == CBI.getType(),
- "The personality routine should have a consistent result type "
- "inside a function.",
- &CBI);
-
- 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::visitCleanupReturnInst(CleanupReturnInst &CRI) {
- if (BasicBlock *UnwindDest = CRI.getUnwindDest()) {
- Instruction *I = UnwindDest->getFirstNonPHI();
- Assert(I->isEHBlock() && !isa<LandingPadInst>(I),
- "CleanupReturnInst must unwind to an EH block which is not a "
- "landingpad.",
- &CRI);
- }
-
- visitTerminatorInst(CRI);
-}
-
-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);
-
- if (BasicBlock *UnwindDest = TBI.getUnwindDest()) {
- Instruction *I = UnwindDest->getFirstNonPHI();
- Assert(I->isEHBlock() && !isa<LandingPadInst>(I),
- "TerminateBlockInst must unwind to an EH block which is not a "
- "landingpad.",
- &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