]> granicus.if.org Git - llvm/commitdiff
Revert "Separate the Verifier into an analysis and a transformation pass and"
authorAdrian Prantl <aprantl@apple.com>
Mon, 9 May 2016 17:43:24 +0000 (17:43 +0000)
committerAdrian Prantl <aprantl@apple.com>
Mon, 9 May 2016 17:43:24 +0000 (17:43 +0000)
This reverts commit 268937 while investigating build bot breakage.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268939 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/DiagnosticInfo.h
include/llvm/IR/Verifier.h
lib/IR/DiagnosticInfo.cpp
lib/IR/Verifier.cpp
lib/Passes/PassRegistry.def
unittests/IR/VerifierTest.cpp

index 78d7de27b43a16f3998883fbd5305abcd72347de..3bcf7345d9e34936d98c5954ab7e299328447e80 100644 (file)
@@ -51,7 +51,6 @@ enum DiagnosticKind {
   DK_StackSize,
   DK_Linker,
   DK_DebugMetadataVersion,
-  DK_DebugMetadataInvalid,
   DK_SampleProfile,
   DK_OptimizationRemark,
   DK_OptimizationRemarkMissed,
@@ -215,29 +214,6 @@ public:
   }
 };
 
-/// Diagnostic information for stripping invalid debug metadata.
-class DiagnosticInfoIgnoringInvalidDebugMetadata : public DiagnosticInfo {
-private:
-  /// The module that is concerned by this debug metadata version diagnostic.
-  const Module &M;
-
-public:
-  /// \p The module that is concerned by this debug metadata version diagnostic.
-  DiagnosticInfoIgnoringInvalidDebugMetadata(
-      const Module &M, DiagnosticSeverity Severity = DS_Warning)
-      : DiagnosticInfo(DK_DebugMetadataVersion, Severity), M(M) {}
-
-  const Module &getModule() const { return M; }
-
-  /// \see DiagnosticInfo::print.
-  void print(DiagnosticPrinter &DP) const override;
-
-  static bool classof(const DiagnosticInfo *DI) {
-    return DI->getKind() == DK_DebugMetadataInvalid;
-  }
-};
-
-
 /// Diagnostic information for the sample profiler.
 class DiagnosticInfoSampleProfile : public DiagnosticInfo {
 public:
index 654b29c5fcbcad35885a024d16df74512ee2f1ed..70bec787a4c7d1548ab064b4fdb73ee69ae1bab9 100644 (file)
@@ -52,28 +52,6 @@ bool verifyFunction(const Function &F, raw_ostream *OS = nullptr);
 bool verifyModule(const Module &M, raw_ostream *OS = nullptr,
                   bool *BrokenDebugInfo = nullptr);
 
-FunctionPass *createVerifierPass(bool FatalErrors = true);
-
-/// Check a module for errors, and report separate error states for IR
-/// and debug info errors.
-class VerifierAnalysis : public AnalysisInfoMixin<VerifierAnalysis> {
-  friend AnalysisInfoMixin<VerifierAnalysis>;
-  static char PassID;
-
-public:
-  struct Result {
-    bool IRBroken, DebugInfoBroken;
-  };
-  static void *ID() { return (void *)&PassID; }
-  Result run(Module &M);
-  Result run(Function &F);
-};
-
-/// Check a module for errors, but report debug info errors separately.
-/// Otherwise behaves as the normal verifyModule. Debug info errors can be
-/// "recovered" from by stripping the debug info.
-bool verifyModule(bool &BrokenDebugInfo, const Module &M, raw_ostream *OS);
-
 /// \brief Create a verifier pass.
 ///
 /// Check a module or function for validity. This is essentially a pass wrapped
@@ -84,17 +62,18 @@ bool verifyModule(bool &BrokenDebugInfo, const Module &M, raw_ostream *OS);
 ///
 /// Note that this creates a pass suitable for the legacy pass manager. It has
 /// nothing to do with \c VerifierPass.
+FunctionPass *createVerifierPass(bool FatalErrors = true);
+
 class VerifierPass : public PassInfoMixin<VerifierPass> {
   bool FatalErrors;
 
 public:
   explicit VerifierPass(bool FatalErrors = true) : FatalErrors(FatalErrors) {}
 
-  PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+  PreservedAnalyses run(Module &M);
+  PreservedAnalyses run(Function &F);
 };
 
-
 } // End llvm namespace
 
 #endif
index 91463ec5f1e1ebde4491bf75375fb28a61ccc2b8..10d9d55ed719b87853a14eeea50ac52571de4123 100644 (file)
@@ -122,11 +122,6 @@ void DiagnosticInfoDebugMetadataVersion::print(DiagnosticPrinter &DP) const {
      << ") in " << getModule();
 }
 
