[llvm] 7059a6c - [IR] Split out IR printing passes into IRPrinter

Alexander Shaposhnikov via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 17 17:51:21 PST 2022


Author: Alexander Shaposhnikov
Date: 2022-11-18T01:47:56Z
New Revision: 7059a6c32cfad8f272fad47265e3890cd7a1a7e1

URL: https://github.com/llvm/llvm-project/commit/7059a6c32cfad8f272fad47265e3890cd7a1a7e1
DIFF: https://github.com/llvm/llvm-project/commit/7059a6c32cfad8f272fad47265e3890cd7a1a7e1.diff

LOG: [IR] Split out IR printing passes into IRPrinter

This diff splits out (from LLVMCore) IR printing passes into IRPrinter.
This structure is similar to what we already have for IRReader and
enables us to avoid circular dependencies between LLVMCore and Analysis
(this is a preparation for https://reviews.llvm.org/D137768).
The legacy interface is left unchanged, once the legacy pass manager
is removed (in the future) we will be able to clean it up further.
The bazel build configuration has been updated as well.

Test plan:
1/ Tested the following cmake configurations: static/dynamic linking * lld/gold * clang/gcc
2/ bazel build --config=generic_clang @llvm-project//...

Differential revision: https://reviews.llvm.org/D138081

Added: 
    llvm/include/llvm/IRPrinter/IRPrintingPasses.h
    llvm/lib/IRPrinter/CMakeLists.txt
    llvm/lib/IRPrinter/IRPrintingPasses.cpp

Modified: 
    clang/lib/CodeGen/BackendUtil.cpp
    clang/lib/CodeGen/CMakeLists.txt
    llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
    llvm/include/llvm/IR/IRPrintingPasses.h
    llvm/lib/CMakeLists.txt
    llvm/lib/IR/IRPrintingPasses.cpp
    llvm/lib/Passes/CMakeLists.txt
    llvm/lib/Passes/PassBuilder.cpp
    llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
    llvm/tools/llc/llc.cpp
    llvm/tools/opt/CMakeLists.txt
    llvm/tools/opt/NewPMDriver.cpp
    utils/bazel/llvm-project-overlay/clang/BUILD.bazel
    utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
    utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 8498ca2e63388..9c677140b4a5d 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -31,7 +31,7 @@
 #include "llvm/CodeGen/TargetSubtargetInfo.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DebugInfo.h"
-#include "llvm/IR/IRPrintingPasses.h"
+#include "llvm/IRPrinter/IRPrintingPasses.h"
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/ModuleSummaryIndex.h"

diff  --git a/clang/lib/CodeGen/CMakeLists.txt b/clang/lib/CodeGen/CMakeLists.txt
index a97042ee2008b..802c34b5b7e19 100644
--- a/clang/lib/CodeGen/CMakeLists.txt
+++ b/clang/lib/CodeGen/CMakeLists.txt
@@ -10,6 +10,7 @@ set(LLVM_LINK_COMPONENTS
   FrontendHLSL
   FrontendOpenMP
   IPO
+  IRPrinter
   IRReader
   AggressiveInstCombine
   InstCombine

diff  --git a/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h b/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
index 15f46cf46ba7e..95625d13021eb 100644
--- a/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h
@@ -29,7 +29,7 @@
 #include "llvm/CodeGen/PreISelIntrinsicLowering.h"
 #include "llvm/CodeGen/ReplaceWithVeclib.h"
 #include "llvm/CodeGen/UnreachableBlockElim.h"
-#include "llvm/IR/IRPrintingPasses.h"
+#include "llvm/IRPrinter/IRPrintingPasses.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/MC/MCAsmInfo.h"

diff  --git a/llvm/include/llvm/IR/IRPrintingPasses.h b/llvm/include/llvm/IR/IRPrintingPasses.h
index 3fba5b81e37a9..942e420a2d659 100644
--- a/llvm/include/llvm/IR/IRPrintingPasses.h
+++ b/llvm/include/llvm/IR/IRPrintingPasses.h
@@ -7,18 +7,14 @@
 //===----------------------------------------------------------------------===//
 /// \file
 ///
-/// This file defines passes to print out IR in various granularities. The
-/// PrintModulePass pass simply prints out the entire module when it is
-/// executed. The PrintFunctionPass class is designed to be pipelined with
-/// other FunctionPass's, and prints out the functions of the module as they
-/// are processed.
+/// This file contains an interface for creating legacy passes to print out IR
+/// in various granularities.
 ///
 //===----------------------------------------------------------------------===//
 
 #ifndef LLVM_IR_IRPRINTINGPASSES_H
 #define LLVM_IR_IRPRINTINGPASSES_H
 
-#include "llvm/IR/PassManager.h"
 #include <string>
 
 namespace llvm {
@@ -50,40 +46,6 @@ void printLLVMNameWithoutPrefix(raw_ostream &OS, StringRef Name);
 /// Return true if a pass is for IR printing.
 bool isIRPrintingPass(Pass *P);
 
-/// Pass for printing a Module as LLVM's text IR assembly.
-///
-/// Note: This pass is for use with the new pass manager. Use the create...Pass
-/// functions above to create passes for use with the legacy pass manager.
-class PrintModulePass : public PassInfoMixin<PrintModulePass> {
-  raw_ostream &OS;
-  std::string Banner;
-  bool ShouldPreserveUseListOrder;
-
-public:
-  PrintModulePass();
-  PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
-                  bool ShouldPreserveUseListOrder = false);
-
-  PreservedAnalyses run(Module &M, AnalysisManager<Module> &);
-  static bool isRequired() { return true; }
-};
-
-/// Pass for printing a Function as LLVM's text IR assembly.
-///
-/// Note: This pass is for use with the new pass manager. Use the create...Pass
-/// functions above to create passes for use with the legacy pass manager.
-class PrintFunctionPass : public PassInfoMixin<PrintFunctionPass> {
-  raw_ostream &OS;
-  std::string Banner;
-
-public:
-  PrintFunctionPass();
-  PrintFunctionPass(raw_ostream &OS, const std::string &Banner = "");
-
-  PreservedAnalyses run(Function &F, AnalysisManager<Function> &);
-  static bool isRequired() { return true; }
-};
-
 } // namespace llvm
 
 #endif

diff  --git a/llvm/include/llvm/IRPrinter/IRPrintingPasses.h b/llvm/include/llvm/IRPrinter/IRPrintingPasses.h
new file mode 100644
index 0000000000000..6cfa7a87af933
--- /dev/null
+++ b/llvm/include/llvm/IRPrinter/IRPrintingPasses.h
@@ -0,0 +1,63 @@
+//===- IRPrintingPasses.h - Passes to print out IR constructs ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+/// \file
+///
+/// This file defines passes to print out IR in various granularities. The
+/// PrintModulePass pass simply prints out the entire module when it is
+/// executed. The PrintFunctionPass class is designed to be pipelined with
+/// other FunctionPass's, and prints out the functions of the module as they
+/// are processed.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_IRPRINTER_IRPRINTINGPASSES_H
+#define LLVM_IRPRINTER_IRPRINTINGPASSES_H
+
+#include "llvm/IR/PassManager.h"
+#include <string>
+
+namespace llvm {
+class raw_ostream;
+class StringRef;
+class Function;
+class Module;
+class Pass;
+
+/// Pass (for the new pass manager) for printing a Module as
+/// LLVM's text IR assembly.
+class PrintModulePass : public PassInfoMixin<PrintModulePass> {
+  raw_ostream &OS;
+  std::string Banner;
+  bool ShouldPreserveUseListOrder;
+
+public:
+  PrintModulePass();
+  PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
+                  bool ShouldPreserveUseListOrder = false);
+
+  PreservedAnalyses run(Module &M, AnalysisManager<Module> &);
+  static bool isRequired() { return true; }
+};
+
+/// Pass (for the new pass manager) for printing a Function as
+/// LLVM's text IR assembly.
+class PrintFunctionPass : public PassInfoMixin<PrintFunctionPass> {
+  raw_ostream &OS;
+  std::string Banner;
+
+public:
+  PrintFunctionPass();
+  PrintFunctionPass(raw_ostream &OS, const std::string &Banner = "");
+
+  PreservedAnalyses run(Function &F, AnalysisManager<Function> &);
+  static bool isRequired() { return true; }
+};
+
+} // namespace llvm
+
+#endif

