[llvm] [CodeGen] Split off PseudoSourceValueManager into separate header (NFC) (PR #73327)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 24 05:46:42 PST 2023


https://github.com/nikic created https://github.com/llvm/llvm-project/pull/73327

Most users of PseudoSourceValue.h only need PseudoSourceValue, not the PseudoSourceValueManager. However, this header pulls in some very expensive dependencies like ValueMap.h, which is only used for the manager.

Split off the manager into a separate header and include it only where used.

>From ae8318f99d33d72d885c736f387f044ee17ccc7b Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Fri, 24 Nov 2023 13:57:00 +0100
Subject: [PATCH] [CodeGen] Split off PseudoSourceValueManager into separate
 header (NFC)

Most users of PseudoSourceValue.h only need PseudoSourceValue,
not the PseudoSourceValueManager. However, this header pulls in
some very expensive dependenceis like ValueMap.h, which is only
used for the manager.

Split off the manager into a separate header and include it only
where used.
---
 llvm/include/llvm/CodeGen/PseudoSourceValue.h | 44 ------------
 .../llvm/CodeGen/PseudoSourceValueManager.h   | 68 +++++++++++++++++++
 llvm/lib/CodeGen/MIRParser/MIParser.cpp       |  1 +
 llvm/lib/CodeGen/MachineFunction.cpp          |  1 +
 llvm/lib/CodeGen/MachineOperand.cpp           |  1 +
 llvm/lib/CodeGen/PseudoSourceValue.cpp        |  1 +
 llvm/lib/CodeGen/StackColoring.cpp            |  1 +
 llvm/lib/CodeGen/StackSlotColoring.cpp        |  1 +
 llvm/lib/Target/Mips/MipsMachineFunction.cpp  |  1 +
 llvm/tools/llvm-reduce/ReducerWorkItem.cpp    |  1 +
 10 files changed, 76 insertions(+), 44 deletions(-)
 create mode 100644 llvm/include/llvm/CodeGen/PseudoSourceValueManager.h

diff --git a/llvm/include/llvm/CodeGen/PseudoSourceValue.h b/llvm/include/llvm/CodeGen/PseudoSourceValue.h
index 07b7ba32156698d..6f38ed97a53e855 100644
--- a/llvm/include/llvm/CodeGen/PseudoSourceValue.h
+++ b/llvm/include/llvm/CodeGen/PseudoSourceValue.h
@@ -13,10 +13,6 @@
 #ifndef LLVM_CODEGEN_PSEUDOSOURCEVALUE_H
 #define LLVM_CODEGEN_PSEUDOSOURCEVALUE_H
 
-#include "llvm/ADT/StringMap.h"
-#include "llvm/IR/ValueMap.h"
-#include <map>
-
 namespace llvm {
 
 class GlobalValue;
@@ -151,46 +147,6 @@ class ExternalSymbolPseudoSourceValue : public CallEntryPseudoSourceValue {
   const char *getSymbol() const { return ES; }
 };
 
-/// Manages creation of pseudo source values.
-class PseudoSourceValueManager {
-  const TargetMachine &TM;
-  const PseudoSourceValue StackPSV, GOTPSV, JumpTablePSV, ConstantPoolPSV;
-  std::map<int, std::unique_ptr<FixedStackPseudoSourceValue>> FSValues;
-  StringMap<std::unique_ptr<const ExternalSymbolPseudoSourceValue>>
-      ExternalCallEntries;
-  ValueMap<const GlobalValue *,
-           std::unique_ptr<const GlobalValuePseudoSourceValue>>
-      GlobalCallEntries;
-
-public:
-  PseudoSourceValueManager(const TargetMachine &TM);
-
-  /// Return a pseudo source value referencing the area below the stack frame of
-  /// a function, e.g., the argument space.
-  const PseudoSourceValue *getStack();
-
-  /// Return a pseudo source value referencing the global offset table
-  /// (or something the like).
-  const PseudoSourceValue *getGOT();
-
-  /// Return a pseudo source value referencing the constant pool. Since constant
-  /// pools are constant, this doesn't need to identify a specific constant
-  /// pool entry.
-  const PseudoSourceValue *getConstantPool();
-
-  /// Return a pseudo source value referencing a jump table. Since jump tables
-  /// are constant, this doesn't need to identify a specific jump table.
-  const PseudoSourceValue *getJumpTable();
-
-  /// Return a pseudo source value referencing a fixed stack frame entry,
-  /// e.g., a spill slot.
-  const PseudoSourceValue *getFixedStack(int FI);
-
-  const PseudoSourceValue *getGlobalValueCallEntry(const GlobalValue *GV);
-
-  const PseudoSourceValue *getExternalSymbolCallEntry(const char *ES);
-};
-
 } // end namespace llvm
 
 #endif
diff --git a/llvm/include/llvm/CodeGen/PseudoSourceValueManager.h b/llvm/include/llvm/CodeGen/PseudoSourceValueManager.h
new file mode 100644
index 000000000000000..4be6ae0b60cb8ec
--- /dev/null
+++ b/llvm/include/llvm/CodeGen/PseudoSourceValueManager.h
@@ -0,0 +1,68 @@
+//===-- llvm/CodeGen/PseudoSourceValueManager.h -----------------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains the declaration of the PseudoSourceValueManager class.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CODEGEN_PSEUDOSOURCEVALUEMANAGER_H
+#define LLVM_CODEGEN_PSEUDOSOURCEVALUEMANAGER_H
+
+#include "llvm/ADT/StringMap.h"
+#include "llvm/CodeGen/PseudoSourceValue.h"
+#include "llvm/IR/ValueMap.h"
+#include <map>
+
+namespace llvm {
+
+class GlobalValue;
+class TargetMachine;
+
+/// Manages creation of pseudo source values.
+class PseudoSourceValueManager {
+  const TargetMachine &TM;
+  const PseudoSourceValue StackPSV, GOTPSV, JumpTablePSV, ConstantPoolPSV;
+  std::map<int, std::unique_ptr<FixedStackPseudoSourceValue>> FSValues;
+  StringMap<std::unique_ptr<const ExternalSymbolPseudoSourceValue>>
+      ExternalCallEntries;
+  ValueMap<const GlobalValue *,
+           std::unique_ptr<const GlobalValuePseudoSourceValue>>
+      GlobalCallEntries;
+
+public:
+  PseudoSourceValueManager(const TargetMachine &TM);
+
+  /// Return a pseudo source value referencing the area below the stack frame of
+  /// a function, e.g., the argument space.
+  const PseudoSourceValue *getStack();
+
+  /// Return a pseudo source value referencing the global offset table
+  /// (or something the like).
+  const PseudoSourceValue *getGOT();
+
+  /// Return a pseudo source value referencing the constant pool. Since constant
+  /// pools are constant, this doesn't need to identify a specific constant
+  /// pool entry.
+  const PseudoSourceValue *getConstantPool();
+
+  /// Return a pseudo source value referencing a jump table. Since jump tables
+  /// are constant, this doesn't need to identify a specific jump table.
+  const PseudoSourceValue *getJumpTable();
+
+  /// Return a pseudo source value referencing a fixed stack frame entry,
+  /// e.g., a spill slot.
+  const PseudoSourceValue *getFixedStack(int FI);
+
+  const PseudoSourceValue *getGlobalValueCallEntry(const GlobalValue *GV);
+
+  const PseudoSourceValue *getExternalSymbolCallEntry(const char *ES);
+};
+
+} // end namespace llvm
+
+#endif
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index f5d80b2ae27c233..0f6a451be6b22c0 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -35,6 +35,7 @@
 #include "llvm/CodeGen/MachineMemOperand.h"
 #include "llvm/CodeGen/MachineOperand.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
+#include "llvm/CodeGen/PseudoSourceValueManager.h"
 #include "llvm/CodeGen/RegisterBank.h"
 #include "llvm/CodeGen/RegisterBankInfo.h"
 #include "llvm/CodeGen/TargetInstrInfo.h"
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index 07eb0ba7f45c2e3..57af571ed9bfd51 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -32,6 +32,7 @@
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/PseudoSourceValue.h"
+#include "llvm/CodeGen/PseudoSourceValueManager.h"
 #include "llvm/CodeGen/TargetFrameLowering.h"
 #include "llvm/CodeGen/TargetInstrInfo.h"
 #include "llvm/CodeGen/TargetLowering.h"
diff --git a/llvm/lib/CodeGen/MachineOperand.cpp b/llvm/lib/CodeGen/MachineOperand.cpp
index b6d6a7532d34074..12d6b79f735d7ea 100644
--- a/llvm/lib/CodeGen/MachineOperand.cpp
+++ b/llvm/lib/CodeGen/MachineOperand.cpp
@@ -18,6 +18,7 @@
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineJumpTableInfo.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
+#include "llvm/CodeGen/PseudoSourceValueManager.h"
 #include "llvm/CodeGen/TargetInstrInfo.h"
 #include "llvm/CodeGen/TargetRegisterInfo.h"
 #include "llvm/Config/llvm-config.h"
diff --git a/llvm/lib/CodeGen/PseudoSourceValue.cpp b/llvm/lib/CodeGen/PseudoSourceValue.cpp
index 40c52b9d9707654..089867f46d2aa1e 100644
--- a/llvm/lib/CodeGen/PseudoSourceValue.cpp
+++ b/llvm/lib/CodeGen/PseudoSourceValue.cpp
@@ -11,6 +11,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/CodeGen/PseudoSourceValue.h"
+#include "llvm/CodeGen/PseudoSourceValueManager.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
diff --git a/llvm/lib/CodeGen/StackColoring.cpp b/llvm/lib/CodeGen/StackColoring.cpp
index a06172ef99939fd..37f7aa9290054e3 100644
--- a/llvm/lib/CodeGen/StackColoring.cpp
+++ b/llvm/lib/CodeGen/StackColoring.cpp
@@ -36,6 +36,7 @@
 #include "llvm/CodeGen/MachineMemOperand.h"
 #include "llvm/CodeGen/MachineOperand.h"
 #include "llvm/CodeGen/Passes.h"
+#include "llvm/CodeGen/PseudoSourceValueManager.h"
 #include "llvm/CodeGen/SlotIndexes.h"
 #include "llvm/CodeGen/TargetOpcodes.h"
 #include "llvm/CodeGen/WinEHFuncInfo.h"
diff --git a/llvm/lib/CodeGen/StackSlotColoring.cpp b/llvm/lib/CodeGen/StackSlotColoring.cpp
index 16a1203262e5a31..c180f4d8f036550 100644
--- a/llvm/lib/CodeGen/StackSlotColoring.cpp
+++ b/llvm/lib/CodeGen/StackSlotColoring.cpp
@@ -27,6 +27,7 @@
 #include "llvm/CodeGen/MachineOperand.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/CodeGen/PseudoSourceValue.h"
+#include "llvm/CodeGen/PseudoSourceValueManager.h"
 #include "llvm/CodeGen/SlotIndexes.h"
 #include "llvm/CodeGen/TargetInstrInfo.h"
 #include "llvm/CodeGen/TargetSubtargetInfo.h"
diff --git a/llvm/lib/Target/Mips/MipsMachineFunction.cpp b/llvm/lib/Target/Mips/MipsMachineFunction.cpp
index 7d9824aaf8ec36c..194b467fb1d8bf5 100644
--- a/llvm/lib/Target/Mips/MipsMachineFunction.cpp
+++ b/llvm/lib/Target/Mips/MipsMachineFunction.cpp
@@ -13,6 +13,7 @@
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/PseudoSourceValue.h"
+#include "llvm/CodeGen/PseudoSourceValueManager.h"
 #include "llvm/CodeGen/TargetRegisterInfo.h"
 #include "llvm/Support/CommandLine.h"
 
diff --git a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
index f38d9b8a1d5f001..353216766717e34 100644
--- a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
+++ b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
@@ -22,6 +22,7 @@
 #include "llvm/CodeGen/MachineJumpTableInfo.h"
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
+#include "llvm/CodeGen/PseudoSourceValueManager.h"
 #include "llvm/CodeGen/TargetInstrInfo.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/Instructions.h"



More information about the llvm-commits mailing list