• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-12-stable/contrib/llvm-project/llvm/lib/Passes/

Lines Matching defs:IR

10 /// This file defines IR-printing pass instrumentation callbacks as well as
20 #include "llvm/IR/Function.h"
21 #include "llvm/IR/IRPrintingPasses.h"
22 #include "llvm/IR/Module.h"
23 #include "llvm/IR/PassInstrumentation.h"
32 /// Extracting Module out of \p IR unit. Also fills a textual description
33 /// of \p IR for use in header when printing.
34 Optional<std::pair<const Module *, std::string>> unwrapModule(Any IR) {
35 if (any_isa<const Module *>(IR))
36 return std::make_pair(any_cast<const Module *>(IR), std::string());
38 if (any_isa<const Function *>(IR)) {
39 const Function *F = any_cast<const Function *>(IR);
46 if (any_isa<const LazyCallGraph::SCC *>(IR)) {
47 const LazyCallGraph::SCC *C = any_cast<const LazyCallGraph::SCC *>(IR);
58 if (any_isa<const Loop *>(IR)) {
59 const Loop *L = any_cast<const Loop *>(IR);
70 llvm_unreachable("Unknown IR unit");
104 /// Generic IR-printing helper that unpacks a pointer to IRUnit wrapped into
106 void unwrapAndPrint(Any IR, StringRef Banner, bool ForceModule = false) {
108 if (auto UnwrappedModule = unwrapModule(IR))
113 if (any_isa<const Module *>(IR)) {
114 const Module *M = any_cast<const Module *>(IR);
120 if (any_isa<const Function *>(IR)) {
121 const Function *F = any_cast<const Function *>(IR);
127 if (any_isa<const LazyCallGraph::SCC *>(IR)) {
128 const LazyCallGraph::SCC *C = any_cast<const LazyCallGraph::SCC *>(IR);
135 if (any_isa<const Loop *>(IR)) {
136 const Loop *L = any_cast<const Loop *>(IR);
141 llvm_unreachable("Unknown wrapped IR type");
150 void PrintIRInstrumentation::pushModuleDesc(StringRef PassID, Any IR) {
154 if (auto UnwrappedModule = unwrapModule(IR))
167 bool PrintIRInstrumentation::printBeforePass(StringRef PassID, Any IR) {
176 pushModuleDesc(PassID, IR);
181 SmallString<20> Banner = formatv("*** IR Dump Before {0} ***", PassID);
182 unwrapAndPrint(IR, Banner, llvm::forcePrintModuleIR());
186 void PrintIRInstrumentation::printAfterPass(StringRef PassID, Any IR) {
196 SmallString<20> Banner = formatv("*** IR Dump After {0} ***", PassID);
197 unwrapAndPrint(IR, Banner, llvm::forcePrintModuleIR());
217 formatv("*** IR Dump After {0} *** invalidated: ", PassID);
228 [this](StringRef P, Any IR) { return this->printBeforePass(P, IR); });
232 [this](StringRef P, Any IR) { this->printAfterPass(P, IR); });