diff  --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt
index 5ecdf5af956a3..52772fefdb20f 100644
--- a/llvm/lib/CMakeLists.txt
+++ b/llvm/lib/CMakeLists.txt
@@ -7,6 +7,7 @@ add_subdirectory(IR)
 add_subdirectory(FuzzMutate)
 add_subdirectory(FileCheck)
 add_subdirectory(InterfaceStub)
+add_subdirectory(IRPrinter)
 add_subdirectory(IRReader)
 add_subdirectory(CodeGen)
 add_subdirectory(BinaryFormat)

diff  --git a/llvm/lib/IR/IRPrintingPasses.cpp b/llvm/lib/IR/IRPrintingPasses.cpp
index 8d6fe1eb61347..78c2f192d2c0c 100644
--- a/llvm/lib/IR/IRPrintingPasses.cpp
+++ b/llvm/lib/IR/IRPrintingPasses.cpp
@@ -6,7 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// PrintModulePass and PrintFunctionPass implementations.
+// PrintModulePass and PrintFunctionPass implementations for the legacy pass
+// manager.
 //
 //===----------------------------------------------------------------------===//
 
@@ -22,63 +23,38 @@
 
 using namespace llvm;
 
-PrintModulePass::PrintModulePass() : OS(dbgs()) {}
-PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner,
-                                 bool ShouldPreserveUseListOrder)
-    : OS(OS), Banner(Banner),
-      ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
-
-PreservedAnalyses PrintModulePass::run(Module &M, ModuleAnalysisManager &) {
-  if (llvm::isFunctionInPrintList("*")) {
-    if (!Banner.empty())
-      OS << Banner << "\n";
-    M.print(OS, nullptr, ShouldPreserveUseListOrder);
-  }
-  else {
-    bool BannerPrinted = false;
-    for(const auto &F : M.functions()) {
-      if (llvm::isFunctionInPrintList(F.getName())) {
-        if (!BannerPrinted && !Banner.empty()) {
-          OS << Banner << "\n";
-          BannerPrinted = true;
-        }
-        F.print(OS);
-      }
-    }
-  }
-  return PreservedAnalyses::all();
-}
-
-PrintFunctionPass::PrintFunctionPass() : OS(dbgs()) {}
-PrintFunctionPass::PrintFunctionPass(raw_ostream &OS, const std::string &Banner)
-    : OS(OS), Banner(Banner) {}
-
-PreservedAnalyses PrintFunctionPass::run(Function &F,
-                                         FunctionAnalysisManager &) {
-  if (isFunctionInPrintList(F.getName())) {
-    if (forcePrintModuleIR())
-      OS << Banner << " (function: " << F.getName() << ")\n" << *F.getParent();
-    else
-      OS << Banner << '\n' << static_cast<Value &>(F);
-  }
-  return PreservedAnalyses::all();
-}
-
 namespace {
 
 class PrintModulePassWrapper : public ModulePass {
-  PrintModulePass P;
+  raw_ostream &OS;
+  std::string Banner;
+  bool ShouldPreserveUseListOrder;
 
 public:
   static char ID;
-  PrintModulePassWrapper() : ModulePass(ID) {}
+  PrintModulePassWrapper() : ModulePass(ID), OS(dbgs()) {}
   PrintModulePassWrapper(raw_ostream &OS, const std::string &Banner,
                          bool ShouldPreserveUseListOrder)
-      : ModulePass(ID), P(OS, Banner, ShouldPreserveUseListOrder) {}
+      : ModulePass(ID), OS(OS), Banner(Banner),
+        ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
 
   bool runOnModule(Module &M) override {
-    ModuleAnalysisManager DummyMAM;
-    P.run(M, DummyMAM);
+    if (llvm::isFunctionInPrintList("*")) {
+      if (!Banner.empty())
+        OS << Banner << "\n";
+      M.print(OS, nullptr, ShouldPreserveUseListOrder);
+    } else {
+      bool BannerPrinted = false;
+      for (const auto &F : M.functions()) {
+        if (llvm::isFunctionInPrintList(F.getName())) {
+          if (!BannerPrinted && !Banner.empty()) {
+            OS << Banner << "\n";
+            BannerPrinted = true;
+          }
+          F.print(OS);
+        }
+      }
+    }
     return false;
   }
 
@@ -90,18 +66,24 @@ class PrintModulePassWrapper : public ModulePass {
 };
 
 class PrintFunctionPassWrapper : public FunctionPass {
-  PrintFunctionPass P;
+  raw_ostream &OS;
+  std::string Banner;
 
 public:
   static char ID;
-  PrintFunctionPassWrapper() : FunctionPass(ID) {}
+  PrintFunctionPassWrapper() : FunctionPass(ID), OS(dbgs()) {}
   PrintFunctionPassWrapper(raw_ostream &OS, const std::string &Banner)
-      : FunctionPass(ID), P(OS, Banner) {}
+      : FunctionPass(ID), OS(OS), Banner(Banner) {}
 
   // This pass just prints a banner followed by the function as it's processed.
   bool runOnFunction(Function &F) override {
-    FunctionAnalysisManager DummyFAM;
-    P.run(F, DummyFAM);
+    if (isFunctionInPrintList(F.getName())) {
+      if (forcePrintModuleIR())
+        OS << Banner << " (function: " << F.getName() << ")\n"
+           << *F.getParent();
+      else
+        OS << Banner << '\n' << static_cast<Value &>(F);
+    }
     return false;
   }
 
@@ -112,7 +94,7 @@ class PrintFunctionPassWrapper : public FunctionPass {
   StringRef getPassName() const override { return "Print Function IR"; }
 };
 
-}
+} // namespace
 
 char PrintModulePassWrapper::ID = 0;
 INITIALIZE_PASS(PrintModulePassWrapper, "print-module",
@@ -133,7 +115,7 @@ FunctionPass *llvm::createPrintFunctionPass(llvm::raw_ostream &OS,
 }
 
 bool llvm::isIRPrintingPass(Pass *P) {
-  const char *PID = (const char*)P->getPassID();
+  const char *PID = (const char *)P->getPassID();
 
   return (PID == &PrintModulePassWrapper::ID) ||
          (PID == &PrintFunctionPassWrapper::ID);

diff  --git a/llvm/lib/IRPrinter/CMakeLists.txt b/llvm/lib/IRPrinter/CMakeLists.txt
new file mode 100644
index 0000000000000..926835ab965bc
--- /dev/null
+++ b/llvm/lib/IRPrinter/CMakeLists.txt
@@ -0,0 +1,13 @@
+add_llvm_component_library(LLVMIRPrinter
+  IRPrintingPasses.cpp
+
+  ADDITIONAL_HEADER_DIRS
+  ${LLVM_MAIN_INCLUDE_DIR}/llvm/IRPrinter
+
+  DEPENDS
+  intrinsics_gen
+
+  LINK_COMPONENTS
+  Core
+  Support
+  )

diff  --git a/llvm/lib/IRPrinter/IRPrintingPasses.cpp b/llvm/lib/IRPrinter/IRPrintingPasses.cpp
new file mode 100644
index 0000000000000..4b31c68bfc2b6
--- /dev/null
+++ b/llvm/lib/IRPrinter/IRPrintingPasses.cpp
@@ -0,0 +1,63 @@
+//===--- IRPrintingPasses.cpp - Module and Function printing passes -------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// PrintModulePass and PrintFunctionPass implementations.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/IRPrinter/IRPrintingPasses.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PrintPasses.h"
+#include "llvm/Pass.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+
+PrintModulePass::PrintModulePass() : OS(dbgs()) {}
+PrintModulePass::PrintModulePass(raw_ostream &OS, const std::string &Banner,
+                                 bool ShouldPreserveUseListOrder)
+    : OS(OS), Banner(Banner),
+      ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
+
+PreservedAnalyses PrintModulePass::run(Module &M, ModuleAnalysisManager &) {
+  if (llvm::isFunctionInPrintList("*")) {
+    if (!Banner.empty())
+      OS << Banner << "\n";
+    M.print(OS, nullptr, ShouldPreserveUseListOrder);
+  } else {
+    bool BannerPrinted = false;
+    for (const auto &F : M.functions()) {
+      if (llvm::isFunctionInPrintList(F.getName())) {
+        if (!BannerPrinted && !Banner.empty()) {
+          OS << Banner << "\n";
+          BannerPrinted = true;
+        }
+        F.print(OS);
+      }
+    }
+  }
+  return PreservedAnalyses::all();
+}
+
+PrintFunctionPass::PrintFunctionPass() : OS(dbgs()) {}
+PrintFunctionPass::PrintFunctionPass(raw_ostream &OS, const std::string &Banner)
+    : OS(OS), Banner(Banner) {}
+
+PreservedAnalyses PrintFunctionPass::run(Function &F,
+                                         FunctionAnalysisManager &) {
+  if (isFunctionInPrintList(F.getName())) {
+    if (forcePrintModuleIR())
+      OS << Banner << " (function: " << F.getName() << ")\n" << *F.getParent();
+    else
+      OS << Banner << '\n' << static_cast<Value &>(F);
+  }
+  return PreservedAnalyses::all();
+}

diff  --git a/llvm/lib/Passes/CMakeLists.txt b/llvm/lib/Passes/CMakeLists.txt
index 703969f8b5f40..c60706be266c4 100644
--- a/llvm/lib/Passes/CMakeLists.txt
+++ b/llvm/lib/Passes/CMakeLists.txt
@@ -20,6 +20,7 @@ add_llvm_component_library(LLVMPasses
   Coroutines
   IPO
   InstCombine
+  IRPrinter
   ObjCARC
   Scalar
   Support

diff  --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index b84f0db188da6..3371e6ee6a9c4 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -75,7 +75,7 @@
 #include "llvm/Analysis/TypeBasedAliasAnalysis.h"
 #include "llvm/IR/DebugInfo.h"
 #include "llvm/IR/Dominators.h"
-#include "llvm/IR/IRPrintingPasses.h"
+#include "llvm/IRPrinter/IRPrintingPasses.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/PrintPasses.h"
 #include "llvm/IR/SafepointIRVerifier.h"

diff  --git a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
index 7031b66c9668f..50daa9994ec23 100644
--- a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
+++ b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
@@ -22,7 +22,7 @@
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/CodeGen/TargetPassConfig.h"
-#include "llvm/IR/IRPrintingPasses.h"
+#include "llvm/IRPrinter/IRPrintingPasses.h"
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/MC/MCSectionDXContainer.h"
 #include "llvm/MC/SectionKind.h"

diff  --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index 24017dbafedc2..efc9b0c502e50 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -28,7 +28,7 @@
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/IR/IRPrintingPasses.h"
+#include "llvm/IRPrinter/IRPrintingPasses.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/LLVMRemarkStreamer.h"
 #include "llvm/IR/LegacyPassManager.h"

diff  --git a/llvm/tools/opt/CMakeLists.txt b/llvm/tools/opt/CMakeLists.txt
index e5d9d28d50065..6d215509ac237 100644
--- a/llvm/tools/opt/CMakeLists.txt
+++ b/llvm/tools/opt/CMakeLists.txt
@@ -14,6 +14,7 @@ set(LLVM_LINK_COMPONENTS
   Extensions
   IPO
   IRReader
+  IRPrinter
   InstCombine
   Instrumentation
   MC

diff  --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index d4bf250bc78de..8c4233f8f5560 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -21,7 +21,7 @@
 #include "llvm/Bitcode/BitcodeWriterPass.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/Dominators.h"
-#include "llvm/IR/IRPrintingPasses.h"
+#include "llvm/IRPrinter/IRPrintingPasses.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/PassManager.h"

diff  --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
index e1af45b50e54d..2d6ce68b99895 100644
--- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -1642,6 +1642,7 @@ cc_library(
         "//llvm:FrontendHLSL",
         "//llvm:FrontendOpenMP",
         "//llvm:IPO",
+        "//llvm:IRPrinter",
         "//llvm:IRReader",
         "//llvm:InstCombine",
         "//llvm:Instrumentation",

diff  --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
index ee5bf5ed9c7a6..0cbd51b0591b8 100644
--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -915,6 +915,7 @@ cc_library(
         ":BinaryFormat",
         ":BitReader",
         ":Core",
+        ":IRPrinter",
         ":IRReader",
         ":MC",
         ":MCParser",
@@ -1374,6 +1375,22 @@ cc_library(
     ],
 )
 
+cc_library(
+    name = "IRPrinter",
+    srcs = glob([
+        "lib/IRPrinter/*.cpp",
+        "lib/IRPrinter/*.h",
+    ]),
+    hdrs = glob([
+        "include/llvm/IRPrinter/*.h",
+    ]),
+    copts = llvm_copts,
+    deps = [
+        ":Core",
+        ":Support",
+    ],
+)
+
 cc_library(
     name = "IRReader",
     srcs = glob([
@@ -1437,6 +1454,7 @@ cc_library(
         ":BitWriter",
         ":Core",
         ":FrontendOpenMP",
+        ":IRPrinter",
         ":IRReader",
         ":InstCombine",
         ":Instrumentation",
@@ -2259,6 +2277,7 @@ cc_library(
         ":BitWriter",
         ":CodeGen",
         ":Core",
+        ":IRPrinter",
         ":IRReader",
         ":Linker",
         ":MC",
@@ -2745,6 +2764,7 @@ cc_binary(
         ":BitReader",
         ":CodeGen",
         ":Core",
+        ":IRPrinter",
         ":IRReader",
         ":MC",
         ":Support",
@@ -2787,6 +2807,7 @@ cc_binary(
         ":CodeGen",
         ":Core",
         ":ExecutionEngine",
+        ":IRPrinter",
         ":IRReader",
         ":Instrumentation",
         ":Interpreter",
@@ -2885,6 +2906,7 @@ cc_binary(
         ":BitReader",
         ":BitWriter",
         ":Core",
+        ":IRPrinter",
         ":IRReader",
         ":Support",
     ],
@@ -3177,6 +3199,7 @@ cc_binary(
         ":BitWriter",
         ":Core",
         ":IPO",
+        ":IRPrinter",
         ":IRReader",
         ":Support",
     ],
@@ -3310,6 +3333,7 @@ cc_binary(
         ":BitWriter",
         ":Core",
         ":IPO",
+        ":IRPrinter",
         ":IRReader",
         ":Linker",
         ":Object",
@@ -3370,6 +3394,7 @@ cc_binary(
         ":BitWriter",
         ":CodeGen",
         ":Core",
+        ":IRPrinter",
         ":IRReader",
         ":LTO",
         ":Support",
@@ -3481,6 +3506,7 @@ cc_binary(
     deps = [
         ":BitReader",
         ":BitWriter",
+        ":IRPrinter",
         ":IRReader",
         ":Support",
     ],
@@ -4036,6 +4062,7 @@ cc_binary(
     deps = [
         ":BitWriter",
         ":Core",
+        ":IRPrinter",
         ":IRReader",
         ":Support",
         ":TransformUtils",
@@ -4161,6 +4188,7 @@ cc_binary(
         ":BitWriter",
         ":CodeGen",
         ":Core",
+        ":IRPrinter",
         ":IRReader",
         ":MC",
         ":Passes",
@@ -4322,6 +4350,7 @@ cc_binary(
         ":BitWriter",
         ":CodeGen",
         ":Core",
+        ":IRPrinter",
         ":IRReader",
         ":Linker",
         ":Passes",
@@ -4415,6 +4444,7 @@ cc_binary(
     deps = [
         ":Core",
         ":Diff",
+        ":IRPrinter",
         ":IRReader",
         ":Support",
     ],
@@ -4438,6 +4468,7 @@ cc_binary(
         ":CodeGen",
         ":Core",
         ":FuzzMutate",
+        ":IRPrinter",
         ":IRReader",
         ":Support",
         ":Target",
@@ -4585,6 +4616,7 @@ cc_binary(
         ":BitReader",
         ":BitWriter",
         ":Core",
+        ":IRPrinter",
         ":IRReader",
         ":Support",
     ],

diff  --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
index f01bd66f25547..5b03c2e4d7129 100644
--- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
@@ -6521,6 +6521,7 @@ cc_library(
         ":Support",
         ":TranslateLib",
         "//llvm:Core",
+        "//llvm:IRPrinter",
         "//llvm:IRReader",
         "//llvm:Support",
     ],


        


More information about the llvm-commits mailing list