mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-28 14:10:41 +00:00
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
This commit is contained in:
parent
10f24ca2ad
commit
a60d430e31
@ -56,20 +56,9 @@ bool verifyModule(const Module &M, raw_ostream *OS = nullptr);
|
||||
/// printed to stderr, and by default they are fatal. You can override that by
|
||||
/// passing \c false to \p FatalErrors.
|
||||
///
|
||||
/// 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);
|
||||
|
||||
/// \brief Create a debug-info verifier pass.
|
||||
///
|
||||
/// Check a module for validity of debug info. This is essentially a pass
|
||||
/// wrapped around the debug-info parts of \a verifyModule(). When the pass
|
||||
/// detects a verification error it is always printed to stderr, and by default
|
||||
/// they are fatal. You can override that by passing \c false to \p
|
||||
/// FatalErrors.
|
||||
///
|
||||
/// Note that this creates a pass suitable for the legacy pass manager. It has
|
||||
/// nothing to do with \c VerifierPass.
|
||||
ModulePass *createDebugInfoVerifierPass(bool FatalErrors = true);
|
||||
FunctionPass *createVerifierPass(bool FatalErrors = true);
|
||||
|
||||
class VerifierPass {
|
||||
bool FatalErrors;
|
||||
|
@ -106,7 +106,6 @@ void initializeDAEPass(PassRegistry&);
|
||||
void initializeDAHPass(PassRegistry&);
|
||||
void initializeDCEPass(PassRegistry&);
|
||||
void initializeDSEPass(PassRegistry&);
|
||||
void initializeDebugInfoVerifierLegacyPassPass(PassRegistry &);
|
||||
void initializeDeadInstEliminationPass(PassRegistry&);
|
||||
void initializeDeadMachineInstructionElimPass(PassRegistry&);
|
||||
void initializeDelinearizationPass(PassRegistry &);
|
||||
|
@ -374,10 +374,8 @@ void TargetPassConfig::addIRPasses() {
|
||||
|
||||
// Before running any passes, run the verifier to determine if the input
|
||||
// coming from the front-end and/or optimizer is valid.
|
||||
if (!DisableVerify) {
|
||||
if (!DisableVerify)
|
||||
addPass(createVerifierPass());
|
||||
addPass(createDebugInfoVerifierPass());
|
||||
}
|
||||
|
||||
// Run loop strength reduction before anything else.
|
||||
if (getOptLevel() != CodeGenOpt::None && !DisableLSR) {
|
||||
@ -448,12 +446,6 @@ void TargetPassConfig::addCodeGenPrepare() {
|
||||
void TargetPassConfig::addISelPrepare() {
|
||||
addPreISel();
|
||||
|
||||
// Need to verify DebugInfo *before* creating the stack protector analysis.
|
||||
// It's a function pass, and verifying between it and its users causes a
|
||||
// crash.
|
||||
if (!DisableVerify)
|
||||
addPass(createDebugInfoVerifierPass());
|
||||
|
||||
addPass(createStackProtectorPass(TM));
|
||||
|
||||
if (PrintISelInput)
|
||||
|
@ -3147,30 +3147,8 @@ struct VerifierLegacyPass : public FunctionPass {
|
||||
if (!V.verify(M) && FatalErrors)
|
||||
report_fatal_error("Broken module found, compilation aborted!");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
AU.setPreservesAll();
|
||||
}
|
||||
};
|
||||
struct DebugInfoVerifierLegacyPass : public ModulePass {
|
||||
static char ID;
|
||||
|
||||
DebugInfoVerifier V;
|
||||
bool FatalErrors;
|
||||
|
||||
DebugInfoVerifierLegacyPass() : ModulePass(ID), FatalErrors(true) {
|
||||
initializeDebugInfoVerifierLegacyPassPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
explicit DebugInfoVerifierLegacyPass(bool FatalErrors)
|
||||
: ModulePass(ID), V(dbgs()), FatalErrors(FatalErrors) {
|
||||
initializeDebugInfoVerifierLegacyPassPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
bool runOnModule(Module &M) override {
|
||||
if (!V.verify(M) && FatalErrors)
|
||||
report_fatal_error("Broken debug info found, compilation aborted!");
|
||||
if (!DebugInfoVerifier(dbgs()).verify(M) && FatalErrors)
|
||||
report_fatal_error("Broken module found, compilation aborted!");
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -3184,18 +3162,10 @@ struct DebugInfoVerifierLegacyPass : public ModulePass {
|
||||
char VerifierLegacyPass::ID = 0;
|
||||
INITIALIZE_PASS(VerifierLegacyPass, "verify", "Module Verifier", false, false)
|
||||
|
||||
char DebugInfoVerifierLegacyPass::ID = 0;
|
||||
INITIALIZE_PASS(DebugInfoVerifierLegacyPass, "verify-di", "Debug Info Verifier",
|
||||
false, false)
|
||||
|
||||
FunctionPass *llvm::createVerifierPass(bool FatalErrors) {
|
||||
return new VerifierLegacyPass(FatalErrors);
|
||||
}
|
||||
|
||||
ModulePass *llvm::createDebugInfoVerifierPass(bool FatalErrors) {
|
||||
return new DebugInfoVerifierLegacyPass(FatalErrors);
|
||||
}
|
||||
|
||||
PreservedAnalyses VerifierPass::run(Module &M) {
|
||||
if (verifyModule(M, &dbgs()) && FatalErrors)
|
||||
report_fatal_error("Broken module found, compilation aborted!");
|
||||
|
@ -471,7 +471,6 @@ void LTOCodeGenerator::applyScopeRestrictions() {
|
||||
// Start off with a verification pass.
|
||||
legacy::PassManager passes;
|
||||
passes.add(createVerifierPass());
|
||||
passes.add(createDebugInfoVerifierPass());
|
||||
|
||||
// mark which symbols can not be internalized
|
||||
Mangler Mangler(TargetMach->getDataLayout());
|
||||
|
@ -511,10 +511,8 @@ void PassManagerBuilder::populateLTOPassManager(legacy::PassManagerBase &PM) {
|
||||
if (LibraryInfo)
|
||||
PM.add(new TargetLibraryInfoWrapperPass(*LibraryInfo));
|
||||
|
||||
if (VerifyInput) {
|
||||
if (VerifyInput)
|
||||
PM.add(createVerifierPass());
|
||||
PM.add(createDebugInfoVerifierPass());
|
||||
}
|
||||
|
||||
if (OptLevel > 1)
|
||||
addLTOOptimizationPasses(PM);
|
||||
@ -527,10 +525,8 @@ void PassManagerBuilder::populateLTOPassManager(legacy::PassManagerBase &PM) {
|
||||
if (OptLevel != 0)
|
||||
addLateLTOOptimizationPasses(PM);
|
||||
|
||||
if (VerifyOutput) {
|
||||
if (VerifyOutput)
|
||||
PM.add(createVerifierPass());
|
||||
PM.add(createDebugInfoVerifierPass());
|
||||
}
|
||||
}
|
||||
|
||||
inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) {
|
||||
|
@ -210,7 +210,6 @@ void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM) {
|
||||
|
||||
void LLVMAddVerifierPass(LLVMPassManagerRef PM) {
|
||||
unwrap(PM)->add(createVerifierPass());
|
||||
// FIXME: should this also add createDebugInfoVerifierPass()?
|
||||
}
|
||||
|
||||
void LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM) {
|
||||
|
@ -409,7 +409,6 @@ bool ReduceCrashingInstructions::TestInsts(std::vector<const Instruction*>
|
||||
// Verify that this is still valid.
|
||||
legacy::PassManager Passes;
|
||||
Passes.add(createVerifierPass());
|
||||
Passes.add(createDebugInfoVerifierPass());
|
||||
Passes.run(*M);
|
||||
|
||||
// Try running on the hacked up program...
|
||||
|
@ -713,7 +713,6 @@ int main(int argc, char **argv) {
|
||||
|
||||
legacy::PassManager Passes;
|
||||
Passes.add(createVerifierPass());
|
||||
Passes.add(createDebugInfoVerifierPass());
|
||||
Passes.add(createPrintModulePass(Out->os()));
|
||||
Passes.run(*M.get());
|
||||
Out->keep();
|
||||
|
@ -185,10 +185,8 @@ static inline void addPass(legacy::PassManagerBase &PM, Pass *P) {
|
||||
PM.add(P);
|
||||
|
||||
// If we are verifying all of the intermediate steps, add the verifier...
|
||||
if (VerifyEach) {
|
||||
if (VerifyEach)
|
||||
PM.add(createVerifierPass());
|
||||
PM.add(createDebugInfoVerifierPass());
|
||||
}
|
||||
}
|
||||
|
||||
/// This routine adds optimization passes based on selected optimization level,
|
||||
@ -198,8 +196,7 @@ static inline void addPass(legacy::PassManagerBase &PM, Pass *P) {
|
||||
static void AddOptimizationPasses(legacy::PassManagerBase &MPM,
|
||||
legacy::FunctionPassManager &FPM,
|
||||
unsigned OptLevel, unsigned SizeLevel) {
|
||||
FPM.add(createVerifierPass()); // Verify that input is correct
|
||||
MPM.add(createDebugInfoVerifierPass()); // Verify that debug info is correct
|
||||
FPM.add(createVerifierPass()); // Verify that input is correct
|
||||
|
||||
PassManagerBuilder Builder;
|
||||
Builder.OptLevel = OptLevel;
|
||||
@ -558,10 +555,8 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
// Check that the module is well formed on completion of optimization
|
||||
if (!NoVerify && !VerifyEach) {
|
||||
if (!NoVerify && !VerifyEach)
|
||||
Passes.add(createVerifierPass());
|
||||
Passes.add(createDebugInfoVerifierPass());
|
||||
}
|
||||
|
||||
// Write bitcode or assembly to the output as the last step...
|
||||
if (!NoOutput && !AnalyzeOnly) {
|
||||
|
Loading…
Reference in New Issue
Block a user