diff options
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 156 |
1 files changed, 5 insertions, 151 deletions
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. |