[llvm] r323256 - [Debugify] Add a mode to opt to enable faster testing

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 23 12:43:50 PST 2018


Author: vedantk
Date: Tue Jan 23 12:43:50 2018
New Revision: 323256

URL: http://llvm.org/viewvc/llvm-project?rev=323256&view=rev
Log:
[Debugify] Add a mode to opt to enable faster testing

Opt's "-enable-debugify" mode adds an instance of Debugify at the
beginning of the pass pipeline, and an instance of CheckDebugify at the
end.

You can enable this mode with lit using: -Dopt="opt -enable-debugify".
Note that running test suites in this mode will result in many failures
due to strict FileCheck commands, etc.

It can be more useful to look for assertion failures which arise only
when Debugify is enabled, e.g to prove that we have (or do not have)
test coverage for some code path with debug info present.

Differential Revision: https://reviews.llvm.org/D41793

Modified:
    llvm/trunk/test/DebugInfo/debugify.ll
    llvm/trunk/tools/opt/Debugify.cpp
    llvm/trunk/tools/opt/opt.cpp

Modified: llvm/trunk/test/DebugInfo/debugify.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/debugify.ll?rev=323256&r1=323255&r2=323256&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/debugify.ll (original)
+++ llvm/trunk/test/DebugInfo/debugify.ll Tue Jan 23 12:43:50 2018
@@ -9,6 +9,9 @@
 ; RUN: opt -debugify -strip -check-debugify -S -o - < %s | \
 ; RUN:   FileCheck %s -check-prefix=CHECK-FAIL
 
+; RUN: opt -enable-debugify -strip -S -o - < %s | \
+; RUN:   FileCheck %s -check-prefix=CHECK-FAIL
+
 ; CHECK-LABEL: define void @foo
 define void @foo() {
 ; CHECK: ret void, !dbg ![[RET1:.*]]

Modified: llvm/trunk/tools/opt/Debugify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/Debugify.cpp?rev=323256&r1=323255&r2=323256&view=diff
==============================================================================
--- llvm/trunk/tools/opt/Debugify.cpp (original)
+++ llvm/trunk/tools/opt/Debugify.cpp Tue Jan 23 12:43:50 2018
@@ -204,6 +204,10 @@ struct CheckDebugifyPass : public Module
 
 } // end anonymous namespace
 
+ModulePass *createDebugifyPass() { return new DebugifyPass(); }
+
+ModulePass *createCheckDebugifyPass() { return new CheckDebugifyPass(); }
+
 char DebugifyPass::ID = 0;
 static RegisterPass<DebugifyPass> X("debugify",
                                     "Attach debug info to everything");

Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=323256&r1=323255&r2=323256&view=diff
==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Tue Jan 23 12:43:50 2018
@@ -203,6 +203,11 @@ QuietA("quiet", cl::desc("Alias for -q")
 static cl::opt<bool>
 AnalyzeOnly("analyze", cl::desc("Only perform analysis, no optimization"));
 
+static cl::opt<bool> EnableDebugify(
+    "enable-debugify",
+    cl::desc(
+        "Start the pipeline with debugify and end it with check-debugify"));
+
 static cl::opt<bool>
 PrintBreakpoints("print-breakpoints-for-testing",
                  cl::desc("Print select breakpoints location for testing"));
@@ -252,6 +257,9 @@ static cl::opt<std::string>
                     cl::desc("YAML output filename for pass remarks"),
                     cl::value_desc("filename"));
 
+extern ModulePass *createDebugifyPass();
+extern ModulePass *createCheckDebugifyPass();
+
 static inline void addPass(legacy::PassManagerBase &PM, Pass *P) {
   // Add the pass to the pass manager...
   PM.add(P);
@@ -570,6 +578,9 @@ int main(int argc, char **argv) {
   Passes.add(createTargetTransformInfoWrapperPass(TM ? TM->getTargetIRAnalysis()
                                                      : TargetIRAnalysis()));
 
+  if (EnableDebugify)
+    Passes.add(createDebugifyPass());
+
   std::unique_ptr<legacy::FunctionPassManager> FPasses;
   if (OptLevelO0 || OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz ||
       OptLevelO3) {
@@ -715,6 +726,9 @@ int main(int argc, char **argv) {
   if (!NoVerify && !VerifyEach)
     Passes.add(createVerifierPass());
 
+  if (EnableDebugify)
+    Passes.add(createCheckDebugifyPass());
+
   // In run twice mode, we want to make sure the output is bit-by-bit
   // equivalent if we run the pass manager again, so setup two buffers and
   // a stream to write to them. Note that llc does something similar and it




More information about the llvm-commits mailing list