Index: llvm/include/llvm/IR/PrintPasses.h =================================================================== --- llvm/include/llvm/IR/PrintPasses.h +++ llvm/include/llvm/IR/PrintPasses.h @@ -23,8 +23,18 @@ DiffQuiet, ColourDiffVerbose, ColourDiffQuiet, + LastLLCMode = ColourDiffQuiet, + // rest are opt only modes and not supported by llc DotCfgVerbose, - DotCfgQuiet + DotCfgQuiet, + OptVerbose, + OptQuiet, + OptDiffVerbose, + OptDiffQuiet, + OptColourDiffVerbose, + OptColourDiffQuiet, + OptDotCfgVerbose, + OptDotCfgQuiet }; extern cl::opt PrintChanged; Index: llvm/lib/CodeGen/MachineFunctionPass.cpp =================================================================== --- llvm/lib/CodeGen/MachineFunctionPass.cpp +++ llvm/lib/CodeGen/MachineFunctionPass.cpp @@ -81,6 +81,7 @@ } const bool IsInterestingPass = isPassInPrintList(PassID); const bool ShouldPrintChanged = PrintChanged != ChangePrinter::None && + PrintChanged <= ChangePrinter::LastLLCMode && IsInterestingPass && isFunctionInPrintList(MF.getName()); if (ShouldPrintChanged) { @@ -127,12 +128,10 @@ errs() << ("*** IR Dump After " + getPassName() + " (" + PassID + ") on " + MF.getName() + " ***\n"); switch (PrintChanged) { - case ChangePrinter::None: + default: llvm_unreachable(""); case ChangePrinter::Quiet: case ChangePrinter::Verbose: - case ChangePrinter::DotCfgQuiet: // unimplemented - case ChangePrinter::DotCfgVerbose: // unimplemented errs() << AfterStr; break; case ChangePrinter::DiffQuiet: Index: llvm/lib/IR/PrintPasses.cpp =================================================================== --- llvm/lib/IR/PrintPasses.cpp +++ llvm/lib/IR/PrintPasses.cpp @@ -61,18 +61,35 @@ cl::ValueOptional, cl::init(ChangePrinter::None), cl::values( clEnumValN(ChangePrinter::Quiet, "quiet", "Run in quiet mode"), + clEnumValN(ChangePrinter::OptQuiet, "opt-quiet", + "Run in quiet mode for opt only"), clEnumValN(ChangePrinter::DiffVerbose, "diff", "Display patch-like changes"), + clEnumValN(ChangePrinter::OptDiffVerbose, "opt-diff", + "Display patch-like changes for opt only"), clEnumValN(ChangePrinter::DiffQuiet, "diff-quiet", "Display patch-like changes in quiet mode"), + clEnumValN(ChangePrinter::OptDiffQuiet, "opt-diff-quiet", + "Display patch-like changes in quiet mode for opt only"), clEnumValN(ChangePrinter::ColourDiffVerbose, "cdiff", "Display patch-like changes with color"), + clEnumValN(ChangePrinter::OptColourDiffVerbose, "opt-cdiff", + "Display patch-like changes with color for opt only"), clEnumValN(ChangePrinter::ColourDiffQuiet, "cdiff-quiet", "Display patch-like changes in quiet mode with color"), + clEnumValN( + ChangePrinter::OptColourDiffQuiet, "opt-cdiff-quiet", + "Display patch-like changes in quiet mode with color for opt only"), clEnumValN(ChangePrinter::DotCfgVerbose, "dot-cfg", "Create a website with graphical changes"), + clEnumValN(ChangePrinter::OptDotCfgVerbose, "opt-dot-cfg", + "Create a website with graphical changes for opt only"), clEnumValN(ChangePrinter::DotCfgQuiet, "dot-cfg-quiet", "Create a website with graphical changes in quiet mode"), + clEnumValN(ChangePrinter::OptDotCfgQuiet, "opt-dot-cfg-quiet", + "Create a website with graphical changes in quiet mode for " + "opt only"), + clEnumValN(ChangePrinter::OptVerbose, "opt", "Display for opt only"), // Sentinel value for unspecified option. clEnumValN(ChangePrinter::Verbose, "", ""))); Index: llvm/lib/Passes/StandardInstrumentations.cpp =================================================================== --- llvm/lib/Passes/StandardInstrumentations.cpp +++ llvm/lib/Passes/StandardInstrumentations.cpp @@ -454,7 +454,9 @@ void IRChangedPrinter::registerCallbacks(PassInstrumentationCallbacks &PIC) { if (PrintChanged == ChangePrinter::Verbose || - PrintChanged == ChangePrinter::Quiet) + PrintChanged == ChangePrinter::OptVerbose || + PrintChanged == ChangePrinter::Quiet || + PrintChanged == ChangePrinter::OptQuiet) TextChangeReporter::registerRequiredCallbacks(PIC); } @@ -1157,9 +1159,13 @@ void InLineChangePrinter::registerCallbacks(PassInstrumentationCallbacks &PIC) { if (PrintChanged == ChangePrinter::DiffVerbose || + PrintChanged == ChangePrinter::OptDiffVerbose || PrintChanged == ChangePrinter::DiffQuiet || + PrintChanged == ChangePrinter::OptDiffQuiet || PrintChanged == ChangePrinter::ColourDiffVerbose || - PrintChanged == ChangePrinter::ColourDiffQuiet) + PrintChanged == ChangePrinter::OptColourDiffVerbose || + PrintChanged == ChangePrinter::ColourDiffQuiet || + PrintChanged == ChangePrinter::OptColourDiffQuiet) TextChangeReporter>::registerRequiredCallbacks(PIC); } @@ -2021,7 +2027,9 @@ void DotCfgChangeReporter::registerCallbacks( PassInstrumentationCallbacks &PIC) { if (PrintChanged == ChangePrinter::DotCfgVerbose || - PrintChanged == ChangePrinter::DotCfgQuiet) { + PrintChanged == ChangePrinter::OptDotCfgVerbose || + PrintChanged == ChangePrinter::DotCfgQuiet || + PrintChanged == ChangePrinter::OptDotCfgQuiet) { SmallString<128> OutputDir; sys::fs::expand_tilde(DotCfgDir, OutputDir); sys::fs::make_absolute(OutputDir); @@ -2038,12 +2046,19 @@ StandardInstrumentations::StandardInstrumentations( bool DebugLogging, bool VerifyEach, PrintPassOptions PrintPassOpts) : PrintPass(DebugLogging, PrintPassOpts), OptNone(DebugLogging), - PrintChangedIR(PrintChanged == ChangePrinter::Verbose), + PrintChangedIR(PrintChanged == ChangePrinter::Verbose || + PrintChanged == ChangePrinter::OptVerbose), PrintChangedDiff(PrintChanged == ChangePrinter::DiffVerbose || - PrintChanged == ChangePrinter::ColourDiffVerbose, + PrintChanged == ChangePrinter::OptDiffVerbose || + PrintChanged == ChangePrinter::ColourDiffVerbose || + PrintChanged == ChangePrinter::OptColourDiffVerbose, PrintChanged == ChangePrinter::ColourDiffVerbose || - PrintChanged == ChangePrinter::ColourDiffQuiet), - WebsiteChangeReporter(PrintChanged == ChangePrinter::DotCfgVerbose), + PrintChanged == + ChangePrinter::OptColourDiffVerbose || + PrintChanged == ChangePrinter::ColourDiffQuiet || + PrintChanged == ChangePrinter::OptColourDiffQuiet), + WebsiteChangeReporter(PrintChanged == ChangePrinter::DotCfgVerbose || + PrintChanged == ChangePrinter::OptDotCfgVerbose), Verify(DebugLogging), VerifyEach(VerifyEach) {} PrintCrashIRInstrumentation *PrintCrashIRInstrumentation::CrashReporter = Index: llvm/test/Other/ChangePrinters/DotCfg/print-changed-dot-cfg.ll =================================================================== --- llvm/test/Other/ChangePrinters/DotCfg/print-changed-dot-cfg.ll +++ llvm/test/Other/ChangePrinters/DotCfg/print-changed-dot-cfg.ll @@ -8,6 +8,11 @@ ; RUN: ls %t/*.pdf %t/passes.html | count 4 ; RUN: FileCheck %s -input-file=%t/passes.html --check-prefix=CHECK-DOT-CFG-SIMPLE ; +; RUN: rm -rf %t && mkdir -p %t +; RUN: opt -disable-verify -S -print-changed=opt-dot-cfg -passes=instsimplify -dot-cfg-dir=%t < %s -o /dev/null +; RUN: ls %t/*.pdf %t/passes.html | count 4 +; RUN: FileCheck %s -input-file=%t/passes.html --check-prefix=CHECK-DOT-CFG-SIMPLE +; ; Check that only the passes that change the IR are printed and that the ; others (including g) are filtered out. ; RUN: rm -rf %t && mkdir -p %t @@ -64,6 +69,12 @@ ; RUN: ls %t/*.pdf %t/passes.html | count 3 ; RUN: FileCheck %s -input-file=%t/passes.html --check-prefix=CHECK-DOT-CFG-QUIET-SIMPLE --allow-empty ; +; Simple functionality check. +; RUN: rm -rf %t && mkdir -p %t +; RUN: opt -S -print-changed=opt-dot-cfg-quiet -passes=instsimplify -dot-cfg-dir=%t < %s -o /dev/null +; RUN: ls %t/*.pdf %t/passes.html | count 3 +; RUN: FileCheck %s -input-file=%t/passes.html --check-prefix=CHECK-DOT-CFG-QUIET-SIMPLE --allow-empty +; ; Check that only the passes that change the IR are printed and that the ; others (including g) are filtered out. ; RUN: rm -rf %t && mkdir -p %t Index: llvm/test/Other/ChangePrinters/print-changed-diff.ll =================================================================== --- llvm/test/Other/ChangePrinters/print-changed-diff.ll +++ llvm/test/Other/ChangePrinters/print-changed-diff.ll @@ -4,6 +4,7 @@ ; ; Simple functionality check. ; RUN: opt -S -print-changed=diff -passes=instsimplify 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-DIFF-SIMPLE +; RUN: opt -S -print-changed=opt-diff -passes=instsimplify 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-DIFF-SIMPLE ; ; Check that only the passes that change the IR are printed and that the ; others (including g) are filtered out. @@ -36,6 +37,7 @@ ; ; Simple functionality check. ; RUN: opt -S -print-changed=diff-quiet -passes=instsimplify 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-DIFF-QUIET-SIMPLE --allow-empty +; RUN: opt -S -print-changed=opt-diff-quiet -passes=instsimplify 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-DIFF-QUIET-SIMPLE --allow-empty ; ; Check that only the passes that change the IR are printed and that the ; others (including g) are filtered out. @@ -68,6 +70,7 @@ ; ; Simple functionality check. ; RUN: opt -S -print-changed=cdiff -passes=instsimplify 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-CDIFF-SIMPLE +; RUN: opt -S -print-changed=opt-cdiff -passes=instsimplify 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-CDIFF-SIMPLE ; ; Check that only the passes that change the IR are printed and that the ; others (including g) are filtered out. @@ -100,6 +103,7 @@ ; ; Simple functionality check. ; RUN: opt -S -print-changed=cdiff-quiet -passes=instsimplify 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-CDIFF-QUIET-SIMPLE --allow-empty +; RUN: opt -S -print-changed=opt-cdiff-quiet -passes=instsimplify 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-CDIFF-QUIET-SIMPLE --allow-empty ; ; Check that only the passes that change the IR are printed and that the ; others (including g) are filtered out. Index: llvm/test/Other/change-printer.ll =================================================================== --- llvm/test/Other/change-printer.ll +++ llvm/test/Other/change-printer.ll @@ -4,6 +4,9 @@ ; ; Simple functionality check. ; RUN: opt -S -print-changed -passes=instsimplify 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-SIMPLE +; Cannot do the expected test as the test harness substitutes the path to opt +; for -print-changed=opt +; R_U_N: opt -S -print-changed=opt -passes=instsimplify 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-SIMPLE ; ; Simple functionality check. ; RUN: opt -S -print-changed= -passes=instsimplify 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-SIMPLE @@ -51,6 +54,7 @@ ; ; Simple functionality check. ; RUN: opt -S -print-changed=quiet -passes=instsimplify 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-QUIET-SIMPLE +; RUN: opt -S -print-changed=opt-quiet -passes=instsimplify 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-QUIET-SIMPLE ; ; Check that only the passes that change the IR are printed and that the ; others (including g) are filtered out. Index: llvm/test/Other/print-changed-machine.ll =================================================================== --- llvm/test/Other/print-changed-machine.ll +++ llvm/test/Other/print-changed-machine.ll @@ -37,8 +37,12 @@ ; QUIET-FILTER: *** IR Dump After IRTranslator (irtranslator) on foo *** ; QUIET-FILTER: *** IR Dump After IRTranslator (irtranslator) on bar *** -;; dot-cfg/dot-cfg-quiet are unimplemented. Currently they behave like 'quiet'. -; RUN: llc -filetype=null -mtriple=aarch64 -O0 -print-changed=dot-cfg %s 2>&1 | FileCheck %s --check-prefix=QUIET +; EMPTY-NOT: *** IR Dump + +;; dot-cfg/dot-cfg-quiet are unimplemented. Currently they produce nothing. +;; Same with the opt-... versions. +; RUN: llc -filetype=null -mtriple=aarch64 -O0 -print-changed=dot-cfg %s 2>&1 | FileCheck %s --allow-empty -check-prefix=EMPTY +; RUN: llc -filetype=null -mtriple=aarch64 -O0 -print-changed=opt-quiet %s 2>&1 | FileCheck %s --allow-empty -check-prefix=EMPTY @var = global i32 0