LLVM 24.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
18class DebugLoc;
19class Function;
20
32
33extern LLVM_ABI cl::opt<ChangePrinter> PrintChanged;
34
35// Returns true if printing before/after some pass is enabled, whether all
36// passes or a specific pass.
39
40// Returns true if we should print before/after a specific pass. The argument
41// should be the pass ID, e.g. "instcombine".
42LLVM_ABI bool shouldPrintBeforePass(StringRef PassID);
43LLVM_ABI bool shouldPrintAfterPass(StringRef PassID);
44
45// Returns true if we should print before/after all passes.
48
49// The list of passes to print before/after, if we only want to print
50// before/after specific passes.
51LLVM_ABI std::vector<std::string> printBeforePasses();
52LLVM_ABI std::vector<std::string> printAfterPasses();
53
54// Returns true if we should always print the entire module.
56
57// Returns true if we should print the entire function for loop passes.
59
60// Return true if -filter-passes is empty or contains the pass name.
61LLVM_ABI bool isPassInPrintList(StringRef PassName);
63
64// Returns true if we should print the function.
65LLVM_ABI bool isFunctionInPrintList(StringRef FunctionName);
66
67// Returns true if -filter-print-source-locs is empty or contains the source
68// location.
71
72// Returns true if the print filters allow all functions.
74
75// Returns true if the function passes the function-name and source-location
76// print filters.
78
79// Ensure temporary files exist, creating or re-using them. \p FD contains
80// file descriptors (-1 indicates that the file should be created) and
81// \p SR contains the corresponding initial content. \p FileName will have
82// the filenames filled in when creating files. Return first error code (if
83// any) and stop.
84LLVM_ABI std::error_code prepareTempFiles(SmallVector<int> &FD,
86 SmallVector<std::string> &FileName);
87
88// Remove the temporary files in \p FileName. Typically used in conjunction
89// with prepareTempFiles. Return first error code (if any) and stop..
90LLVM_ABI std::error_code cleanUpTempFiles(ArrayRef<std::string> FileName);
91
92// Perform a system based diff between \p Before and \p After, using \p
93// OldLineFormat, \p NewLineFormat, and \p UnchangedLineFormat to control the
94// formatting of the output. Return an error message for any failures instead
95// of the diff.
96LLVM_ABI std::string doSystemDiff(StringRef Before, StringRef After,
97 StringRef OldLineFormat,
98 StringRef NewLineFormat,
99 StringRef UnchangedLineFormat);
100
101// Report a -print-changed diff for one pass over one IR unit (function or
102// module). IsInteresting is isPassInPrintList(PassID); ShouldReport is whether
103// the unit passed all filters (Before/After are only set then).
104LLVM_ABI void reportChangedIR(StringRef Before, StringRef After,
105 StringRef PassName, StringRef PassID,
106 StringRef IRName, bool IsInteresting,
107 bool ShouldReport);
108
109} // namespace llvm
110
111#endif // LLVM_IR_PRINTPASSES_H
#define LLVM_ABI
Definition Compiler.h:215
#define F(x, y, z)
Definition MD5.cpp:54
static const char PassName[]
A debug info location.
Definition DebugLoc.h:126
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool isSourceLocInPrintList(const DebugLoc &Loc)
ChangePrinter
Definition PrintPasses.h:21
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 bool isSourceLocFilterEmpty()
LLVM_ABI bool shouldPrintFunction(const Function &F)
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 shouldPrintAllFunctions()
LLVM_ABI bool forcePrintFuncIR()