15#include <unordered_set>
64 clEnumValN(ChangePrinter::Quiet,
"quiet",
"Run in quiet mode"),
66 "Display patch-like changes"),
67 clEnumValN(ChangePrinter::DiffQuiet,
"diff-quiet",
68 "Display patch-like changes in quiet mode"),
69 clEnumValN(ChangePrinter::ColourDiffVerbose,
"cdiff",
70 "Display patch-like changes with color"),
71 clEnumValN(ChangePrinter::ColourDiffQuiet,
"cdiff-quiet",
72 "Display patch-like changes in quiet mode with color"),
73 clEnumValN(ChangePrinter::DotCfgVerbose,
"dot-cfg",
74 "Create a website with graphical changes"),
75 clEnumValN(ChangePrinter::DotCfgQuiet,
"dot-cfg-quiet",
76 "Create a website with graphical changes in quiet mode"),
83 cl::desc(
"system diff used by change reporters"));
87 cl::desc(
"When printing IR for print-[before|after]{-all} "
88 "always print a module IR"),
95 cl::desc(
"Only consider IR changes for passes whose names "
96 "match the specified value. No-op without -print-changed"),
101 cl::desc(
"Only print IR for functions whose name "
102 "match this for all print-[before|after][-all] "
145 static std::unordered_set<std::string> Set(
FilterPasses.begin(),
147 return Set.empty() || Set.count(std::string(
PassName));
153 static std::unordered_set<std::string> PrintFuncNames(
PrintFuncsList.begin(),
155 return PrintFuncNames.empty() ||
156 PrintFuncNames.count(std::string(FunctionName));
162 for (
unsigned I = 0;
I <
N; ++
I) {
174 "Unexpected array sizes");
177 for (;
I < FD.
size(); ++
I) {
216 return "Unable to create temporary file.";
220 return "Unable to find diff executable.";
223 (
"--old-line-format=" + OldLineFormat).toVector(OLF);
224 (
"--new-line-format=" + NewLineFormat).toVector(NLF);
225 (
"--unchanged-line-format=" + UnchangedLineFormat).toVector(ULF);
228 NLF, ULF, FileName[0], FileName[1]};
229 std::optional<StringRef> Redirects[] = {std::nullopt,
StringRef(FileName[2]),
233 return "Error executing system diff.";
237 Diff = (*B)->getBuffer().str();
239 return "Unable to read result.";
242 return "Unable to remove temporary file.";
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
static bool shouldPrintBeforeOrAfterPass(StringRef PassID, ArrayRef< std::string > PassesToPrint)
static cl::opt< bool > PrintBeforeAll("print-before-all", llvm::cl::desc("Print IR before each pass"), cl::init(false), cl::Hidden)
static cl::opt< bool > PrintModuleScope("print-module-scope", cl::desc("When printing IR for print-[before|after]{-all} " "always print a module IR"), cl::init(false), cl::Hidden)
static cl::list< std::string > PrintBefore("print-before", llvm::cl::desc("Print IR before specified passes"), cl::CommaSeparated, cl::Hidden)
static cl::list< std::string > FilterPasses("filter-passes", cl::value_desc("pass names"), cl::desc("Only consider IR changes for passes whose names " "match the specified value. No-op without -print-changed"), cl::CommaSeparated, cl::Hidden)
static cl::list< std::string > PrintAfter("print-after", llvm::cl::desc("Print IR after specified passes"), cl::CommaSeparated, cl::Hidden)
static cl::opt< bool > PrintAfterAll("print-after-all", llvm::cl::desc("Print IR after each pass"), cl::init(false), cl::Hidden)
static cl::opt< std::string > DiffBinary("print-changed-diff-path", cl::Hidden, cl::init("diff"), cl::desc("system diff used by change reporters"))
std::error_code cleanUpTempFilesImpl(ArrayRef< std::string > FileName, unsigned N)
static cl::list< std::string > PrintFuncsList("filter-print-funcs", cl::value_desc("function names"), cl::desc("Only print IR for functions whose name " "match this for all print-[before|after][-all] " "options"), cl::CommaSeparated, cl::Hidden)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static const char PassName[]
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
Represents either an error or a value T.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::string str() const
Return the twine contents as a std::string.
A raw_ostream that writes to a file descriptor.
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
initializer< Ty > init(const Ty &Val)
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
std::error_code openFileForWrite(const Twine &Name, int &ResultFD, CreationDisposition Disp=CD_CreateAlways, OpenFlags Flags=OF_None, unsigned Mode=0666)
Opens the file with the given name in a write-only or read-write mode, returning its open file descri...
std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix, int &ResultFD, SmallVectorImpl< char > &ResultPath, OpenFlags Flags=OF_None)
Create a file in the system temporary directory.
int ExecuteAndWait(StringRef Program, ArrayRef< StringRef > Args, std::optional< ArrayRef< StringRef > > Env=std::nullopt, ArrayRef< std::optional< StringRef > > Redirects={}, unsigned SecondsToWait=0, unsigned MemoryLimit=0, std::string *ErrMsg=nullptr, bool *ExecutionFailed=nullptr, std::optional< ProcessStatistics > *ProcStat=nullptr, BitVector *AffinityMask=nullptr)
This function executes the program using the arguments provided.
ErrorOr< std::string > findProgramByName(StringRef Name, ArrayRef< StringRef > Paths={})
Find the first executable file Name in Paths.
This is an optimization pass for GlobalISel generic memory operations.
std::error_code prepareTempFiles(SmallVector< int > &FD, ArrayRef< StringRef > SR, SmallVector< std::string > &FileName)
bool forcePrintModuleIR()
std::error_code make_error_code(BitcodeError E)
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()
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 is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
bool shouldPrintBeforePass(StringRef PassID)
bool shouldPrintAfterPass(StringRef PassID)
bool isFilterPassesEmpty()