LLVM 20.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
18enum class ChangePrinter {
19 None,
20 Verbose,
21 Quiet,
28};
29
30extern 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".
39bool shouldPrintBeforePass(StringRef PassID);
40bool 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.
48std::vector<std::string> printBeforePasses();
49std::vector<std::string> printAfterPasses();
50
51// Returns true if we should always print the entire module.
53
54// Return true if -filter-passes is empty or contains the pass name.
55bool isPassInPrintList(StringRef PassName);
57
58// Returns true if we should print the function.
59bool isFunctionInPrintList(StringRef FunctionName);
60
61// Ensure temporary files exist, creating or re-using them. \p FD contains
62// file descriptors (-1 indicates that the file should be created) and
63// \p SR contains the corresponding initial content. \p FileName will have
64// the filenames filled in when creating files. Return first error code (if
65// any) and stop.
66std::error_code prepareTempFiles(SmallVector<int> &FD, ArrayRef<StringRef> SR,
67 SmallVector<std::string> &FileName);
68
69// Remove the temporary files in \p FileName. Typically used in conjunction
70// with prepareTempFiles. Return first error code (if any) and stop..
71std::error_code cleanUpTempFiles(ArrayRef<std::string> FileName);
72
73// Perform a system based diff between \p Before and \p After, using \p
74// OldLineFormat, \p NewLineFormat, and \p UnchangedLineFormat to control the
75// formatting of the output. Return an error message for any failures instead
76// of the diff.
77std::string doSystemDiff(StringRef Before, StringRef After,
78 StringRef OldLineFormat, StringRef NewLineFormat,
79 StringRef UnchangedLineFormat);
80
81} // namespace llvm
82
83#endif // LLVM_IR_PRINTPASSES_H
static const char PassName[]
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
ChangePrinter
Definition: PrintPasses.h:18
std::error_code prepareTempFiles(SmallVector< int > &FD, ArrayRef< StringRef > SR, SmallVector< std::string > &FileName)
bool forcePrintModuleIR()
std::vector< std::string > printAfterPasses()
bool shouldPrintBeforeAll()
bool shouldPrintAfterAll()
cl::opt< ChangePrinter > PrintChanged
std::vector< std::string > printBeforePasses()
bool shouldPrintBeforeSomePass()
This is a helper to determine whether to print IR before or after a pass.
bool shouldPrintAfterSomePass()
@ None
Definition: CodeGenData.h:106
bool isFunctionInPrintList(StringRef FunctionName)
bool isPassInPrintList(StringRef PassName)
std::error_code cleanUpTempFiles(ArrayRef< std::string > FileName)
std::string doSystemDiff(StringRef Before, StringRef After, StringRef OldLineFormat, StringRef NewLineFormat, StringRef UnchangedLineFormat)
bool shouldPrintBeforePass(StringRef PassID)
bool shouldPrintAfterPass(StringRef PassID)
bool isFilterPassesEmpty()