-void DiagnosticInfoIgnoringInvalidDebugMetadata::print(
-    DiagnosticPrinter &DP) const {
-  DP << "ignoring invalid debug info in " << getModule().getModuleIdentifier();
-}
-
 void DiagnosticInfoSampleProfile::print(DiagnosticPrinter &DP) const {
   if (!FileName.empty()) {
     DP << getFileName();
index 9abe8d850f56964ab223764582010bc67adc1e13..e09f763f10bcf63234aa2e0d208dae5339ac45b6 100644 (file)
@@ -59,7 +59,6 @@
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/DerivedTypes.h"
-#include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/InstIterator.h"
@@ -4483,38 +4482,15 @@ FunctionPass *llvm::createVerifierPass(bool FatalErrors) {
   return new VerifierLegacyPass(FatalErrors);
 }
 
-char VerifierAnalysis::PassID;
-VerifierAnalysis::Result VerifierAnalysis::run(Module &M) {
-  Result Res;
-  Res.IRBroken = llvm::verifyModule(M, &dbgs(), &Res.DebugInfoBroken);
-  return Res;
-}
-
-VerifierAnalysis::Result VerifierAnalysis::run(Function &F) {
-  return { llvm::verifyFunction(F, &dbgs()), false };
-}
+PreservedAnalyses VerifierPass::run(Module &M) {
+  if (verifyModule(M, &dbgs()) && FatalErrors)
+    report_fatal_error("Broken module found, compilation aborted!");
 
-PreservedAnalyses VerifierPass::run(Module &M, ModuleAnalysisManager &AM) {
-  auto Res = AM.getResult<VerifierAnalysis>(M);
-  if (FatalErrors) {
-    if (Res.IRBroken)
-      report_fatal_error("Broken module found, compilation aborted!");
-    assert(!Res.DebugInfoBroken && "Module contains invalid debug info");
-  }
-
-  // Strip broken debug info.
-  if (Res.DebugInfoBroken) {
-    DiagnosticInfoIgnoringInvalidDebugMetadata DiagInvalid(M);
-    M.getContext().diagnose(DiagInvalid);
-    if (!StripDebugInfo(M))
-      report_fatal_error("Failed to strip malformed debug info");
-  }
   return PreservedAnalyses::all();
 }
 
-PreservedAnalyses VerifierPass::run(Function &F, FunctionAnalysisManager &AM) {
-  auto res = AM.getResult<VerifierAnalysis>(F);
-  if (res.IRBroken && FatalErrors)
+PreservedAnalyses VerifierPass::run(Function &F) {
+  if (verifyFunction(F, &dbgs()) && FatalErrors)
     report_fatal_error("Broken function found, compilation aborted!");
 
   return PreservedAnalyses::all();
index d79a39cf952325c079a9591bbd70fced063359cd..9a31be3c8169f8b79d7b2d27a98b8a9124f6d2a5 100644 (file)
@@ -23,7 +23,6 @@ MODULE_ANALYSIS("callgraph", CallGraphAnalysis())
 MODULE_ANALYSIS("lcg", LazyCallGraphAnalysis())
 MODULE_ANALYSIS("no-op-module", NoOpModuleAnalysis())
 MODULE_ANALYSIS("targetlibinfo", TargetLibraryAnalysis())
-MODULE_ANALYSIS("verify", VerifierAnalysis())
 
 #ifndef MODULE_ALIAS_ANALYSIS
 #define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS)                             \
@@ -88,7 +87,6 @@ FUNCTION_ANALYSIS("scalar-evolution", ScalarEvolutionAnalysis())
 FUNCTION_ANALYSIS("targetlibinfo", TargetLibraryAnalysis())
 FUNCTION_ANALYSIS("targetir",
                   TM ? TM->getTargetIRAnalysis() : TargetIRAnalysis())
-FUNCTION_ANALYSIS("verify", VerifierAnalysis())
 
 #ifndef FUNCTION_ALIAS_ANALYSIS
 #define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS)                             \
index 1fc50da16a9d2867c3c3336b520cda1c83d9b9b5..8b951739e4710558fcc5cd16f72bcfc469870330 100644 (file)
@@ -144,30 +144,5 @@ TEST(VerifierTest, CrossModuleMetadataRef) {
   EXPECT_TRUE(StringRef(ErrorOS.str())
                   .startswith("Referencing global in another module!"));
 }
-
-TEST(VerifierTest, StripInvalidDebugInfo) {
-  LLVMContext C;
-  Module M("M", C);
-  DIBuilder DIB(M);
-  DIB.createCompileUnit(dwarf::DW_LANG_C89, "broken.c", "/",
-                        "unittest", false, "", 0);
-  DIB.finalize();
-  EXPECT_FALSE(verifyModule(M));
-
-  // Now break it.
-  auto *File = DIB.createFile("not-a-CU.f", ".");
-  NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
-  NMD->addOperand(File);
-  EXPECT_TRUE(verifyModule(M));
-
-  ModulePassManager MPM(true);
-  MPM.addPass(VerifierPass(false));
-  ModuleAnalysisManager MAM(true);
-  MAM.registerPass([&] { return VerifierAnalysis(); });
-  MPM.run(M, MAM);
-  EXPECT_FALSE(verifyModule(M));
-}
-
-
 } // end anonymous namespace
 } // end namespace llvm