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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 4 00:25:19 PST 2023


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

>From 8a96d5632ac406769f2e1a621a84d0e3fc1d9f31 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 1/2] [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 07b7ba3215669..6f38ed97a53e8 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 0000000000000..4be6ae0b60cb8
--- /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 f300b05727f79..ede4291fe26dc 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 07eb0ba7f45c2..57af571ed9bfd 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 b6d6a7532d340..12d6b79f735d7 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 40c52b9d97076..089867f46d2aa 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 a06172ef99939..37f7aa9290054 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 16a1203262e5a..c180f4d8f0365 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 7d9824aaf8ec3..194b467fb1d8b 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 f38d9b8a1d5f0..353216766717e 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"

>From 73c282d0a3a52d765cb36f6112293afc9bc6321e Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Fri, 24 Nov 2023 17:22:20 +0100
Subject: [PATCH 2/2] Fix clang-format

---
 llvm/lib/CodeGen/PseudoSourceValue.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/CodeGen/PseudoSourceValue.cpp b/llvm/lib/CodeGen/PseudoSourceValue.cpp
index 089867f46d2aa..0e1a2c921c5cb 100644
--- a/llvm/lib/CodeGen/PseudoSourceValue.cpp
+++ b/llvm/lib/CodeGen/PseudoSourceValue.cpp
@@ -11,8 +11,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/CodeGen/PseudoSourceValue.h"
-#include "llvm/CodeGen/PseudoSourceValueManager.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/PseudoSourceValueManager.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetMachine.h"



More information about the llvm-commits mailing list