llvm.org GIT mirror llvm / a60d430
Verifier: Remove the separate -verify-di pass Remove `DebugInfoVerifierLegacyPass` and the `-verify-di` pass. Instead, call into the `DebugInfoVerifier` from inside `VerifierLegacyPass::finalizeModule()`. This better matches the logic in `verifyModule()` (used by the new PassManager), avoids requiring two separate passes to verify the IR, and makes the API for "add a pass to verify the IR" simple. Note: the `-verify-debug-info` flag still works (for now, at least; eventually it might make sense to just remove it). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232772 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 4 years ago
10 changed file(s) with 10 addition(s) and 73 deletion(s). Raw diff Collapse all Expand all
5555 /// printed to stderr, and by default they are fatal. You can override that by
5656 /// passing \c false to \p FatalErrors.
5757 ///
58 /// Note that this creates a pass suitable for the legacy pass manager. It has nothing to do with \c VerifierPass.
59 FunctionPass *createVerifierPass(bool FatalErrors = true);
60
61 /// \brief Create a debug-info verifier pass.
62 ///
63 /// Check a module for validity of debug info. This is essentially a pass
64 /// wrapped around the debug-info parts of \a verifyModule(). When the pass
65 /// detects a verification error it is always printed to stderr, and by default
66 /// they are fatal. You can override that by passing \c false to \p
67 /// FatalErrors.
68 ///
6958 /// Note that this creates a pass suitable for the legacy pass manager. It has
7059 /// nothing to do with \c VerifierPass.
71 ModulePass *createDebugInfoVerifierPass(bool FatalErrors = true);
60 FunctionPass *createVerifierPass(bool FatalErrors = true);
7261
7362 class VerifierPass {
7463 bool FatalErrors;
105105 void initializeDAHPass(PassRegistry&);
106106 void initializeDCEPass(PassRegistry&);
107107 void initializeDSEPass(PassRegistry&);
108 void initializeDebugInfoVerifierLegacyPassPass(PassRegistry &);
109108 void initializeDeadInstEliminationPass(PassRegistry&);
110109 void initializeDeadMachineInstructionElimPass(PassRegistry&);
111110 void initializeDelinearizationPass(PassRegistry &);
373373
374374 // Before running any passes, run the verifier to determine if the input
375375 // coming from the front-end and/or optimizer is valid.
376 if (!DisableVerify) {
376 if (!DisableVerify)
377377 addPass(createVerifierPass());
378 addPass(createDebugInfoVerifierPass());
379 }
380378
381379 // Run loop strength reduction before anything else.
382380 if (getOptLevel() != CodeGenOpt::None && !DisableLSR) {
447445 void TargetPassConfig::addISelPrepare() {
448446 addPreISel();
449447
450 // Need to verify DebugInfo *before* creating the stack protector analysis.
451 // It's a function pass, and verifying between it and its users causes a
452 // crash.
453 if (!DisableVerify)
454 addPass(createDebugInfoVerifierPass());
455
456448 addPass(createStackProtectorPass(TM));
457449
458450 if (PrintISelInput)
31463146 if (!V.verify(M) && FatalErrors)
31473147 report_fatal_error("Broken module found, compilation aborted!");
31483148
3149 if (!DebugInfoVerifier(dbgs()).verify(M) && FatalErrors)
3150 report_fatal_error("Broken module found, compilation aborted!");
3151
31493152 return false;
31503153 }
31513154
31533156 AU.setPreservesAll();
31543157 }
31553158 };
3156 struct DebugInfoVerifierLegacyPass : public ModulePass {
3157 static char ID;
3158
3159 DebugInfoVerifier V;
3160 bool FatalErrors;
3161
3162 DebugInfoVerifierLegacyPass() : ModulePass(ID), FatalErrors(true) {
3163 initializeDebugInfoVerifierLegacyPassPass(*PassRegistry::getPassRegistry());
3164 }
3165 explicit DebugInfoVerifierLegacyPass(bool FatalErrors)
3166 : ModulePass(ID), V(dbgs()), FatalErrors(FatalErrors) {
3167 initializeDebugInfoVerifierLegacyPassPass(*PassRegistry::getPassRegistry());
3168 }
3169
3170 bool runOnModule(Module &M) override {
3171 if (!V.verify(M) && FatalErrors)
3172 report_fatal_error("Broken debug info found, compilation aborted!");
3173
3174 return false;
3175 }
3176
3177 void getAnalysisUsage(AnalysisUsage &AU) const override {
3178 AU.setPreservesAll();
3179 }
3180 };
31813159 }
31823160
31833161 char VerifierLegacyPass::ID = 0;
31843162 INITIALIZE_PASS(VerifierLegacyPass, "verify", "Module Verifier", false, false)
31853163
3186 char DebugInfoVerifierLegacyPass::ID = 0;
3187 INITIALIZE_PASS(DebugInfoVerifierLegacyPass, "verify-di", "Debug Info Verifier",
3188 false, false)
3189
31903164 FunctionPass *llvm::createVerifierPass(bool FatalErrors) {
31913165 return new VerifierLegacyPass(FatalErrors);
3192 }
3193
3194 ModulePass *llvm::createDebugInfoVerifierPass(bool FatalErrors) {
3195 return new DebugInfoVerifierLegacyPass(FatalErrors);
31963166 }
31973167
31983168 PreservedAnalyses VerifierPass::run(Module &M) {
470470 // Start off with a verification pass.
471471 legacy::PassManager passes;
472472 passes.add(createVerifierPass());
473 passes.add(createDebugInfoVerifierPass());
474473
475474 // mark which symbols can not be internalized
476475 Mangler Mangler(TargetMach->getDataLayout());
510510 if (LibraryInfo)
511511 PM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));
512512
513 if (VerifyInput) {
513 if (VerifyInput)
514514 PM.add(createVerifierPass());
515 PM.add(createDebugInfoVerifierPass());
516 }
517515
518516 if (OptLevel > 1)
519517 addLTOOptimizationPasses(PM);
526524 if (OptLevel != 0)
527525 addLateLTOOptimizationPasses(PM);
528526
529 if (VerifyOutput) {
527 if (VerifyOutput)
530528 PM.add(createVerifierPass());
531 PM.add(createDebugInfoVerifierPass());
532 }
533529 }
534530
535531 inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) {
209209
210210 void LLVMAddVerifierPass(LLVMPassManagerRef PM) {
211211 unwrap(PM)->add(createVerifierPass());
212 // FIXME: should this also add createDebugInfoVerifierPass()?
213212 }
214213
215214 void LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM) {
408408 // Verify that this is still valid.
409409 legacy::PassManager Passes;
410410 Passes.add(createVerifierPass());
411 Passes.add(createDebugInfoVerifierPass());
412411 Passes.run(*M);
413412
414413 // Try running on the hacked up program...
712712
713713 legacy::PassManager Passes;
714714 Passes.add(createVerifierPass());
715 Passes.add(createDebugInfoVerifierPass());
716715 Passes.add(createPrintModulePass(Out->os()));
717716 Passes.run(*M.get());
718717 Out->keep();
184184 PM.add(P);
185185
186186 // If we are verifying all of the intermediate steps, add the verifier...
187 if (VerifyEach) {
187 if (VerifyEach)
188188 PM.add(createVerifierPass());
189 PM.add(createDebugInfoVerifierPass());
190 }
191189 }
192190
193191 /// This routine adds optimization passes based on selected optimization level,
197195 static void AddOptimizationPasses(legacy::PassManagerBase &MPM,
198196 legacy::FunctionPassManager &FPM,
199197 unsigned OptLevel, unsigned SizeLevel) {
200 FPM.add(createVerifierPass()); // Verify that input is correct
201 MPM.add(createDebugInfoVerifierPass()); // Verify that debug info is correct
198 FPM.add(createVerifierPass()); // Verify that input is correct
202199
203200 PassManagerBuilder Builder;
204201 Builder.OptLevel = OptLevel;
557554 }
558555
559556 // Check that the module is well formed on completion of optimization
560 if (!NoVerify && !VerifyEach) {
557 if (!NoVerify && !VerifyEach)
561558 Passes.add(createVerifierPass());
562 Passes.add(createDebugInfoVerifierPass());
563 }
564559
565560 // Write bitcode or assembly to the output as the last step...
566561 if (!NoOutput && !AnalyzeOnly) {