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