/// \brief Track the brokenness of the module while recursively visiting.
bool Broken;
+ bool EverBroken;
explicit VerifierSupport(raw_ostream &OS)
- : OS(OS), M(nullptr), Broken(false) {}
+ : OS(OS), M(nullptr), Broken(false), EverBroken(false) {}
private:
void Write(const Value *V) {
/// something is not correct.
void CheckFailed(const Twine &Message) {
OS << Message << '\n';
- Broken = true;
+ EverBroken = Broken = true;
}
/// \brief A check failed (with values to print).
visitModuleFlags(M);
visitModuleIdents(M);
+ // Verify debug info last.
+ verifyDebugInfo();
+
return !Broken;
}
void VerifyConstantExprBitcastType(const ConstantExpr *CE);
void VerifyStatepoint(ImmutableCallSite CS);
void verifyFrameRecoverIndices();
-};
-class DebugInfoVerifier : public VerifierSupport {
-public:
- explicit DebugInfoVerifier(raw_ostream &OS = dbgs()) : VerifierSupport(OS) {}
-
- bool verify(const Module &M) {
- this->M = &M;
- verifyDebugInfo();
- return !Broken;
- }
-private:
+ // Module-level debug info verification...
void verifyDebugInfo();
void processInstructions(DebugInfoFinder &Finder);
void processCallInst(DebugInfoFinder &Finder, const CallInst &CI);
DII.getRawExpression());
}
-void DebugInfoVerifier::verifyDebugInfo() {
- if (!VerifyDebugInfo)
+void Verifier::verifyDebugInfo() {
+ // Run the debug info verifier only if the regular verifier succeeds, since
+ // sometimes checks that have already failed will cause crashes here.
+ if (EverBroken || !VerifyDebugInfo)
return;
DebugInfoFinder Finder;
}
}
-void DebugInfoVerifier::processInstructions(DebugInfoFinder &Finder) {
+void Verifier::processInstructions(DebugInfoFinder &Finder) {
for (const Function &F : *M)
for (auto I = inst_begin(&F), E = inst_end(&F); I != E; ++I) {
if (MDNode *MD = I->getMetadata(LLVMContext::MD_dbg))
}
}
-void DebugInfoVerifier::processCallInst(DebugInfoFinder &Finder,
- const CallInst &CI) {
+void Verifier::processCallInst(DebugInfoFinder &Finder, const CallInst &CI) {
if (Function *F = CI.getCalledFunction())
if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID())
switch (ID) {
// Note that this function's return value is inverted from what you would
// expect of a function called "verify".
- if (!V.verify(M) || Broken)
- return true;
-
- // Run the debug info verifier only if the regular verifier succeeds, since
- // sometimes checks that have already failed will cause crashes here.
- DebugInfoVerifier DIV(OS ? *OS : NullStr);
- return !DIV.verify(M);
+ return !V.verify(M) || Broken;
}
namespace {
if (!V.verify(M) && FatalErrors)
report_fatal_error("Broken module found, compilation aborted!");
- if (!DebugInfoVerifier(dbgs()).verify(M) && FatalErrors)
- report_fatal_error("Broken module found, compilation aborted!");
-
return false;
}