Index: llvm/include/llvm/Passes/StandardInstrumentations.h =================================================================== --- llvm/include/llvm/Passes/StandardInstrumentations.h +++ llvm/include/llvm/Passes/StandardInstrumentations.h @@ -247,6 +247,215 @@ bool same(const std::string &Before, const std::string &After) override; }; +// The following abstract template base classes contain the necessary code to +// create a change reporter that uses string comparisons of the basic blocks +// that are created using Value::print (ie, similar to dump()). +// These classes allow one to associate extra data with each basic block +// and the structs representing the basic blocks are grouped into +// the structs representing the functions. Essentially, overrides +// in the classes derived from ChangeReporter use a class derived from +// IRComparer to compare representations of IRs. The overrides are called +// when changes are detected after each pass to generate the output while the +// mechanics of detecting changes is handled in the base classes. The +// saving of extra data that may be desired by the overrides is done +// in a class derived from IRComparer, as is the actual generation +// of the output in response to changes to the IR. +// These change reporters work on basic blocks as the basic unit, meaning +// that comparisons between the before and after are made by comparing +// basic blocks and showing the differences between basic blocks. Basic +// blocks are matched from comparison using the name of the basic block +// so if a basic block is renamed, it will be considered to be deleted +// and the renamed block as added since the names do not match. +// 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. +template class BlockDataTemplate { +public: + // Note that the constructor will call a static function + // BlockDataType::initialize(BlockDataType &, BasicBlock &) + // to fill in the Data member. + BlockDataTemplate(const BasicBlock &B); + + bool operator!=(const BlockDataTemplate &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; } + + // Return the associated data + const BlockDataType &getData() const { return Data; } + +protected: + std::string Label; + std::string Body; + + // Extra data associated with a basic block + BlockDataType Data; +}; + +// The data saved for comparing functions. +template class FuncDataTemplate { +public: + FuncDataTemplate(const Function &F); + + // Create data for a missing function that is present in the other IR + FuncDataTemplate(StringRef Name) { EntryBlockName = Name.str(); } + + bool operator==(const FuncDataTemplate &That) const; + + bool operator!=(const FuncDataTemplate &That) const { + return !(*this == That); + } + + // Iterator over the saved basic block data + typename StringMap>::const_iterator + begin() const { + return Blocks.begin(); + } + typename StringMap>::const_iterator + end() const { + return Blocks.end(); + } + + // Return the name of the entry block + std::string getEntryBlockName() const { return EntryBlockName; } + + // Return the block data for the basic block with label \p S. + const BlockDataTemplate * + getBlockData(const StringRef S) const { + return (Blocks.count(S) == 1) ? &Blocks.find(S)->getValue() : nullptr; + } + +protected: + std::string EntryBlockName; + StringMap> Blocks; +}; + +// A map of names to the saved data. +template +class IRDataTemplate : public StringMap { +public: + IRDataTemplate() = default; + bool operator==(const IRDataTemplate &That) const; + bool operator!=(const IRDataTemplate &That) const { return !(*this == That); } +}; + +enum IRChangeDiffType { InBefore, InAfter, IsCommon }; + +// Abstract template base class for a class that compares two IRs. The +// class is created with the 2 IRs to compare and then compare is called. +// The static function analyzeIR is used to build up the IR representation. +template +class IRComparer { +protected: + IRComparer(const IRDataType &Before, const IRDataType &After, unsigned N); + +public: + virtual ~IRComparer(); + + // Compare the 2 IRs. In the case of a module IR, delegate to + // handleFunctionCompare in the derived class for each function; + // otherwise delegate to handleCompare in the derived class. + void compare(Any IR, StringRef Prefix, StringRef PassID, StringRef Name); + // Analyze \p IR and save the data in \p Data. + static bool analyzeIR(Any IR, IRDataType &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(IRDataType &Data, const Function &F); + + // Called to handle the compare of function when IR unit is a function. + virtual void handleSingleFunctionCompare(StringRef Name, StringRef Prefix, + StringRef PassID, unsigned, + unsigned *, + const FuncDataType &Before, + const FuncDataType &After) = 0; + // Called to handle the compare of function when IR unit is a module. + virtual void handleFunctionInModuleCompare(StringRef Name, StringRef Prefix, + StringRef PassID, unsigned, + unsigned *, + const FuncDataType &Before, + const FuncDataType &After) = 0; + + const IRDataType &Before; + const IRDataType &After; + unsigned N; +}; + +// An empty class that satisfies the requirements for being a template +// argument for the IRComparer template base class. +class EmptyData { +public: + static void initialize(EmptyData &, const BasicBlock &) {} +}; + +using EmptyDataBlockData = BlockDataTemplate; +using EmptyDataFuncData = FuncDataTemplate; +using EmptyDataIRData = IRDataTemplate; + +// A class that compares two IRs of type EmptyDataIRData and does a +// linux 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). The functions +// handleCompare and handleFunctionCompare are called by the base +// class with the appropriate parameters. +class InLineComparer : public IRComparer { +public: + InLineComparer(raw_ostream &OS, const EmptyDataIRData &Before, + const EmptyDataIRData &After) + : IRComparer(Before, After, 0), Out(OS) {} + ~InLineComparer() override; + + // Called to handle the compare of function when IR unit is a function. + void handleSingleFunctionCompare(StringRef Name, StringRef Prefix, + StringRef PassID, unsigned, unsigned *, + const EmptyDataFuncData &Before, + const EmptyDataFuncData &After) override; + // Called to handle the compare of function when IR unit is a module. + void handleFunctionInModuleCompare(StringRef Name, StringRef Prefix, + StringRef PassID, unsigned, unsigned *, + const EmptyDataFuncData &Before, + const EmptyDataFuncData &After) override; + +protected: + 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, + EmptyDataIRData &Output) override; + + // Called when an interesting IR has changed. + virtual void handleAfter(StringRef PassID, std::string &Name, + const EmptyDataIRData &Before, + const EmptyDataIRData &After, Any) override; + // Called to compare the before and after representations of the IR. + virtual bool same(const EmptyDataIRData &Before, + const EmptyDataIRData &After) override; +}; + class VerifyInstrumentation { bool DebugLogging; @@ -265,6 +474,7 @@ OptBisectInstrumentation OptBisect; PreservedCFGCheckerInstrumentation PreservedCFGChecker; IRChangedPrinter PrintChangedIR; + InLineChangePrinter PrintChangedDiff; VerifyInstrumentation Verify; bool VerifyEach; @@ -282,6 +492,14 @@ extern template class ChangeReporter; extern template class TextChangeReporter; +extern template class BlockDataTemplate; +extern template class FuncDataTemplate; +extern template class IRDataTemplate; +extern template class ChangeReporter; +extern template class TextChangeReporter; +extern template class IRComparer; + } // 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,88 @@ 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 + DiffForChangeReporters("diff-for-print-changed", cl::Hidden, + cl::init("/usr/bin/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."; + + llvm::raw_fd_ostream OutStream(FD[I], /*shouldClose=*/true); + if (FD[I] == -1) + return "Error opening file for writing."; + OutStream << SR[I]; + } + + 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(DiffForChangeReporters, 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> @@ -358,6 +439,47 @@ }); } +template +BlockDataTemplate::BlockDataTemplate(const llvm::BasicBlock &B) + : Label(B.getName().str()), Data() { + llvm::raw_string_ostream SS(Body); + B.Value::print(SS, true); + BlockDataType::initialize(Data, B); +} + +template +FuncDataTemplate::FuncDataTemplate(const llvm::Function &F) { + EntryBlockName = F.getEntryBlock().getName().str(); + for (const auto &B : F) + Blocks.insert({B.getName(), B}); +} + +template +bool FuncDataTemplate::operator==(const FuncDataTemplate &That) const { + for (auto &B : That) { + llvm::StringRef Label = B.getKey(); + if (Blocks.count(Label) == 0) + return false; + const BlockDataTemplate &ThisData = Blocks.find(Label)->getValue(); + const BlockDataTemplate &ThatData = B.getValue(); + if (ThisData != ThatData) + return false; + } + return true; +} + +template +bool IRDataTemplate::operator==(const IRDataTemplate &That) const { + if (llvm::StringMap::size() != That.size()) + return false; + for (auto &F : *this) { + llvm::StringRef Key = F.getKey(); + if (That.count(Key) == 0 || F.getValue() != That.find(Key)->getValue()) + return false; + } + return true; +} + template TextChangeReporter::TextChangeReporter() : ChangeReporter(), Out(dbgs()) {} @@ -451,6 +573,111 @@ return S1 == S2; } +template +IRComparer::IRComparer( + const IRDataType &Before, const IRDataType &After, unsigned N) + : Before(Before), After(After), N(N) {} + +template +IRComparer::~IRComparer() {} + +template +void IRComparer::compare( + llvm::Any IR, llvm::StringRef Prefix, llvm::StringRef PassID, + llvm::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."); + handleSingleFunctionCompare(Name, Prefix, PassID, N, nullptr, + Before.begin()->getValue(), + After.begin()->getValue()); + return; + } + // Determine whether functions are common or not. + llvm::StringMap Funcs; + for (auto &B : Before) + Funcs.insert({B.getKey(), InBefore}); + for (auto &A : After) + if (Funcs.count(A.getKey()) == 1) + Funcs[A.getKey()] = IsCommon; + else + Funcs.insert({A.getKey(), InAfter}); + + // Set up an appropriate numbering system. + unsigned Minor = 0; + + 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 == InBefore) { + FuncDataType MissingFunc( + Before.find(Name)->getValue().getEntryBlockName()); + handleFunctionInModuleCompare(Name, Prefix, PassID, N, &Minor, + Before.find(Name)->getValue(), MissingFunc); + } else if (CDDT == InAfter) { + FuncDataType MissingFunc( + After.find(Name)->getValue().getEntryBlockName()); + handleFunctionInModuleCompare(Name, Prefix, PassID, N, &Minor, + MissingFunc, After.find(Name)->getValue()); + } else { + assert(CDDT == IsCommon && "Unexpected Diff type."); + handleFunctionInModuleCompare(Name, Prefix, PassID, N, &Minor, + Before.find(Name)->getValue(), + After.find(Name)->getValue()); + } + ++Minor; + } +} + +template +bool IRComparer::analyzeIR( + llvm::Any IR, IRDataType &Data) { + if (const llvm::Module *M = getModule(IR)) { + // Create data for each existing/interesting function in the module. + bool OutputExists = false; + for (const llvm::Function &F : *M) + OutputExists = generateFunctionData(Data, F) | OutputExists; + return OutputExists; + } + + const llvm::Function *F = nullptr; + if (llvm::any_isa(IR)) + F = llvm::any_cast(IR); + else { + assert(llvm::any_isa(IR) && "Unknown IR unit."); + const llvm::Loop *L = llvm::any_cast(IR); + F = L->getHeader()->getParent(); + } + assert(F && "Unknown IR unit."); + return generateFunctionData(Data, *F); +} + +template +const llvm::Module * +IRComparer::getModule(llvm::Any IR) { + if (llvm::any_isa(IR)) + return llvm::any_cast(IR); + if (llvm::any_isa(IR)) { + const llvm::LazyCallGraph::SCC *C = + llvm::any_cast(IR); + for (const llvm::LazyCallGraph::Node &N : *C) + return N.getFunction().getParent(); + } + return nullptr; +} + +template +bool IRComparer::generateFunctionData( + IRDataType &Data, const llvm::Function &F) { + if (!F.isDeclaration() && llvm::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 +1059,70 @@ }); } +InLineChangePrinter::~InLineChangePrinter() {} + +void InLineChangePrinter::generateIRRepresentation(Any IR, StringRef PassID, + EmptyDataIRData &D) { + InLineComparer::analyzeIR(IR, D); +} + +void InLineChangePrinter::handleAfter(StringRef PassID, std::string &Name, + const EmptyDataIRData &Before, + const EmptyDataIRData &After, Any IR) { + if (Name == "") + Name = " (module)"; + SmallString<20> Banner = + formatv("*** IR Dump After {0} ***{1}\n", PassID, Name); + Out << Banner; + InLineComparer(Out, Before, After).compare(IR, "", PassID, Name); + Out << "\n"; +} + +bool InLineChangePrinter::same(const EmptyDataIRData &D1, + const EmptyDataIRData &D2) { + return D1 == D2; +} + +InLineComparer::~InLineComparer() {} + +void InLineComparer::handleSingleFunctionCompare( + llvm::StringRef, llvm::StringRef Prefix, llvm::StringRef PassID, unsigned, + unsigned *, const EmptyDataFuncData &Before, + const EmptyDataFuncData &After) { + for (const auto &B : Before) { + const EmptyDataBlockData &BeforeBD = B.getValue(); + const EmptyDataBlockData *BD = After.getBlockData(BeforeBD.getLabel()); + if (BD) + // This block is in both + Out << doSystemDiff(BeforeBD.getBody(), BD->getBody(), "-%l\n", "+%l\n", + " %l\n"); + else + // This has been removed + Out << doSystemDiff(BeforeBD.getBody(), "\n", "-%l\n", "+%l\n", " %l\n"); + } + for (const auto &B : After) { + const EmptyDataBlockData &AfterBD = B.getValue(); + const EmptyDataBlockData *BD = Before.getBlockData(AfterBD.getLabel()); + if (!BD) + // This block is new + Out << doSystemDiff("\n", AfterBD.getBody(), "-%l\n", "+%l\n", " %l\n"); + } +} + +void InLineComparer::handleFunctionInModuleCompare( + llvm::StringRef Name, llvm::StringRef Prefix, llvm::StringRef PassID, + unsigned, unsigned *, const EmptyDataFuncData &Before, + const EmptyDataFuncData &After) { + Out << "\n*** IR for function " << Name << " ***\n"; + InLineComparer::handleSingleFunctionCompare(Name, Prefix, PassID, 0, nullptr, + Before, After); +} + +void InLineChangePrinter::registerCallbacks(PassInstrumentationCallbacks &PIC) { + if (PrintChangedDiff) + TextChangeReporter::registerRequiredCallbacks(PIC); +} + void StandardInstrumentations::registerCallbacks( PassInstrumentationCallbacks &PIC) { PrintIR.registerCallbacks(PIC); @@ -843,6 +1134,7 @@ PrintChangedIR.registerCallbacks(PIC); if (VerifyEach) Verify.registerCallbacks(PIC); + PrintChangedDiff.registerCallbacks(PIC); } namespace llvm { @@ -850,4 +1142,12 @@ template class ChangeReporter; template class TextChangeReporter; +template class BlockDataTemplate; +template class FuncDataTemplate; +template class IRDataTemplate; +template class ChangeReporter; +template class TextChangeReporter; +template class IRComparer; + } // 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 ***