LLVM  8.0.0svn
IRPrintingPasses.h
Go to the documentation of this file.
1 //===- IRPrintingPasses.h - Passes to print out IR constructs ---*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 ///
11 /// This file defines passes to print out IR in various granularities. The
12 /// PrintModulePass pass simply prints out the entire module when it is
13 /// executed. The PrintFunctionPass class is designed to be pipelined with
14 /// other FunctionPass's, and prints out the functions of the module as they
15 /// are processed.
16 ///
17 //===----------------------------------------------------------------------===//
18 
19 #ifndef LLVM_IR_IRPRINTINGPASSES_H
20 #define LLVM_IR_IRPRINTINGPASSES_H
21 
22 #include "llvm/ADT/StringRef.h"
23 #include <string>
24 
25 namespace llvm {
26 class Pass;
27 class BasicBlockPass;
28 class Function;
29 class FunctionPass;
30 class Module;
31 class ModulePass;
32 class PreservedAnalyses;
33 class raw_ostream;
34 template <typename IRUnitT, typename... ExtraArgTs> class AnalysisManager;
35 
36 /// Create and return a pass that writes the module to the specified
37 /// \c raw_ostream.
38 ModulePass *createPrintModulePass(raw_ostream &OS,
39  const std::string &Banner = "",
40  bool ShouldPreserveUseListOrder = false);
41 
42 /// Create and return a pass that prints functions to the specified
43 /// \c raw_ostream as they are processed.
44 FunctionPass *createPrintFunctionPass(raw_ostream &OS,
45  const std::string &Banner = "");
46 
47 /// Create and return a pass that writes the BB to the specified
48 /// \c raw_ostream.
49 BasicBlockPass *createPrintBasicBlockPass(raw_ostream &OS,
50  const std::string &Banner = "");
51 
52 /// Print out a name of an LLVM value without any prefixes.
53 ///
54 /// The name is surrounded with ""'s and escaped if it has any special or
55 /// non-printable characters in it.
56 void printLLVMNameWithoutPrefix(raw_ostream &OS, StringRef Name);
57 
58 /// Return true if a pass is for IR printing.
59 bool isIRPrintingPass(Pass *P);
60 
61 /// isFunctionInPrintList - returns true if a function should be printed via
62 // debugging options like -print-after-all/-print-before-all.
63 // Tells if the function IR should be printed by PrinterPass.
64 extern bool isFunctionInPrintList(StringRef FunctionName);
65 
66 /// forcePrintModuleIR - returns true if IR printing passes should
67 // be printing module IR (even for local-pass printers e.g. function-pass)
68 // to provide more context, as enabled by debugging option -print-module-scope
69 // Tells if IR printer should be printing module IR
70 extern bool forcePrintModuleIR();
71 
72 extern bool shouldPrintBeforePass();
73 extern bool shouldPrintBeforePass(StringRef);
74 extern bool shouldPrintAfterPass();
75 extern bool shouldPrintAfterPass(StringRef);
76 
77 /// Pass for printing a Module as LLVM's text IR assembly.
78 ///
79 /// Note: This pass is for use with the new pass manager. Use the create...Pass
80 /// functions above to create passes for use with the legacy pass manager.
82  raw_ostream &OS;
83  std::string Banner;
84  bool ShouldPreserveUseListOrder;
85 
86 public:
88  PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
89  bool ShouldPreserveUseListOrder = false);
90 
92 
93  static StringRef name() { return "PrintModulePass"; }
94 };
95 
96 /// Pass for printing a Function as LLVM's text IR assembly.
97 ///
98 /// Note: This pass is for use with the new pass manager. Use the create...Pass
99 /// functions above to create passes for use with the legacy pass manager.
101  raw_ostream &OS;
102  std::string Banner;
103 
104 public:
106  PrintFunctionPass(raw_ostream &OS, const std::string &Banner = "");
107 
109 
110  static StringRef name() { return "PrintFunctionPass"; }
111 };
112 
113 } // End llvm namespace
114 
115 #endif
bool shouldPrintAfterPass()
bool forcePrintModuleIR()
forcePrintModuleIR - returns true if IR printing passes should
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:64
Pass for printing a Module as LLVM&#39;s text IR assembly.
bool shouldPrintBeforePass()
This is a helper to determine whether to print IR before or after a pass.
FunctionPass * createPrintFunctionPass(raw_ostream &OS, const std::string &Banner="")
Create and return a pass that prints functions to the specified raw_ostream as they are processed...
static StringRef name()
F(f)
amdgpu Simplify well known AMD library false Value Value const Twine & Name
bool isIRPrintingPass(Pass *P)
Return true if a pass is for IR printing.
static StringRef name()
#define P(N)
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:154
print lazy value Lazy Value Info Printer Pass
void printLLVMNameWithoutPrefix(raw_ostream &OS, StringRef Name)
Print out a name of an LLVM value without any prefixes.
Definition: AsmWriter.cpp:399
BasicBlockPass * createPrintBasicBlockPass(raw_ostream &OS, const std::string &Banner="")
Create and return a pass that writes the BB to the specified raw_ostream.
bool isFunctionInPrintList(StringRef FunctionName)
isFunctionInPrintList - returns true if a function should be printed via
PreservedAnalyses run(Module &M, AnalysisManager< Module > &)
ModulePass * createPrintModulePass(raw_ostream &OS, const std::string &Banner="", bool ShouldPreserveUseListOrder=false)
Create and return a pass that writes the module to the specified raw_ostream.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
A container for analyses that lazily runs them and caches their results.
Pass for printing a Function as LLVM&#39;s text IR assembly.