LLVM 23.0.0git
PrintPasses.h
Go to the documentation of this file.
1//===- PrintPasses.h - Determining whether/when to print IR ---------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_IR_PRINTPASSES_H
10#define LLVM_IR_PRINTPASSES_H
11
12#include "llvm/ADT/StringRef.h"
14#include <vector>
15
16namespace llvm {
17
29
30extern LLVM_ABI cl::opt<ChangePrinter> PrintChanged;
31
32// Returns true if printing before/after some pass is enabled, whether all
33// passes or a specific pass.
36
37// Returns true if we should print before/after a specific pass. The argument
38// should be the pass ID, e.g. "instcombine".
39LLVM_ABI bool shouldPrintBeforePass(StringRef PassID);
40LLVM_ABI bool shouldPrintAfterPass(StringRef PassID);
41
42// Returns true if we should print before/after all passes.
45
46// The list of passes to print before/after, if we only want to print
47// before/after specific passes.
48LLVM_ABI std::vector<std::string> printBeforePasses();
49LLVM_ABI std::vector<std::string> printAfterPasses();
50
51// Returns true if we should always print the entire module.
53
54// Returns true if we should print the entire function for loop passes.
56
57// Return true if -filter-passes is empty or contains the pass name.
58LLVM_ABI bool isPassInPrintList(StringRef PassName);
60
61// Returns true if we should print the function.
62LLVM_ABI bool isFunctionInPrintList(StringRef FunctionName);
63
64// Ensure temporary files exist, creating or re-using them. \p FD contains
65// file descriptors (-1 indicates that the file should be created) and
66// \p SR contains the corresponding initial content. \p FileName will have
67// the filenames filled in when creating files. Return first error code (if
68// any) and stop.
69LLVM_ABI std::error_code prepareTempFiles(SmallVector<int> &FD,
71 SmallVector<std::string> &FileName);
72
73// Remove the temporary files in \p FileName. Typically used in conjunction
74// with prepareTempFiles. Return first error code (if any) and stop..
75LLVM_ABI std::error_code cleanUpTempFiles(ArrayRef<std::string> FileName);
76
77// Perform a system based diff between \p Before and \p After, using \p
78// OldLineFormat, \p NewLineFormat, and \p UnchangedLineFormat to control the
79// formatting of the output. Return an error message for any failures instead
80// of the diff.
81LLVM_ABI std::string doSystemDiff(StringRef Before, StringRef After,
82 StringRef OldLineFormat,
83 StringRef NewLineFormat,
84 StringRef UnchangedLineFormat);
85
86// Report a -print-changed diff for one pass over one IR unit (function or
87// module). IsInteresting is isPassInPrintList(PassID); ShouldReport is whether
88// the unit passed all filters (Before/After are only set then).
89LLVM_ABI void reportChangedIR(StringRef Before, StringRef After,
90 StringRef PassName, StringRef PassID,
91 StringRef IRName, bool IsInteresting,
92 bool ShouldReport);
93
94} // namespace llvm
95
96#endif // LLVM_IR_PRINTPASSES_H
#define LLVM_ABI
Definition Compiler.h:213
static const char PassName[]
This is an optimization pass for GlobalISel generic memory operations.
ChangePrinter
Definition PrintPasses.h:18
LLVM_ABI std::error_code prepareTempFiles(SmallVector< int > &FD, ArrayRef< StringRef > SR, SmallVector< std::string > &FileName)
LLVM_ABI bool forcePrintModuleIR()
LLVM_ABI std::vector< std::string > printAfterPasses()
LLVM_ABI void reportChangedIR(StringRef Before, StringRef After, StringRef PassName, StringRef PassID, StringRef IRName, bool IsInteresting, bool ShouldReport)
LLVM_ABI bool shouldPrintBeforeAll()
LLVM_ABI bool shouldPrintAfterAll()
LLVM_ABI cl::opt< ChangePrinter > PrintChanged
LLVM_ABI std::vector< std::string > printBeforePasses()
LLVM_ABI bool shouldPrintBeforeSomePass()
This is a helper to determine whether to print IR before or after a pass.
LLVM_ABI bool shouldPrintAfterSomePass()
LLVM_ABI bool isFunctionInPrintList(StringRef FunctionName)
LLVM_ABI bool isPassInPrintList(StringRef PassName)
LLVM_ABI std::error_code cleanUpTempFiles(ArrayRef< std::string > FileName)
LLVM_ABI std::string doSystemDiff(StringRef Before, StringRef After, StringRef OldLineFormat, StringRef NewLineFormat, StringRef UnchangedLineFormat)
ArrayRef(const T &OneElt) -> ArrayRef< T >
LLVM_ABI bool shouldPrintBeforePass(StringRef PassID)
LLVM_ABI bool shouldPrintAfterPass(StringRef PassID)
LLVM_ABI bool isFilterPassesEmpty()
LLVM_ABI bool forcePrintFuncIR()