Index: llvm/include/llvm/Passes/StandardInstrumentations.h =================================================================== --- llvm/include/llvm/Passes/StandardInstrumentations.h +++ llvm/include/llvm/Passes/StandardInstrumentations.h @@ -247,6 +247,109 @@ bool same(const std::string &Before, const std::string &After) override; }; +// The following classes hold a representation of the IR for a change +// reporter that uses string comparisons of the basic blocks +// that are created using print (ie, similar to dump()). +// These classes respect the filtering of passes and functions using +// -filter-passes and -filter-print-funcs. +// +// Information that needs to be saved for a basic block in order to compare +// before and after the pass to determine if it was changed by a pass. +class ChangedBlockData { +public: + ChangedBlockData(const BasicBlock &B); + + bool operator!=(const ChangedBlockData &That) const { + return Body != That.Body; + } + + // Return the label of the represented basic block. + StringRef getLabel() const { return Label; } + // Return the string representation of the basic block. + StringRef getBody() const { return Body; } + +protected: + std::string Label; + std::string Body; +}; + +// The data saved for comparing functions. +class ChangedFuncData : public StringMap { +public: + ChangedFuncData() {} + ChangedFuncData(const Function &F); + bool operator==(const ChangedFuncData &That) const; + bool operator!=(const ChangedFuncData &That) const { + return !(*this == That); + } +}; + +// A map of names to the saved data. +using ChangedIRData = StringMap; + +enum class IRChangeDiffType { InBefore, InAfter, IsCommon }; + +// A class that compares two IRs and does a diff between them. The +// added lines are prefixed with a '+', the removed lines are prefixed +// with a '-' and unchanged lines are prefixed with a space (to have +// things line up). +class ChangedIRComparer { +public: + ChangedIRComparer(raw_ostream &OS, const ChangedIRData &Before, + const ChangedIRData &After) + : Before(Before), After(After), Out(OS) {} + + // Compare the 2 IRs. + void compare(Any IR, StringRef Prefix, StringRef PassID, StringRef Name); + + // Analyze \p IR and build the IR representation in \p Data. + static void analyzeIR(Any IR, ChangedIRData &Data); + +protected: + // Return the module when that is the appropriate level of + // comparison for \p IR. + static const Module *getModule(Any IR); + + // Generate the data for \p F into \p Data. + static bool generateFunctionData(ChangedIRData &Data, const Function &F); + + // Called to handle the compare of a function. When \p InModule is set, + // this function is being handled as part of comparing a module. + void handleFunctionCompare(StringRef Name, StringRef Prefix, StringRef PassID, + bool InModule, const ChangedFuncData &Before, + const ChangedFuncData &After); + + const ChangedIRData &Before; + const ChangedIRData &After; + raw_ostream &Out; +}; + +// A change printer that prints out in-line differences in the basic +// blocks. It uses an InlineComparer to do the comparison so it shows +// the differences prefixed with '-' and '+' for code that is removed +// and added, respectively. Changes to the IR that do not affect basic +// blocks are not reported as having changed the IR. The option +// -print-module-scope does not affect this change reporter. +class InLineChangePrinter : public TextChangeReporter { +public: + InLineChangePrinter() {} + ~InLineChangePrinter() override; + void registerCallbacks(PassInstrumentationCallbacks &PIC); + +protected: + // Create a representation of the IR. + virtual void generateIRRepresentation(Any IR, StringRef PassID, + ChangedIRData &Output) override; + + // Called when an interesting IR has changed. + virtual void handleAfter(StringRef PassID, std::string &Name, + const ChangedIRData &Before, + const ChangedIRData &After, Any) override; + // Called to compare the before and after representations of the IR. + virtual bool same(const ChangedIRData &Before, + const ChangedIRData &After) override; +}; + class VerifyInstrumentation { bool DebugLogging; @@ -265,6 +368,7 @@ OptBisectInstrumentation OptBisect; PreservedCFGCheckerInstrumentation PreservedCFGChecker; IRChangedPrinter PrintChangedIR; + InLineChangePrinter PrintChangedDiff; VerifyInstrumentation Verify; bool VerifyEach; @@ -282,6 +386,9 @@ extern template class ChangeReporter; extern template class TextChangeReporter; +extern template class ChangeReporter; +extern template class TextChangeReporter; + } // namespace llvm #endif Index: llvm/lib/Passes/StandardInstrumentations.cpp =================================================================== --- llvm/lib/Passes/StandardInstrumentations.cpp +++ llvm/lib/Passes/StandardInstrumentations.cpp @@ -26,6 +26,8 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/Program.h" #include "llvm/Support/raw_ostream.h" #include #include @@ -82,9 +84,90 @@ PrintChangedBefore("print-before-changed", cl::desc("Print before passes that change them"), cl::init(false), cl::Hidden); +// An option -print-changed-diff which prints in line differences of +// changed IR as they progress through the pipeline. The differences +// are presented in a form similar to a patch. The lines that are removed +// and added are prefixed with '-' and '+', respectively. The +// -filter-print-funcs and -filter-passes can be used to filter the output. +// This reporter relies on the linux diff utility to do comparisons and +// insert the prefixes. For systems that do not have the necessary +// facilities, the error message will be shown in place of the expected output. +static cl::opt PrintChangedDiff( + "print-changed-diff", cl::Hidden, cl::init(false), + cl::desc("Print in-line differences of changes made by a pass")); +// An option for specifying the diff used by print-changed-diff +static cl::opt + DiffBinary("diff-for-print-changed", cl::Hidden, cl::init("diff"), + cl::desc("system diff used by change reporters")); namespace { +// Perform a system based diff between \p Before and \p After, using +// \p OldLineFormat, \p NewLineFormat, and \p UnchangedLineFormat +// to control the formatting of the output. Return an error message +// for any failures instead of the diff. +std::string doSystemDiff(StringRef Before, StringRef After, + StringRef OldLineFormat, StringRef NewLineFormat, + StringRef UnchangedLineFormat) { + StringRef SR[2]{Before, After}; + // Store the 2 bodies into temporary files and call diff on them + // to get the body of the node. + static const unsigned NumFiles = 3; + static std::string FileName[NumFiles]; + static int FD[NumFiles]{-1, -1, -1}; + for (unsigned I = 0; I < NumFiles; ++I) { + if (FD[I] == -1) { + SmallVector SV; + std::error_code EC = + sys::fs::createTemporaryFile("tmpdiff", "txt", FD[I], SV); + if (EC) + return "Unable to create temporary file."; + FileName[I] = Twine(SV).str(); + } + // The third file is used as the result of the diff. + if (I == NumFiles - 1) + break; + + std::error_code EC = sys::fs::openFileForWrite(FileName[I], FD[I]); + if (EC) + return "Unable to open temporary file for writing."; + + raw_fd_ostream OutStream(FD[I], /*shouldClose=*/true); + if (FD[I] == -1) + return "Error opening file for writing."; + OutStream << SR[I]; + } + + static ErrorOr DiffExe = sys::findProgramByName(DiffBinary); + if (!DiffExe) + return "Unable to find diff executable."; + + SmallString<128> OLF = formatv("--old-line-format={0}", OldLineFormat); + SmallString<128> NLF = formatv("--new-line-format={0}", NewLineFormat); + SmallString<128> ULF = + formatv("--unchanged-line-format={0}", UnchangedLineFormat); + + StringRef Args[] = {"-w", "-d", OLF, NLF, ULF, FileName[0], FileName[1]}; + Optional Redirects[] = {None, StringRef(FileName[2]), None}; + int Result = sys::ExecuteAndWait(*DiffExe, Args, None, Redirects); + if (Result < 0) + return "Error executing system diff."; + std::string Diff; + auto B = MemoryBuffer::getFile(FileName[2]); + if (B && *B) + Diff = (*B)->getBuffer().str(); + else + return "Unable to read result."; + + // Clean up. + for (unsigned I = 0; I < NumFiles; ++I) { + std::error_code EC = sys::fs::remove(FileName[I]); + if (EC) + return "Unable to remove temporary file."; + } + return Diff; +} + /// Extracting Module out of \p IR unit. Also fills a textual description /// of \p IR for use in header when printing. Optional> @@ -250,7 +333,7 @@ template bool ChangeReporter::isInterestingFunction(const Function &F) { - return llvm::isFunctionInPrintList(F.getName()); + return isFunctionInPrintList(F.getName()); } template @@ -358,6 +441,30 @@ }); } +ChangedBlockData::ChangedBlockData(const BasicBlock &B) + : Label(B.getName().str()) { + raw_string_ostream SS(Body); + B.print(SS, nullptr, true, true); +} + +ChangedFuncData::ChangedFuncData(const Function &F) { + for (const auto &B : F) + insert({B.getName(), B}); +} + +bool ChangedFuncData::operator==(const ChangedFuncData &That) const { + for (auto &B : That) { + StringRef Label = B.getKey(); + if (count(Label) == 0) + return false; + const ChangedBlockData &ThisData = find(Label)->getValue(); + const ChangedBlockData &ThatData = B.getValue(); + if (ThisData != ThatData) + return false; + } + return true; +} + template TextChangeReporter::TextChangeReporter() : ChangeReporter(), Out(dbgs()) {} @@ -430,7 +537,7 @@ Out << "*** IR Dump Before" << Banner.substr(17); // LazyCallGraph::SCC already has "(scc:..." in banner so only add // in the name if it isn't already there. - if (Name.substr(0, 6) != " (scc:" && !llvm::forcePrintModuleIR()) + if (Name.substr(0, 6) != " (scc:" && !forcePrintModuleIR()) Out << Name; StringRef BeforeRef = Before; @@ -441,7 +548,7 @@ // LazyCallGraph::SCC already has "(scc:..." in banner so only add // in the name if it isn't already there. - if (Name.substr(0, 6) != " (scc:" && !llvm::forcePrintModuleIR()) + if (Name.substr(0, 6) != " (scc:" && !forcePrintModuleIR()) Out << Name; Out << After.substr(Banner.size()); @@ -451,6 +558,86 @@ return S1 == S2; } +void ChangedIRComparer::compare(Any IR, StringRef Prefix, StringRef PassID, + StringRef Name) { + if (!getModule(IR)) { + // Not a module so just handle the single function. + assert(Before.size() == 1 && "Expected only one function."); + assert(After.size() == 1 && "Expected only one function."); + handleFunctionCompare(Name, Prefix, PassID, false, + Before.begin()->getValue(), + After.begin()->getValue()); + return; + } + // Determine whether functions are common or not. + StringMap Funcs; + for (auto &B : Before) + Funcs.insert({B.getKey(), IRChangeDiffType::InBefore}); + for (auto &A : After) + if (Funcs.count(A.getKey()) == 1) + Funcs[A.getKey()] = IRChangeDiffType::IsCommon; + else + Funcs.insert({A.getKey(), IRChangeDiffType::InAfter}); + + for (auto &F : Funcs) { + Name = F.getKey(); + IRChangeDiffType CDDT = F.getValue(); + // If the function isn't common, create an empty version for the compare. + if (CDDT == IRChangeDiffType::InBefore) + handleFunctionCompare(Name, Prefix, PassID, true, + Before.find(Name)->getValue(), ChangedFuncData()); + else if (CDDT == IRChangeDiffType::InAfter) + handleFunctionCompare(Name, Prefix, PassID, true, ChangedFuncData(), + After.find(Name)->getValue()); + else { + assert(CDDT == IRChangeDiffType::IsCommon && "Unexpected Diff type."); + handleFunctionCompare(Name, Prefix, PassID, true, + Before.find(Name)->getValue(), + After.find(Name)->getValue()); + } + } +} + +void ChangedIRComparer::analyzeIR(Any IR, ChangedIRData &Data) { + if (const Module *M = getModule(IR)) { + // Create data for each existing/interesting function in the module. + for (const Function &F : *M) + generateFunctionData(Data, F); + return; + } + + const Function *F = nullptr; + if (any_isa(IR)) + F = any_cast(IR); + else { + assert(any_isa(IR) && "Unknown IR unit."); + const Loop *L = any_cast(IR); + F = L->getHeader()->getParent(); + } + assert(F && "Unknown IR unit."); + generateFunctionData(Data, *F); +} + +const Module *ChangedIRComparer::getModule(Any IR) { + if (any_isa(IR)) + return any_cast(IR); + if (any_isa(IR)) { + const LazyCallGraph::SCC *C = any_cast(IR); + for (const LazyCallGraph::Node &N : *C) + return N.getFunction().getParent(); + } + return nullptr; +} + +bool ChangedIRComparer::generateFunctionData(ChangedIRData &Data, + const Function &F) { + if (!F.isDeclaration() && isFunctionInPrintList(F.getName())) { + Data.insert({F.getName(), F}); + return true; + } + return false; +} + PrintIRInstrumentation::~PrintIRInstrumentation() { assert(ModuleDescStack.empty() && "ModuleDescStack is not empty at exit"); } @@ -832,6 +1019,66 @@ }); } +InLineChangePrinter::~InLineChangePrinter() {} + +void InLineChangePrinter::generateIRRepresentation(Any IR, StringRef PassID, + ChangedIRData &D) { + ChangedIRComparer::analyzeIR(IR, D); +} + +void InLineChangePrinter::handleAfter(StringRef PassID, std::string &Name, + const ChangedIRData &Before, + const ChangedIRData &After, Any IR) { + if (Name == "") + Name = " (module)"; + SmallString<20> Banner = + formatv("*** IR Dump After {0} ***{1}\n", PassID, Name); + Out << Banner; + ChangedIRComparer(Out, Before, After).compare(IR, "", PassID, Name); + Out << "\n"; +} + +bool InLineChangePrinter::same(const ChangedIRData &D1, + const ChangedIRData &D2) { + return D1 == D2; +} + +void ChangedIRComparer::handleFunctionCompare(StringRef Name, StringRef Prefix, + StringRef PassID, bool InModule, + const ChangedFuncData &Before, + const ChangedFuncData &After) { + // Print a banner when this is being shown in the context of a module + if (InModule) + Out << "\n*** IR for function " << Name << " ***\n"; + + const std::string Removed = "\033[31m-%l\033[0m\n"; + const std::string Added = "\033[32m+%l\033[0m\n"; + const std::string NoChange = " %l\n"; + for (const auto &B : Before) { + const auto &BeforeBD = B.getValue(); + if (After.count(BeforeBD.getLabel())) { + // This block is in both + const auto &BD = After.find(BeforeBD.getLabel())->getValue(); + Out << doSystemDiff(BeforeBD.getBody(), BD.getBody(), Removed, Added, + NoChange); + } else + // This has been removed + Out << doSystemDiff(BeforeBD.getBody(), "\n", Removed, Added, NoChange); + } + for (const auto &B : After) { + const auto &AfterBD = B.getValue(); + if (!Before.count(AfterBD.getLabel())) { + // This block is new + Out << doSystemDiff("\n", AfterBD.getBody(), Removed, Added, NoChange); + } + } +} + +void InLineChangePrinter::registerCallbacks(PassInstrumentationCallbacks &PIC) { + if (PrintChangedDiff) + TextChangeReporter::registerRequiredCallbacks(PIC); +} + void StandardInstrumentations::registerCallbacks( PassInstrumentationCallbacks &PIC) { PrintIR.registerCallbacks(PIC); @@ -843,6 +1090,7 @@ PrintChangedIR.registerCallbacks(PIC); if (VerifyEach) Verify.registerCallbacks(PIC); + PrintChangedDiff.registerCallbacks(PIC); } namespace llvm { @@ -850,4 +1098,7 @@ template class ChangeReporter; template class TextChangeReporter; +template class ChangeReporter; +template class TextChangeReporter; + } // namespace llvm Index: llvm/test/Other/ChangePrinters/lit.local.cfg =================================================================== --- /dev/null +++ llvm/test/Other/ChangePrinters/lit.local.cfg @@ -0,0 +1,16 @@ +import os +import subprocess + +def have_needed_diff_support(): + if not os.path.exists('/usr/bin/diff'): + return False + + ld_cmd = subprocess.Popen( + ['/usr/bin/diff', '--help'], stdout=subprocess.PIPE, env={'LANG': 'C'}) + ld_out = ld_cmd.stdout.read().decode() + ld_cmd.wait() + + return '-line-format' in ld_out + +if not have_needed_diff_support(): + config.unsupported = True Index: llvm/test/Other/ChangePrinters/print-changes.ll =================================================================== --- /dev/null +++ llvm/test/Other/ChangePrinters/print-changes.ll @@ -0,0 +1,161 @@ +; Simple checks of -print-changed-diff +; +; Note that (mostly) only the banners are checked. +; +; Simple functionality check. +; RUN: opt -S -print-changed-diff -passes=instsimplify 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-SIMPLE +; +; Check that only the passes that change the IR are printed and that the +; others (including g) are filtered out. +; RUN: opt -S -print-changed-diff -passes=instsimplify -filter-print-funcs=f 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-FUNC-FILTER +; +; Check that the reporting of IRs respects is not affected by +; -print-module-scope +; RUN: opt -S -print-changed-diff -passes=instsimplify -print-module-scope 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-PRINT-MOD-SCOPE +; +; Check that reporting of multiple functions happens +; RUN: opt -S -print-changed-diff -passes=instsimplify -filter-print-funcs="f,g" 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-FILTER-MULT-FUNC +; +; Check that the reporting of IRs respects -filter-passes +; RUN: opt -S -print-changed-diff -passes="instsimplify,no-op-function" -filter-passes="NoOpFunctionPass" 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-FILTER-PASSES +; +; Check that the reporting of IRs respects -filter-passes with multiple passes +; RUN: opt -S -print-changed-diff -passes="instsimplify,no-op-function" -filter-passes="NoOpFunctionPass,InstSimplifyPass" 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-FILTER-MULT-PASSES +; +; Check that the reporting of IRs respects both -filter-passes and -filter-print-funcs +; RUN: opt -S -print-changed-diff -passes="instsimplify,no-op-function" -filter-passes="NoOpFunctionPass,InstSimplifyPass" -filter-print-funcs=f 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-FILTER-FUNC-PASSES +; +; Check that repeated passes that change the IR are printed and that the +; others (including g) are filtered out. Note that only the first time +; instsimplify is run on f will result in changes +; RUN: opt -S -print-changed-diff -passes="instsimplify,instsimplify" -filter-print-funcs=f 2>&1 -o /dev/null < %s | FileCheck %s --check-prefix=CHECK-MULT-PASSES-FILTER-FUNC + +define i32 @g() { +entry: + %a = add i32 2, 3 + ret i32 %a +} + +define i32 @f() { +entry: + %a = add i32 2, 3 + ret i32 %a +} + +; CHECK-SIMPLE: *** IR Dump At Start: *** +; CHECK-SIMPLE: ModuleID = {{.+}} +; CHECK-SIMPLE: *** IR Dump After VerifierPass (module) omitted because no change *** +; CHECK-SIMPLE: *** IR Dump After InstSimplifyPass *** (function: g) +; CHECK-SIMPLE-NOT: ModuleID = {{.+}} +; CHECK-SIMPLE-NOT: *** IR{{.*}} +; CHECK-SIMPLE: entry: +; CHECK-SIMPLE-NEXT:- %a = add i32 2, 3 +; CHECK-SIMPLE-NEXT:- ret i32 %a +; CHECK-SIMPLE-NEXT:+ ret i32 5 +; CHECK-SIMPLE: *** IR Pass PassManager{{.*}} (function: g) ignored *** +; CHECK-SIMPLE: *** IR Dump After InstSimplifyPass *** (function: f) +; CHECK-SIMPLE-NOT: ModuleID = {{.+}} +; CHECK-SIMPLE-NOT: *** IR{{.*}} +; CHECK-SIMPLE: entry: +; CHECK-SIMPLE-NEXT:- %a = add i32 2, 3 +; CHECK-SIMPLE-NEXT:- ret i32 %a +; CHECK-SIMPLE-NEXT:+ ret i32 5 +; CHECK-SIMPLE: *** IR Pass PassManager{{.*}} (function: f) ignored *** +; CHECK-SIMPLE: *** IR Pass ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}> (module) ignored *** +; CHECK-SIMPLE: *** IR Dump After VerifierPass (module) omitted because no change *** +; CHECK-SIMPLE: *** IR Dump After PrintModulePass (module) omitted because no change *** + +; CHECK-FUNC-FILTER: *** IR Dump At Start: *** +; CHECK-FUNC-FILTER-NEXT: ; ModuleID = {{.+}} +; CHECK-FUNC-FILTER: *** IR Dump After InstSimplifyPass (function: g) filtered out *** +; CHECK-FUNC-FILTER: *** IR Dump After InstSimplifyPass *** (function: f) +; CHECK-FUNC-FILTER-NOT: ModuleID = {{.+}} +; CHECK-FUNC-FILTER: entry: +; CHECK-FUNC-FILTER:- %a = add i32 2, 3 +; CHECK-FUNC-FILTER:- ret i32 %a +; CHECK-FUNC-FILTER:+ ret i32 5 +; CHECK-FUNC-FILTER: *** IR Pass PassManager{{.*}} (function: f) ignored *** +; CHECK-FUNC-FILTER: *** IR Pass ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}> (module) ignored *** +; CHECK-FUNC-FILTER: *** IR Dump After VerifierPass (module) omitted because no change *** +; CHECK-FUNC-FILTER: *** IR Dump After PrintModulePass (module) omitted because no change *** + +; CHECK-PRINT-MOD-SCOPE: *** IR Dump At Start: *** +; CHECK-PRINT-MOD-SCOPE: ModuleID = {{.+}} +; CHECK-PRINT-MOD-SCOPE: *** IR Dump After InstSimplifyPass *** (function: g) +; CHECK-PRINT-MOD-SCOPE-NOT: ModuleID = {{.+}} +; CHECK-PRINT-MOD-SCOPE: entry: +; CHECK-PRINT-MOD-SCOPE:- %a = add i32 2, 3 +; CHECK-PRINT-MOD-SCOPE:- ret i32 %a +; CHECK-PRINT-MOD-SCOPE:+ ret i32 5 +; CHECK-PRINT-MOD-SCOPE: *** IR Dump After InstSimplifyPass *** (function: f) +; CHECK-PRINT-MOD-SCOPE-NOT: ModuleID = {{.+}} +; CHECK-PRINT-MOD-SCOPE: entry: +; CHECK-PRINT-MOD-SCOPE:- %a = add i32 2, 3 +; CHECK-PRINT-MOD-SCOPE:- ret i32 %a +; CHECK-PRINT-MOD-SCOPE:+ ret i32 5 +; CHECK-PRINT-MOD-SCOPE: *** IR Pass PassManager{{.*}} (function: f) ignored *** +; CHECK-PRINT-MOD-SCOPE: *** IR Pass ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}> (module) ignored *** +; CHECK-PRINT-MOD-SCOPE: *** IR Dump After VerifierPass (module) omitted because no change *** +; CHECK-PRINT-MOD-SCOPE: *** IR Dump After PrintModulePass (module) omitted because no change *** + +; CHECK-FILTER-MULT-FUNC: *** IR Dump At Start: *** +; CHECK-FILTER-MULT-FUNC: *** IR Dump After InstSimplifyPass *** (function: g) +; CHECK-FILTER-MULT-FUNC-NOT: ModuleID = {{.+}} +; CHECK-FILTER-MULT-FUNC: entry: +; CHECK-FILTER-MULT-FUNC:- %a = add i32 2, 3 +; CHECK-FILTER-MULT-FUNC:- ret i32 %a +; CHECK-FILTER-MULT-FUNC:+ ret i32 5 +; CHECK-FILTER-MULT-FUNC: *** IR Dump After InstSimplifyPass *** (function: f) +; CHECK-FILTER-MULT-FUNC-NOT: ModuleID = {{.+}} +; CHECK-FILTER-MULT-FUNC: entry: +; CHECK-FILTER-MULT-FUNC:- %a = add i32 2, 3 +; CHECK-FILTER-MULT-FUNC:- ret i32 %a +; CHECK-FILTER-MULT-FUNC:+ ret i32 5 +; CHECK-FILTER-MULT-FUNC: *** IR Pass PassManager{{.*}} (function: f) ignored *** +; CHECK-FILTER-MULT-FUNC: *** IR Pass ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}> (module) ignored *** +; CHECK-FILTER-MULT-FUNC: *** IR Dump After VerifierPass (module) omitted because no change *** +; CHECK-FILTER-MULT-FUNC: *** IR Dump After PrintModulePass (module) omitted because no change *** + +; CHECK-FILTER-PASSES: *** IR Dump After InstSimplifyPass (function: g) filtered out *** +; CHECK-FILTER-PASSES: *** IR Dump At Start: *** (function: g) +; CHECK-FILTER-PASSES: *** IR Dump After NoOpFunctionPass (function: g) omitted because no change *** +; CHECK-FILTER-PASSES: *** IR Dump After InstSimplifyPass (function: f) filtered out *** +; CHECK-FILTER-PASSES: *** IR Dump After NoOpFunctionPass (function: f) omitted because no change *** + +; CHECK-FILTER-MULT-PASSES: *** IR Dump At Start: *** (function: g) +; CHECK-FILTER-MULT-PASSES: *** IR Dump After InstSimplifyPass *** (function: g) +; CHECK-FILTER-MULT-PASSES-NOT: ModuleID = {{.+}} +; CHECK-FILTER-MULT-PASSES: entry: +; CHECK-FILTER-MULT-PASSES:- %a = add i32 2, 3 +; CHECK-FILTER-MULT-PASSES:- ret i32 %a +; CHECK-FILTER-MULT-PASSES:+ ret i32 5 +; CHECK-FILTER-MULT-PASSES: *** IR Dump After NoOpFunctionPass (function: g) omitted because no change *** +; CHECK-FILTER-MULT-PASSES: *** IR Dump After InstSimplifyPass *** (function: f) +; CHECK-FILTER-MULT-PASSES-NOT: ModuleID = {{.+}} +; CHECK-FILTER-MULT-PASSES: entry: +; CHECK-FILTER-MULT-PASSES:- %a = add i32 2, 3 +; CHECK-FILTER-MULT-PASSES:- ret i32 %a +; CHECK-FILTER-MULT-PASSES:+ ret i32 5 +; CHECK-FILTER-MULT-PASSES: *** IR Dump After NoOpFunctionPass (function: f) omitted because no change *** + +; CHECK-FILTER-FUNC-PASSES: *** IR Dump After InstSimplifyPass (function: g) filtered out *** +; CHECK-FILTER-FUNC-PASSES: *** IR Dump After NoOpFunctionPass (function: g) filtered out *** +; CHECK-FILTER-FUNC-PASSES: *** IR Dump At Start: *** (function: f) +; CHECK-FILTER-FUNC-PASSES: *** IR Dump After InstSimplifyPass *** (function: f) +; CHECK-FILTER-FUNC-PASSES-NOT: ModuleID = {{.+}} +; CHECK-FILTER-FUNC-PASSES: entry: +; CHECK-FILTER-FUNC-PASSES:- %a = add i32 2, 3 +; CHECK-FILTER-FUNC-PASSES:- ret i32 %a +; CHECK-FILTER-FUNC-PASSES:+ ret i32 5 +; CHECK-FILTER-FUNC-PASSES: *** IR Dump After NoOpFunctionPass (function: f) omitted because no change *** + +; CHECK-MULT-PASSES-FILTER-FUNC: *** IR Dump At Start: *** +; CHECK-MULT-PASSES-FILTER-FUNC: *** IR Dump After InstSimplifyPass (function: g) filtered out *** +; CHECK-MULT-PASSES-FILTER-FUNC: *** IR Dump After InstSimplifyPass (function: g) filtered out *** +; CHECK-MULT-PASSES-FILTER-FUNC: *** IR Dump After InstSimplifyPass *** (function: f) +; CHECK-MULT-PASSES-FILTER-FUNC-NOT: ModuleID = {{.+}} +; CHECK-MULT-PASSES-FILTER-FUNC: entry: +; CHECK-MULT-PASSES-FILTER-FUNC:- %a = add i32 2, 3 +; CHECK-MULT-PASSES-FILTER-FUNC:- ret i32 %a +; CHECK-MULT-PASSES-FILTER-FUNC:+ ret i32 5 +; CHECK-MULT-PASSES-FILTER-FUNC: *** IR Dump After InstSimplifyPass (function: f) omitted because no change ***