Skip to content

Overhaul the TargetMachine and LLVMTargetMachine Classes #111234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 14, 2024

Conversation

matinraayai
Copy link
Contributor

Following discussions in #110443, and the following earlier discussions in https://lists.llvm.org/pipermail/llvm-dev/2017-October/117907.html, https://reviews.llvm.org/D38482, https://reviews.llvm.org/D38489, this PR attempts to overhaul the TargetMachine and LLVMTargetMachine interface classes. More specifically:

  1. Makes TargetMachine the only class implemented under TargetMachine.h in the Target library.
  2. TargetMachine contains target-specific interface functions that relate to IR/CodeGen/MC constructs, whereas before (at least on paper) it was supposed to have only IR/MC constructs. Any Target that doesn't want to use the independent code generator simply does not implement them, and returns either false or nullptr.
  3. Renames LLVMTargetMachine to CodeGenCommonTMImpl. This renaming aims to make the purpose of LLVMTargetMachine clearer. Its interface was moved under the CodeGen library, to further emphasis its usage in Targets that use CodeGen directly.
  4. Makes TargetMachine the only interface used across LLVM and its projects. With these changes, CodeGenCommonTMImpl is simply a set of shared function implementations of TargetMachine, and CodeGen users don't need to static cast to LLVMTargetMachine every time they need a CodeGen-specific feature of the TargetMachine.
  5. More importantly, does not change any requirements regarding library linking.

cc @arsenm @aeubanks

@llvmbot
Copy link
Member

llvmbot commented Oct 5, 2024

@llvm/pr-subscribers-backend-powerpc
@llvm/pr-subscribers-backend-m68k
@llvm/pr-subscribers-offload
@llvm/pr-subscribers-backend-webassembly
@llvm/pr-subscribers-llvm-globalisel
@llvm/pr-subscribers-mc
@llvm/pr-subscribers-backend-nvptx
@llvm/pr-subscribers-backend-loongarch

@llvm/pr-subscribers-backend-arm

Author: Matin Raayai (matinraayai)

Changes

Following discussions in #110443, and the following earlier discussions in https://lists.llvm.org/pipermail/llvm-dev/2017-October/117907.html, https://reviews.llvm.org/D38482, https://reviews.llvm.org/D38489, this PR attempts to overhaul the TargetMachine and LLVMTargetMachine interface classes. More specifically:

  1. Makes TargetMachine the only class implemented under TargetMachine.h in the Target library.
  2. TargetMachine contains target-specific interface functions that relate to IR/CodeGen/MC constructs, whereas before (at least on paper) it was supposed to have only IR/MC constructs. Any Target that doesn't want to use the independent code generator simply does not implement them, and returns either false or nullptr.
  3. Renames LLVMTargetMachine to CodeGenCommonTMImpl. This renaming aims to make the purpose of LLVMTargetMachine clearer. Its interface was moved under the CodeGen library, to further emphasis its usage in Targets that use CodeGen directly.
  4. Makes TargetMachine the only interface used across LLVM and its projects. With these changes, CodeGenCommonTMImpl is simply a set of shared function implementations of TargetMachine, and CodeGen users don't need to static cast to LLVMTargetMachine every time they need a CodeGen-specific feature of the TargetMachine.
  5. More importantly, does not change any requirements regarding library linking.

cc @arsenm @aeubanks


Patch is 147.27 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/111234.diff

120 Files Affected:

  • (modified) llvm/docs/WritingAnLLVMBackend.rst (+9-9)
  • (added) llvm/include/llvm/CodeGen/CodeGenCommonTMImpl.h (+92)
  • (modified) llvm/include/llvm/CodeGen/MachineFunction.h (+4-4)
  • (modified) llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h (+3-3)
  • (modified) llvm/include/llvm/CodeGen/MachineModuleInfo.h (+7-8)
  • (modified) llvm/include/llvm/CodeGen/RegisterUsageInfo.h (+3-3)
  • (modified) llvm/include/llvm/CodeGen/ScheduleDAG.h (+2-2)
  • (modified) llvm/include/llvm/CodeGen/TargetPassConfig.h (+5-5)
  • (modified) llvm/include/llvm/Passes/CodeGenPassBuilder.h (+1-1)
  • (modified) llvm/include/llvm/Target/TargetMachine.h (+19-71)
  • (modified) llvm/lib/CodeGen/CMakeLists.txt (+1-1)
  • (renamed) llvm/lib/CodeGen/CodeGenCommonTMImpl.cpp (+23-24)
  • (modified) llvm/lib/CodeGen/MIRParser/MIRParser.cpp (+3-3)
  • (modified) llvm/lib/CodeGen/MachineFunction.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/MachineModuleInfo.cpp (+4-4)
  • (modified) llvm/lib/CodeGen/RegUsageInfoCollector.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/RegisterUsageInfo.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/ResetMachineFunctionPass.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/TargetPassConfig.cpp (+6-4)
  • (modified) llvm/lib/Passes/PassRegistry.def (+1-3)
  • (modified) llvm/lib/Target/AArch64/AArch64TargetMachine.cpp (+5-5)
  • (modified) llvm/lib/Target/AArch64/AArch64TargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp (+6-5)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h (+3-3)
  • (modified) llvm/lib/Target/AMDGPU/R600TargetMachine.cpp (+1-1)
  • (modified) llvm/lib/Target/ARC/ARCTargetMachine.cpp (+5-5)
  • (modified) llvm/lib/Target/ARC/ARCTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/ARM/ARMTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/ARM/ARMTargetMachine.h (+2-1)
  • (modified) llvm/lib/Target/AVR/AVRTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/AVR/AVRTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/BPF/BPFTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/BPF/BPFTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/CSKY/CSKYTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/CSKY/CSKYTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/DirectX/DirectXTargetMachine.cpp (+5-5)
  • (modified) llvm/lib/Target/DirectX/DirectXTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp (+1-1)
  • (modified) llvm/lib/Target/Hexagon/HexagonTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/Lanai/LanaiTargetMachine.cpp (+4-4)
  • (modified) llvm/lib/Target/Lanai/LanaiTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/LoongArch/LoongArchTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/M68k/M68kTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/M68k/M68kTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/MSP430/MSP430TargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/MSP430/MSP430TargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp (+2-2)
  • (modified) llvm/lib/Target/Mips/MipsTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/Mips/MipsTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp (+1-1)
  • (modified) llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/NVPTX/NVPTXTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/PowerPC/PPCTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/PowerPC/PPCTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/RISCV/RISCVTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/RISCV/RISCVTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/SPIRV/SPIRVAPI.cpp (+2-3)
  • (modified) llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/SPIRV/SPIRVTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/Sparc/SparcTargetMachine.cpp (+5-5)
  • (modified) llvm/lib/Target/Sparc/SparcTargetMachine.h (+2-1)
  • (modified) llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp (+1-1)
  • (modified) llvm/lib/Target/SystemZ/SystemZTargetMachine.h (+2-1)
  • (modified) llvm/lib/Target/VE/VETargetMachine.cpp (+1-1)
  • (modified) llvm/lib/Target/VE/VETargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp (+3-3)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp (+1-1)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/X86/X86TargetMachine.cpp (+3-5)
  • (modified) llvm/lib/Target/X86/X86TargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/XCore/XCoreTargetMachine.cpp (+1-1)
  • (modified) llvm/lib/Target/XCore/XCoreTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/Xtensa/XtensaTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/Xtensa/XtensaTargetMachine.h (+2-2)
  • (modified) llvm/tools/llc/NewPMDriver.cpp (+3-5)
  • (modified) llvm/tools/llc/llc.cpp (+3-4)
  • (modified) llvm/tools/llvm-exegesis/lib/Assembler.cpp (+3-5)
  • (modified) llvm/tools/llvm-exegesis/lib/Assembler.h (+2-2)
  • (modified) llvm/tools/llvm-exegesis/lib/LlvmState.cpp (+5-6)
  • (modified) llvm/tools/llvm-exegesis/lib/LlvmState.h (+1-1)
  • (modified) llvm/tools/llvm-reduce/ReducerWorkItem.cpp (+2-5)
  • (modified) llvm/tools/opt/optdriver.cpp (+5-3)
  • (modified) llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp (+3-3)
  • (modified) llvm/unittests/CodeGen/AMDGPUMetadataTest.cpp (+3-4)
  • (modified) llvm/unittests/CodeGen/AsmPrinterDwarfTest.cpp (+6-6)
  • (modified) llvm/unittests/CodeGen/CCStateTest.cpp (+1-1)
  • (modified) llvm/unittests/CodeGen/GlobalISel/GISelMITest.cpp (+7-9)
  • (modified) llvm/unittests/CodeGen/GlobalISel/GISelMITest.h (+6-6)
  • (modified) llvm/unittests/CodeGen/InstrRefLDVTest.cpp (+4-4)
  • (modified) llvm/unittests/CodeGen/LexicalScopesTest.cpp (+1-1)
  • (modified) llvm/unittests/CodeGen/MFCommon.inc (+4-4)
  • (modified) llvm/unittests/CodeGen/MLRegAllocDevelopmentFeatures.cpp (+1-1)
  • (modified) llvm/unittests/CodeGen/MachineBasicBlockTest.cpp (+1-1)
  • (modified) llvm/unittests/CodeGen/MachineDomTreeUpdaterTest.cpp (+1-2)
  • (modified) llvm/unittests/CodeGen/MachineInstrTest.cpp (+1-1)
  • (modified) llvm/unittests/CodeGen/MachineOperandTest.cpp (+1-1)
  • (modified) llvm/unittests/CodeGen/PassManagerTest.cpp (+2-4)
  • (modified) llvm/unittests/CodeGen/RegAllocScoreTest.cpp (+1-1)
  • (modified) llvm/unittests/CodeGen/SelectionDAGAddressAnalysisTest.cpp (+3-3)
  • (modified) llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp (+4-5)
  • (modified) llvm/unittests/CodeGen/TargetOptionsTest.cpp (+1-2)
  • (modified) llvm/unittests/MC/AMDGPU/DwarfRegMappings.cpp (+3-4)
  • (modified) llvm/unittests/MI/LiveIntervalTest.cpp (+5-5)
  • (modified) llvm/unittests/MIR/MachineMetadata.cpp (+3-4)
  • (modified) llvm/unittests/MIR/MachineStableHashTest.cpp (+3-4)
  • (modified) llvm/unittests/Target/AArch64/AArch64SVESchedPseudoTest.cpp (+4-4)
  • (modified) llvm/unittests/Target/AArch64/InstSizes.cpp (+15-15)
  • (modified) llvm/unittests/Target/AArch64/MatrixRegisterAliasing.cpp (+4-4)
  • (modified) llvm/unittests/Target/ARM/InstSizes.cpp (+3-3)
  • (modified) llvm/unittests/Target/ARM/MachineInstrTest.cpp (+12-12)
  • (modified) llvm/unittests/Target/LoongArch/InstSizes.cpp (+8-8)
  • (modified) llvm/unittests/Target/VE/MachineInstrTest.cpp (+2-3)
  • (modified) llvm/unittests/Target/WebAssembly/WebAssemblyExceptionInfoTest.cpp (+5-5)
  • (modified) llvm/unittests/Target/X86/MachineSizeOptsTest.cpp (+4-4)
  • (modified) llvm/unittests/Target/X86/TernlogTest.cpp (+3-3)
  • (modified) llvm/unittests/tools/llvm-exegesis/Common/AssemblerUtils.h (+2-3)
  • (modified) llvm/unittests/tools/llvm-exegesis/X86/SnippetRepetitorTest.cpp (+1-1)
  • (modified) llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn (+1-1)
  • (modified) offload/plugins-nextgen/common/src/JIT.cpp (+1-2)
diff --git a/llvm/docs/WritingAnLLVMBackend.rst b/llvm/docs/WritingAnLLVMBackend.rst
index f1f07e4681d509..ae4f635bc5ef87 100644
--- a/llvm/docs/WritingAnLLVMBackend.rst
+++ b/llvm/docs/WritingAnLLVMBackend.rst
@@ -152,7 +152,7 @@ To make your target actually do something, you need to implement a subclass of
 ``lib/Target/DummyTargetMachine.cpp``, but any file in the ``lib/Target``
 directory will be built and should work.  To use LLVM's target independent code
 generator, you should do what all current machine backends do: create a
-subclass of ``LLVMTargetMachine``.  (To create a target from scratch, create a
+subclass of ``CodeGenCommonTMImpl``.  (To create a target from scratch, create a
 subclass of ``TargetMachine``.)
 
 To get LLVM to actually build and link your target, you need to run ``cmake``
@@ -165,15 +165,15 @@ located in the main ``CMakeLists.txt``.
 Target Machine
 ==============
 
-``LLVMTargetMachine`` is designed as a base class for targets implemented with
-the LLVM target-independent code generator.  The ``LLVMTargetMachine`` class
+``CodeGenCommonTMImpl`` is designed as a base class for targets implemented with
+the LLVM target-independent code generator.  The ``CodeGenCommonTMImpl`` class
 should be specialized by a concrete target class that implements the various
-virtual methods.  ``LLVMTargetMachine`` is defined as a subclass of
-``TargetMachine`` in ``include/llvm/Target/TargetMachine.h``.  The
-``TargetMachine`` class implementation (``TargetMachine.cpp``) also processes
-numerous command-line options.
+virtual methods.  ``CodeGenCommonTMImpl`` is defined as a subclass of
+``TargetMachine`` in ``include/llvm/CodeGen/CodeGenCommonTMImpl.h``.  The
+``TargetMachine`` class implementation (``include/llvm/Target/TargetMachine.cpp``)
+also processes numerous command-line options.
 
-To create a concrete target-specific subclass of ``LLVMTargetMachine``, start
+To create a concrete target-specific subclass of ``CodeGenCommonTMImpl``, start
 by copying an existing ``TargetMachine`` class and header.  You should name the
 files that you create to reflect your specific target.  For instance, for the
 SPARC target, name the files ``SparcTargetMachine.h`` and
@@ -197,7 +197,7 @@ simply return a class member.
 
   class Module;
 
-  class SparcTargetMachine : public LLVMTargetMachine {
+  class SparcTargetMachine : public CodeGenCommonTMImpl {
     const DataLayout DataLayout;       // Calculates type size & alignment
     SparcSubtarget Subtarget;
     SparcInstrInfo InstrInfo;
diff --git a/llvm/include/llvm/CodeGen/CodeGenCommonTMImpl.h b/llvm/include/llvm/CodeGen/CodeGenCommonTMImpl.h
new file mode 100644
index 00000000000000..92bfc8f4f96d29
--- /dev/null
+++ b/llvm/include/llvm/CodeGen/CodeGenCommonTMImpl.h
@@ -0,0 +1,92 @@
+//===-- CodeGenCommonTMImpl.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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file This file describes the CodeGenCommonTMImpl class, which
+/// implements a set of functionality used by \c TargetMachine classes in
+/// LLVM that make use of the target-independent code generator.
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_CODEGEN_CODEGENCOMMONTMIMPL_H
+#define LLVM_CODEGEN_CODEGENCOMMONTMIMPL_H
+#include "llvm/Target/TargetMachine.h"
+
+namespace llvm {
+
+/// \brief implements a set of functionality in the \c TargetMachine class
+/// for targets that make use of the independent code generator (CodeGen)
+/// library. Must not be used directly in code unless to inherit its
+/// implementation.
+class CodeGenCommonTMImpl : public TargetMachine {
+protected: // Can only create subclasses.
+  CodeGenCommonTMImpl(const Target &T, StringRef DataLayoutString,
+                      const Triple &TT, StringRef CPU, StringRef FS,
+                      const TargetOptions &Options, Reloc::Model RM,
+                      CodeModel::Model CM, CodeGenOptLevel OL);
+
+  void initAsmInfo();
+
+public:
+  /// Get a TargetTransformInfo implementation for the target.
+  ///
+  /// The TTI returned uses the common code generator to answer queries about
+  /// the IR.
+  TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
+
+  /// Create a pass configuration object to be used by addPassToEmitX methods
+  /// for generating a pipeline of CodeGen passes.
+  virtual TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
+
+  /// Add passes to the specified pass manager to get the specified file
+  /// emitted.  Typically this will involve several steps of code generation.
+  /// \p MMIWP is an optional parameter that, if set to non-nullptr,
+  /// will be used to set the MachineModuloInfo for this PM.
+  bool
+  addPassesToEmitFile(PassManagerBase &PM, raw_pwrite_stream &Out,
+                      raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+                      bool DisableVerify = true,
+                      MachineModuleInfoWrapperPass *MMIWP = nullptr) override;
+
+  /// Add passes to the specified pass manager to get machine code emitted with
+  /// the MCJIT. This method returns true if machine code is not supported. It
+  /// fills the MCContext Ctx pointer which can be used to build custom
+  /// MCStreamer.
+  bool addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx,
+                         raw_pwrite_stream &Out,
+                         bool DisableVerify = true) override;
+
+  /// Adds an AsmPrinter pass to the pipeline that prints assembly or
+  /// machine code from the MI representation.
+  bool addAsmPrinter(PassManagerBase &PM, raw_pwrite_stream &Out,
+                     raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+                     MCContext &Context) override;
+
+  Expected<std::unique_ptr<MCStreamer>>
+  createMCStreamer(raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut,
+                   CodeGenFileType FileType, MCContext &Ctx) override;
+};
+
+/// Helper method for getting the code model, returning Default if
+/// CM does not have a value. The tiny and kernel models will produce
+/// an error, so targets that support them or require more complex codemodel
+/// selection logic should implement and call their own getEffectiveCodeModel.
+inline CodeModel::Model
+getEffectiveCodeModel(std::optional<CodeModel::Model> CM,
+                      CodeModel::Model Default) {
+  if (CM) {
+    // By default, targets do not support the tiny and kernel models.
+    if (*CM == CodeModel::Tiny)
+      report_fatal_error("Target does not support the tiny CodeModel", false);
+    if (*CM == CodeModel::Kernel)
+      report_fatal_error("Target does not support the kernel CodeModel", false);
+    return *CM;
+  }
+  return Default;
+}
+
+} // namespace llvm
+
+#endif
\ No newline at end of file
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index 053e7062fb4995..5a2b4881cfca2d 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -54,7 +54,7 @@ class DILocation;
 class Function;
 class GISelChangeObserver;
 class GlobalValue;
-class LLVMTargetMachine;
+class TargetMachine;
 class MachineConstantPool;
 class MachineFrameInfo;
 class MachineFunction;
@@ -256,7 +256,7 @@ struct LandingPadInfo {
 
 class LLVM_ABI MachineFunction {
   Function &F;
-  const LLVMTargetMachine &Target;
+  const TargetMachine &Target;
   const TargetSubtargetInfo *STI;
   MCContext &Ctx;
 
@@ -634,7 +634,7 @@ class LLVM_ABI MachineFunction {
   /// for instructions that have a stack spill fused into them.
   const static unsigned int DebugOperandMemNumber;
 
-  MachineFunction(Function &F, const LLVMTargetMachine &Target,
+  MachineFunction(Function &F, const TargetMachine &Target,
                   const TargetSubtargetInfo &STI, MCContext &Ctx,
                   unsigned FunctionNum);
   MachineFunction(const MachineFunction &) = delete;
@@ -707,7 +707,7 @@ class LLVM_ABI MachineFunction {
   void assignBeginEndSections();
 
   /// getTarget - Return the target machine this machine code is compiled with
-  const LLVMTargetMachine &getTarget() const { return Target; }
+  const TargetMachine &getTarget() const { return Target; }
 
   /// getSubtarget - Return the subtarget for which this machine code is being
   /// compiled.
diff --git a/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h b/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
index f54d455292da03..e194f4838e118c 100644
--- a/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
+++ b/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
@@ -18,7 +18,7 @@
 namespace llvm {
 
 class MachineFunction;
-class LLVMTargetMachine;
+class TargetMachine;
 
 /// This analysis create MachineFunction for given Function.
 /// To release the MachineFunction, users should invalidate it explicitly.
@@ -28,7 +28,7 @@ class MachineFunctionAnalysis
 
   static AnalysisKey Key;
 
-  const LLVMTargetMachine *TM;
+  const TargetMachine *TM;
 
 public:
   class Result {
@@ -41,7 +41,7 @@ class MachineFunctionAnalysis
                     FunctionAnalysisManager::Invalidator &);
   };
 
-  MachineFunctionAnalysis(const LLVMTargetMachine *TM) : TM(TM){};
+  MachineFunctionAnalysis(const TargetMachine *TM) : TM(TM) {};
   Result run(Function &F, FunctionAnalysisManager &FAM);
 };
 
diff --git a/llvm/include/llvm/CodeGen/MachineModuleInfo.h b/llvm/include/llvm/CodeGen/MachineModuleInfo.h
index 310cc4b2abb772..bec500dc609f32 100644
--- a/llvm/include/llvm/CodeGen/MachineModuleInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineModuleInfo.h
@@ -43,7 +43,7 @@
 namespace llvm {
 
 class Function;
-class LLVMTargetMachine;
+class TargetMachine;
 class MachineFunction;
 class Module;
 
@@ -83,7 +83,7 @@ class MachineModuleInfo {
   friend class MachineModuleInfoWrapperPass;
   friend class MachineModuleAnalysis;
 
-  const LLVMTargetMachine &TM;
+  const TargetMachine &TM;
 
   /// This is the MCContext used for the entire code generator.
   MCContext Context;
@@ -109,10 +109,9 @@ class MachineModuleInfo {
   MachineModuleInfo &operator=(MachineModuleInfo &&MMII) = delete;
 
 public:
-  explicit MachineModuleInfo(const LLVMTargetMachine *TM = nullptr);
+  explicit MachineModuleInfo(const TargetMachine *TM = nullptr);
 
-  explicit MachineModuleInfo(const LLVMTargetMachine *TM,
-                             MCContext *ExtContext);
+  explicit MachineModuleInfo(const TargetMachine *TM, MCContext *ExtContext);
 
   MachineModuleInfo(MachineModuleInfo &&MMII);
 
@@ -121,7 +120,7 @@ class MachineModuleInfo {
   void initialize();
   void finalize();
 
-  const LLVMTargetMachine &getTarget() const { return TM; }
+  const TargetMachine &getTarget() const { return TM; }
 
   const MCContext &getContext() const {
     return ExternalContext ? *ExternalContext : Context;
@@ -173,9 +172,9 @@ class MachineModuleInfoWrapperPass : public ImmutablePass {
 
 public:
   static char ID; // Pass identification, replacement for typeid
-  explicit MachineModuleInfoWrapperPass(const LLVMTargetMachine *TM = nullptr);
+  explicit MachineModuleInfoWrapperPass(const TargetMachine *TM = nullptr);
 
-  explicit MachineModuleInfoWrapperPass(const LLVMTargetMachine *TM,
+  explicit MachineModuleInfoWrapperPass(const TargetMachine *TM,
                                         MCContext *ExtContext);
 
   // Initialization and Finalization
diff --git a/llvm/include/llvm/CodeGen/RegisterUsageInfo.h b/llvm/include/llvm/CodeGen/RegisterUsageInfo.h
index aa1f5ef8110b0c..845ed09a852ad9 100644
--- a/llvm/include/llvm/CodeGen/RegisterUsageInfo.h
+++ b/llvm/include/llvm/CodeGen/RegisterUsageInfo.h
@@ -29,7 +29,7 @@
 namespace llvm {
 
 class Function;
-class LLVMTargetMachine;
+class TargetMachine;
 
 class PhysicalRegisterUsageInfo : public ImmutablePass {
 public:
@@ -41,7 +41,7 @@ class PhysicalRegisterUsageInfo : public ImmutablePass {
   }
 
   /// Set TargetMachine which is used to print analysis.
-  void setTargetMachine(const LLVMTargetMachine &TM);
+  void setTargetMachine(const TargetMachine &TM);
 
   bool doInitialization(Module &M) override;
 
@@ -63,7 +63,7 @@ class PhysicalRegisterUsageInfo : public ImmutablePass {
   /// and 1 means content of register will be preserved around function call.
   DenseMap<const Function *, std::vector<uint32_t>> RegMasks;
 
-  const LLVMTargetMachine *TM = nullptr;
+  const TargetMachine *TM = nullptr;
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/CodeGen/ScheduleDAG.h b/llvm/include/llvm/CodeGen/ScheduleDAG.h
index 53265b286c7c87..54e65335edf3a2 100644
--- a/llvm/include/llvm/CodeGen/ScheduleDAG.h
+++ b/llvm/include/llvm/CodeGen/ScheduleDAG.h
@@ -32,7 +32,7 @@ namespace llvm {
 
 template <class GraphType> struct GraphTraits;
 template<class Graph> class GraphWriter;
-class LLVMTargetMachine;
+class TargetMachine;
 class MachineFunction;
 class MachineRegisterInfo;
 class MCInstrDesc;
@@ -571,7 +571,7 @@ class TargetRegisterInfo;
 
   class ScheduleDAG {
   public:
-    const LLVMTargetMachine &TM;        ///< Target processor
+    const TargetMachine &TM;            ///< Target processor
     const TargetInstrInfo *TII;         ///< Target instruction information
     const TargetRegisterInfo *TRI;      ///< Target processor register info
     MachineFunction &MF;                ///< Machine function
diff --git a/llvm/include/llvm/CodeGen/TargetPassConfig.h b/llvm/include/llvm/CodeGen/TargetPassConfig.h
index 2f5951e3ec3bce..85f87de521855f 100644
--- a/llvm/include/llvm/CodeGen/TargetPassConfig.h
+++ b/llvm/include/llvm/CodeGen/TargetPassConfig.h
@@ -21,7 +21,7 @@
 
 namespace llvm {
 
-class LLVMTargetMachine;
+class TargetMachine;
 struct MachineSchedContext;
 class PassConfigImpl;
 class ScheduleDAGInstrs;
@@ -120,7 +120,7 @@ class TargetPassConfig : public ImmutablePass {
   void setStartStopPasses();
 
 protected:
-  LLVMTargetMachine *TM;
+  TargetMachine *TM;
   PassConfigImpl *Impl = nullptr; // Internal data structures
   bool Initialized = false; // Flagged after all passes are configured.
 
@@ -148,7 +148,7 @@ class TargetPassConfig : public ImmutablePass {
   bool addCoreISelPasses();
 
 public:
-  TargetPassConfig(LLVMTargetMachine &TM, PassManagerBase &pm);
+  TargetPassConfig(TargetMachine &TM, PassManagerBase &PM);
   // Dummy constructor.
   TargetPassConfig();
 
@@ -413,7 +413,7 @@ class TargetPassConfig : public ImmutablePass {
   virtual void addFastRegAlloc();
 
   /// addOptimizedRegAlloc - Add passes related to register allocation.
-  /// LLVMTargetMachine provides standard regalloc passes for most targets.
+  /// CodeGenCommonTMImpl provides standard regalloc passes for most targets.
   virtual void addOptimizedRegAlloc();
 
   /// addPreRewrite - Add passes to the optimized register allocation pipeline
@@ -497,7 +497,7 @@ class TargetPassConfig : public ImmutablePass {
 };
 
 void registerCodeGenCallback(PassInstrumentationCallbacks &PIC,
-                             LLVMTargetMachine &);
+                             TargetMachine &);
 
 } // end namespace llvm
 
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index 13bc4700d87029..08629d656552d7 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -438,7 +438,7 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
   Error addFastRegAlloc(AddMachinePass &) const;
 
   /// addOptimizedRegAlloc - Add passes related to register allocation.
-  /// LLVMTargetMachine provides standard regalloc passes for most targets.
+  /// CodeGenCommonTMImpl provides standard regalloc passes for most targets.
   void addOptimizedRegAlloc(AddMachinePass &) const;
 
   /// Add passes that optimize machine instructions after register allocation.
diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h
index c3e9d41315f617..9bdb110bd36839 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -5,9 +5,9 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// This file defines the TargetMachine and LLVMTargetMachine classes.
-//
+///
+/// This file defines the TargetMachine class.
+///
 //===----------------------------------------------------------------------===//
 
 #ifndef LLVM_TARGET_TARGETMACHINE_H
@@ -16,6 +16,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/MC/MCStreamer.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Error.h"
@@ -40,7 +41,6 @@ class MCAsmInfo;
 class MCContext;
 class MCInstrInfo;
 class MCRegisterInfo;
-class MCStreamer;
 class MCSubtargetInfo;
 class MCSymbol;
 class raw_pwrite_stream;
@@ -60,13 +60,13 @@ class TargetSubtargetInfo;
 // The old pass manager infrastructure is hidden in a legacy namespace now.
 namespace legacy {
 class PassManagerBase;
-}
+} // namespace legacy
 using legacy::PassManagerBase;
 
 struct MachineFunctionInfo;
 namespace yaml {
 struct MachineFunctionInfo;
-}
+} // namespace yaml
 
 //===----------------------------------------------------------------------===//
 ///
@@ -434,40 +434,12 @@ class TargetMachine {
       function_ref<void(std::unique_ptr<Module> MPart)> ModuleCallback) {
     return false;
   }
-};
-
-/// This class describes a target machine that is implemented with the LLVM
-/// target-independent code generator.
-///
-class LLVMTargetMachine : public TargetMachine {
-protected: // Can only create subclasses.
-  LLVMTargetMachine(const Target &T, StringRef DataLayoutString,
-                    const Triple &TT, StringRef CPU, StringRef FS,
-                    const TargetOptions &Options, Reloc::Model RM,
-                    CodeModel::Model CM, CodeGenOptLevel OL);
-
-  void initAsmInfo();
-
-public:
-  /// Get a TargetTransformInfo implementation for the target.
-  ///
-  /// The TTI returned uses the common code generator to answer queries about
-  /// the IR.
-  TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
 
   /// Create a pass configuration object to be used by addPassToEmitX methods
   /// for generating a pipeline of CodeGen passes.
-  virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
-
-  /// Add passes to the specified pass manager to get the specified file
-  /// emitted.  Typically this will involve several steps of code generation.
-  /// \p MMIWP is an optional parameter that, if set to non-nullptr,
-  /// will be used to set the MachineModuloInfo for this PM.
-  bool
-  addPassesToEmitFile(PassManagerBase &PM, raw_pwrite_stream &Out,
-                      raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
-                      bool DisableVerify = true,
-                      MachineModuleInfoWrapperPass *MMIWP = nullptr) override;
+  virtual TargetPassConfig *createPassConfig(PassManagerBase &PM) {
+    return nullptr;
+  }
 
   virtual Error buildCodeGenPipeline(ModulePassManager &, raw_pwrite_stream &,
                                      raw_pwrite_stream *, CodeGenFileType,
@@ -477,14 +449,6 @@ class LLVMTargetMachine : public TargetMachine {
                                    inconvertibleErrorCode());
   }
 
-  /// Add passes to the specified pass manager to get machine code emitted with
-  /// the MCJIT. This method returns true if machine code is not supported. It
-  /// fills the MCContext Ctx pointer which can be used to build custom
-  /// MCStreamer.
-  bool addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx,
-                         raw_pwrite_stream &Out,
-                         bool DisableVerify = true) override;
-
   /// Returns true if the target is expected to pass all machine verifier
   /// checks. This is a stopgap measure to fix targets one by one. We will
   /// remove this at some point and always enable the verifier when
@@ -493,13 +457,17 @@ class LLVMTargetMachine : public TargetMachine {
 
   /// Adds an AsmPrinter pa...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Oct 5, 2024

@llvm/pr-subscribers-backend-aarch64

Author: Matin Raayai (matinraayai)

Changes

Following discussions in #110443, and the following earlier discussions in https://lists.llvm.org/pipermail/llvm-dev/2017-October/117907.html, https://reviews.llvm.org/D38482, https://reviews.llvm.org/D38489, this PR attempts to overhaul the TargetMachine and LLVMTargetMachine interface classes. More specifically:

  1. Makes TargetMachine the only class implemented under TargetMachine.h in the Target library.
  2. TargetMachine contains target-specific interface functions that relate to IR/CodeGen/MC constructs, whereas before (at least on paper) it was supposed to have only IR/MC constructs. Any Target that doesn't want to use the independent code generator simply does not implement them, and returns either false or nullptr.
  3. Renames LLVMTargetMachine to CodeGenCommonTMImpl. This renaming aims to make the purpose of LLVMTargetMachine clearer. Its interface was moved under the CodeGen library, to further emphasis its usage in Targets that use CodeGen directly.
  4. Makes TargetMachine the only interface used across LLVM and its projects. With these changes, CodeGenCommonTMImpl is simply a set of shared function implementations of TargetMachine, and CodeGen users don't need to static cast to LLVMTargetMachine every time they need a CodeGen-specific feature of the TargetMachine.
  5. More importantly, does not change any requirements regarding library linking.

cc @arsenm @aeubanks


Patch is 147.27 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/111234.diff

120 Files Affected:

  • (modified) llvm/docs/WritingAnLLVMBackend.rst (+9-9)
  • (added) llvm/include/llvm/CodeGen/CodeGenCommonTMImpl.h (+92)
  • (modified) llvm/include/llvm/CodeGen/MachineFunction.h (+4-4)
  • (modified) llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h (+3-3)
  • (modified) llvm/include/llvm/CodeGen/MachineModuleInfo.h (+7-8)
  • (modified) llvm/include/llvm/CodeGen/RegisterUsageInfo.h (+3-3)
  • (modified) llvm/include/llvm/CodeGen/ScheduleDAG.h (+2-2)
  • (modified) llvm/include/llvm/CodeGen/TargetPassConfig.h (+5-5)
  • (modified) llvm/include/llvm/Passes/CodeGenPassBuilder.h (+1-1)
  • (modified) llvm/include/llvm/Target/TargetMachine.h (+19-71)
  • (modified) llvm/lib/CodeGen/CMakeLists.txt (+1-1)
  • (renamed) llvm/lib/CodeGen/CodeGenCommonTMImpl.cpp (+23-24)
  • (modified) llvm/lib/CodeGen/MIRParser/MIRParser.cpp (+3-3)
  • (modified) llvm/lib/CodeGen/MachineFunction.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/MachineModuleInfo.cpp (+4-4)
  • (modified) llvm/lib/CodeGen/RegUsageInfoCollector.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/RegisterUsageInfo.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/ResetMachineFunctionPass.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/TargetPassConfig.cpp (+6-4)
  • (modified) llvm/lib/Passes/PassRegistry.def (+1-3)
  • (modified) llvm/lib/Target/AArch64/AArch64TargetMachine.cpp (+5-5)
  • (modified) llvm/lib/Target/AArch64/AArch64TargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp (+6-5)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h (+3-3)
  • (modified) llvm/lib/Target/AMDGPU/R600TargetMachine.cpp (+1-1)
  • (modified) llvm/lib/Target/ARC/ARCTargetMachine.cpp (+5-5)
  • (modified) llvm/lib/Target/ARC/ARCTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/ARM/ARMTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/ARM/ARMTargetMachine.h (+2-1)
  • (modified) llvm/lib/Target/AVR/AVRTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/AVR/AVRTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/BPF/BPFTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/BPF/BPFTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/CSKY/CSKYTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/CSKY/CSKYTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/DirectX/DirectXTargetMachine.cpp (+5-5)
  • (modified) llvm/lib/Target/DirectX/DirectXTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp (+1-1)
  • (modified) llvm/lib/Target/Hexagon/HexagonTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/Lanai/LanaiTargetMachine.cpp (+4-4)
  • (modified) llvm/lib/Target/Lanai/LanaiTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/LoongArch/LoongArchTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/M68k/M68kTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/M68k/M68kTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/MSP430/MSP430TargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/MSP430/MSP430TargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp (+2-2)
  • (modified) llvm/lib/Target/Mips/MipsTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/Mips/MipsTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp (+1-1)
  • (modified) llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/NVPTX/NVPTXTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/PowerPC/PPCTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/PowerPC/PPCTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/RISCV/RISCVTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/RISCV/RISCVTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/SPIRV/SPIRVAPI.cpp (+2-3)
  • (modified) llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/SPIRV/SPIRVTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/Sparc/SparcTargetMachine.cpp (+5-5)
  • (modified) llvm/lib/Target/Sparc/SparcTargetMachine.h (+2-1)
  • (modified) llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp (+1-1)
  • (modified) llvm/lib/Target/SystemZ/SystemZTargetMachine.h (+2-1)
  • (modified) llvm/lib/Target/VE/VETargetMachine.cpp (+1-1)
  • (modified) llvm/lib/Target/VE/VETargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp (+3-3)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp (+1-1)
  • (modified) llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/X86/X86TargetMachine.cpp (+3-5)
  • (modified) llvm/lib/Target/X86/X86TargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/XCore/XCoreTargetMachine.cpp (+1-1)
  • (modified) llvm/lib/Target/XCore/XCoreTargetMachine.h (+2-2)
  • (modified) llvm/lib/Target/Xtensa/XtensaTargetMachine.cpp (+3-3)
  • (modified) llvm/lib/Target/Xtensa/XtensaTargetMachine.h (+2-2)
  • (modified) llvm/tools/llc/NewPMDriver.cpp (+3-5)
  • (modified) llvm/tools/llc/llc.cpp (+3-4)
  • (modified) llvm/tools/llvm-exegesis/lib/Assembler.cpp (+3-5)
  • (modified) llvm/tools/llvm-exegesis/lib/Assembler.h (+2-2)
  • (modified) llvm/tools/llvm-exegesis/lib/LlvmState.cpp (+5-6)
  • (modified) llvm/tools/llvm-exegesis/lib/LlvmState.h (+1-1)
  • (modified) llvm/tools/llvm-reduce/ReducerWorkItem.cpp (+2-5)
  • (modified) llvm/tools/opt/optdriver.cpp (+5-3)
  • (modified) llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp (+3-3)
  • (modified) llvm/unittests/CodeGen/AMDGPUMetadataTest.cpp (+3-4)
  • (modified) llvm/unittests/CodeGen/AsmPrinterDwarfTest.cpp (+6-6)
  • (modified) llvm/unittests/CodeGen/CCStateTest.cpp (+1-1)
  • (modified) llvm/unittests/CodeGen/GlobalISel/GISelMITest.cpp (+7-9)
  • (modified) llvm/unittests/CodeGen/GlobalISel/GISelMITest.h (+6-6)
  • (modified) llvm/unittests/CodeGen/InstrRefLDVTest.cpp (+4-4)
  • (modified) llvm/unittests/CodeGen/LexicalScopesTest.cpp (+1-1)
  • (modified) llvm/unittests/CodeGen/MFCommon.inc (+4-4)
  • (modified) llvm/unittests/CodeGen/MLRegAllocDevelopmentFeatures.cpp (+1-1)
  • (modified) llvm/unittests/CodeGen/MachineBasicBlockTest.cpp (+1-1)
  • (modified) llvm/unittests/CodeGen/MachineDomTreeUpdaterTest.cpp (+1-2)
  • (modified) llvm/unittests/CodeGen/MachineInstrTest.cpp (+1-1)
  • (modified) llvm/unittests/CodeGen/MachineOperandTest.cpp (+1-1)
  • (modified) llvm/unittests/CodeGen/PassManagerTest.cpp (+2-4)
  • (modified) llvm/unittests/CodeGen/RegAllocScoreTest.cpp (+1-1)
  • (modified) llvm/unittests/CodeGen/SelectionDAGAddressAnalysisTest.cpp (+3-3)
  • (modified) llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp (+4-5)
  • (modified) llvm/unittests/CodeGen/TargetOptionsTest.cpp (+1-2)
  • (modified) llvm/unittests/MC/AMDGPU/DwarfRegMappings.cpp (+3-4)
  • (modified) llvm/unittests/MI/LiveIntervalTest.cpp (+5-5)
  • (modified) llvm/unittests/MIR/MachineMetadata.cpp (+3-4)
  • (modified) llvm/unittests/MIR/MachineStableHashTest.cpp (+3-4)
  • (modified) llvm/unittests/Target/AArch64/AArch64SVESchedPseudoTest.cpp (+4-4)
  • (modified) llvm/unittests/Target/AArch64/InstSizes.cpp (+15-15)
  • (modified) llvm/unittests/Target/AArch64/MatrixRegisterAliasing.cpp (+4-4)
  • (modified) llvm/unittests/Target/ARM/InstSizes.cpp (+3-3)
  • (modified) llvm/unittests/Target/ARM/MachineInstrTest.cpp (+12-12)
  • (modified) llvm/unittests/Target/LoongArch/InstSizes.cpp (+8-8)
  • (modified) llvm/unittests/Target/VE/MachineInstrTest.cpp (+2-3)
  • (modified) llvm/unittests/Target/WebAssembly/WebAssemblyExceptionInfoTest.cpp (+5-5)
  • (modified) llvm/unittests/Target/X86/MachineSizeOptsTest.cpp (+4-4)
  • (modified) llvm/unittests/Target/X86/TernlogTest.cpp (+3-3)
  • (modified) llvm/unittests/tools/llvm-exegesis/Common/AssemblerUtils.h (+2-3)
  • (modified) llvm/unittests/tools/llvm-exegesis/X86/SnippetRepetitorTest.cpp (+1-1)
  • (modified) llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn (+1-1)
  • (modified) offload/plugins-nextgen/common/src/JIT.cpp (+1-2)
diff --git a/llvm/docs/WritingAnLLVMBackend.rst b/llvm/docs/WritingAnLLVMBackend.rst
index f1f07e4681d509..ae4f635bc5ef87 100644
--- a/llvm/docs/WritingAnLLVMBackend.rst
+++ b/llvm/docs/WritingAnLLVMBackend.rst
@@ -152,7 +152,7 @@ To make your target actually do something, you need to implement a subclass of
 ``lib/Target/DummyTargetMachine.cpp``, but any file in the ``lib/Target``
 directory will be built and should work.  To use LLVM's target independent code
 generator, you should do what all current machine backends do: create a
-subclass of ``LLVMTargetMachine``.  (To create a target from scratch, create a
+subclass of ``CodeGenCommonTMImpl``.  (To create a target from scratch, create a
 subclass of ``TargetMachine``.)
 
 To get LLVM to actually build and link your target, you need to run ``cmake``
@@ -165,15 +165,15 @@ located in the main ``CMakeLists.txt``.
 Target Machine
 ==============
 
-``LLVMTargetMachine`` is designed as a base class for targets implemented with
-the LLVM target-independent code generator.  The ``LLVMTargetMachine`` class
+``CodeGenCommonTMImpl`` is designed as a base class for targets implemented with
+the LLVM target-independent code generator.  The ``CodeGenCommonTMImpl`` class
 should be specialized by a concrete target class that implements the various
-virtual methods.  ``LLVMTargetMachine`` is defined as a subclass of
-``TargetMachine`` in ``include/llvm/Target/TargetMachine.h``.  The
-``TargetMachine`` class implementation (``TargetMachine.cpp``) also processes
-numerous command-line options.
+virtual methods.  ``CodeGenCommonTMImpl`` is defined as a subclass of
+``TargetMachine`` in ``include/llvm/CodeGen/CodeGenCommonTMImpl.h``.  The
+``TargetMachine`` class implementation (``include/llvm/Target/TargetMachine.cpp``)
+also processes numerous command-line options.
 
-To create a concrete target-specific subclass of ``LLVMTargetMachine``, start
+To create a concrete target-specific subclass of ``CodeGenCommonTMImpl``, start
 by copying an existing ``TargetMachine`` class and header.  You should name the
 files that you create to reflect your specific target.  For instance, for the
 SPARC target, name the files ``SparcTargetMachine.h`` and
@@ -197,7 +197,7 @@ simply return a class member.
 
   class Module;
 
-  class SparcTargetMachine : public LLVMTargetMachine {
+  class SparcTargetMachine : public CodeGenCommonTMImpl {
     const DataLayout DataLayout;       // Calculates type size & alignment
     SparcSubtarget Subtarget;
     SparcInstrInfo InstrInfo;
diff --git a/llvm/include/llvm/CodeGen/CodeGenCommonTMImpl.h b/llvm/include/llvm/CodeGen/CodeGenCommonTMImpl.h
new file mode 100644
index 00000000000000..92bfc8f4f96d29
--- /dev/null
+++ b/llvm/include/llvm/CodeGen/CodeGenCommonTMImpl.h
@@ -0,0 +1,92 @@
+//===-- CodeGenCommonTMImpl.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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file This file describes the CodeGenCommonTMImpl class, which
+/// implements a set of functionality used by \c TargetMachine classes in
+/// LLVM that make use of the target-independent code generator.
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_CODEGEN_CODEGENCOMMONTMIMPL_H
+#define LLVM_CODEGEN_CODEGENCOMMONTMIMPL_H
+#include "llvm/Target/TargetMachine.h"
+
+namespace llvm {
+
+/// \brief implements a set of functionality in the \c TargetMachine class
+/// for targets that make use of the independent code generator (CodeGen)
+/// library. Must not be used directly in code unless to inherit its
+/// implementation.
+class CodeGenCommonTMImpl : public TargetMachine {
+protected: // Can only create subclasses.
+  CodeGenCommonTMImpl(const Target &T, StringRef DataLayoutString,
+                      const Triple &TT, StringRef CPU, StringRef FS,
+                      const TargetOptions &Options, Reloc::Model RM,
+                      CodeModel::Model CM, CodeGenOptLevel OL);
+
+  void initAsmInfo();
+
+public:
+  /// Get a TargetTransformInfo implementation for the target.
+  ///
+  /// The TTI returned uses the common code generator to answer queries about
+  /// the IR.
+  TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
+
+  /// Create a pass configuration object to be used by addPassToEmitX methods
+  /// for generating a pipeline of CodeGen passes.
+  virtual TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
+
+  /// Add passes to the specified pass manager to get the specified file
+  /// emitted.  Typically this will involve several steps of code generation.
+  /// \p MMIWP is an optional parameter that, if set to non-nullptr,
+  /// will be used to set the MachineModuloInfo for this PM.
+  bool
+  addPassesToEmitFile(PassManagerBase &PM, raw_pwrite_stream &Out,
+                      raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+                      bool DisableVerify = true,
+                      MachineModuleInfoWrapperPass *MMIWP = nullptr) override;
+
+  /// Add passes to the specified pass manager to get machine code emitted with
+  /// the MCJIT. This method returns true if machine code is not supported. It
+  /// fills the MCContext Ctx pointer which can be used to build custom
+  /// MCStreamer.
+  bool addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx,
+                         raw_pwrite_stream &Out,
+                         bool DisableVerify = true) override;
+
+  /// Adds an AsmPrinter pass to the pipeline that prints assembly or
+  /// machine code from the MI representation.
+  bool addAsmPrinter(PassManagerBase &PM, raw_pwrite_stream &Out,
+                     raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
+                     MCContext &Context) override;
+
+  Expected<std::unique_ptr<MCStreamer>>
+  createMCStreamer(raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut,
+                   CodeGenFileType FileType, MCContext &Ctx) override;
+};
+
+/// Helper method for getting the code model, returning Default if
+/// CM does not have a value. The tiny and kernel models will produce
+/// an error, so targets that support them or require more complex codemodel
+/// selection logic should implement and call their own getEffectiveCodeModel.
+inline CodeModel::Model
+getEffectiveCodeModel(std::optional<CodeModel::Model> CM,
+                      CodeModel::Model Default) {
+  if (CM) {
+    // By default, targets do not support the tiny and kernel models.
+    if (*CM == CodeModel::Tiny)
+      report_fatal_error("Target does not support the tiny CodeModel", false);
+    if (*CM == CodeModel::Kernel)
+      report_fatal_error("Target does not support the kernel CodeModel", false);
+    return *CM;
+  }
+  return Default;
+}
+
+} // namespace llvm
+
+#endif
\ No newline at end of file
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index 053e7062fb4995..5a2b4881cfca2d 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -54,7 +54,7 @@ class DILocation;
 class Function;
 class GISelChangeObserver;
 class GlobalValue;
-class LLVMTargetMachine;
+class TargetMachine;
 class MachineConstantPool;
 class MachineFrameInfo;
 class MachineFunction;
@@ -256,7 +256,7 @@ struct LandingPadInfo {
 
 class LLVM_ABI MachineFunction {
   Function &F;
-  const LLVMTargetMachine &Target;
+  const TargetMachine &Target;
   const TargetSubtargetInfo *STI;
   MCContext &Ctx;
 
@@ -634,7 +634,7 @@ class LLVM_ABI MachineFunction {
   /// for instructions that have a stack spill fused into them.
   const static unsigned int DebugOperandMemNumber;
 
-  MachineFunction(Function &F, const LLVMTargetMachine &Target,
+  MachineFunction(Function &F, const TargetMachine &Target,
                   const TargetSubtargetInfo &STI, MCContext &Ctx,
                   unsigned FunctionNum);
   MachineFunction(const MachineFunction &) = delete;
@@ -707,7 +707,7 @@ class LLVM_ABI MachineFunction {
   void assignBeginEndSections();
 
   /// getTarget - Return the target machine this machine code is compiled with
-  const LLVMTargetMachine &getTarget() const { return Target; }
+  const TargetMachine &getTarget() const { return Target; }
 
   /// getSubtarget - Return the subtarget for which this machine code is being
   /// compiled.
diff --git a/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h b/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
index f54d455292da03..e194f4838e118c 100644
--- a/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
+++ b/llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h
@@ -18,7 +18,7 @@
 namespace llvm {
 
 class MachineFunction;
-class LLVMTargetMachine;
+class TargetMachine;
 
 /// This analysis create MachineFunction for given Function.
 /// To release the MachineFunction, users should invalidate it explicitly.
@@ -28,7 +28,7 @@ class MachineFunctionAnalysis
 
   static AnalysisKey Key;
 
-  const LLVMTargetMachine *TM;
+  const TargetMachine *TM;
 
 public:
   class Result {
@@ -41,7 +41,7 @@ class MachineFunctionAnalysis
                     FunctionAnalysisManager::Invalidator &);
   };
 
-  MachineFunctionAnalysis(const LLVMTargetMachine *TM) : TM(TM){};
+  MachineFunctionAnalysis(const TargetMachine *TM) : TM(TM) {};
   Result run(Function &F, FunctionAnalysisManager &FAM);
 };
 
diff --git a/llvm/include/llvm/CodeGen/MachineModuleInfo.h b/llvm/include/llvm/CodeGen/MachineModuleInfo.h
index 310cc4b2abb772..bec500dc609f32 100644
--- a/llvm/include/llvm/CodeGen/MachineModuleInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineModuleInfo.h
@@ -43,7 +43,7 @@
 namespace llvm {
 
 class Function;
-class LLVMTargetMachine;
+class TargetMachine;
 class MachineFunction;
 class Module;
 
@@ -83,7 +83,7 @@ class MachineModuleInfo {
   friend class MachineModuleInfoWrapperPass;
   friend class MachineModuleAnalysis;
 
-  const LLVMTargetMachine &TM;
+  const TargetMachine &TM;
 
   /// This is the MCContext used for the entire code generator.
   MCContext Context;
@@ -109,10 +109,9 @@ class MachineModuleInfo {
   MachineModuleInfo &operator=(MachineModuleInfo &&MMII) = delete;
 
 public:
-  explicit MachineModuleInfo(const LLVMTargetMachine *TM = nullptr);
+  explicit MachineModuleInfo(const TargetMachine *TM = nullptr);
 
-  explicit MachineModuleInfo(const LLVMTargetMachine *TM,
-                             MCContext *ExtContext);
+  explicit MachineModuleInfo(const TargetMachine *TM, MCContext *ExtContext);
 
   MachineModuleInfo(MachineModuleInfo &&MMII);
 
@@ -121,7 +120,7 @@ class MachineModuleInfo {
   void initialize();
   void finalize();
 
-  const LLVMTargetMachine &getTarget() const { return TM; }
+  const TargetMachine &getTarget() const { return TM; }
 
   const MCContext &getContext() const {
     return ExternalContext ? *ExternalContext : Context;
@@ -173,9 +172,9 @@ class MachineModuleInfoWrapperPass : public ImmutablePass {
 
 public:
   static char ID; // Pass identification, replacement for typeid
-  explicit MachineModuleInfoWrapperPass(const LLVMTargetMachine *TM = nullptr);
+  explicit MachineModuleInfoWrapperPass(const TargetMachine *TM = nullptr);
 
-  explicit MachineModuleInfoWrapperPass(const LLVMTargetMachine *TM,
+  explicit MachineModuleInfoWrapperPass(const TargetMachine *TM,
                                         MCContext *ExtContext);
 
   // Initialization and Finalization
diff --git a/llvm/include/llvm/CodeGen/RegisterUsageInfo.h b/llvm/include/llvm/CodeGen/RegisterUsageInfo.h
index aa1f5ef8110b0c..845ed09a852ad9 100644
--- a/llvm/include/llvm/CodeGen/RegisterUsageInfo.h
+++ b/llvm/include/llvm/CodeGen/RegisterUsageInfo.h
@@ -29,7 +29,7 @@
 namespace llvm {
 
 class Function;
-class LLVMTargetMachine;
+class TargetMachine;
 
 class PhysicalRegisterUsageInfo : public ImmutablePass {
 public:
@@ -41,7 +41,7 @@ class PhysicalRegisterUsageInfo : public ImmutablePass {
   }
 
   /// Set TargetMachine which is used to print analysis.
-  void setTargetMachine(const LLVMTargetMachine &TM);
+  void setTargetMachine(const TargetMachine &TM);
 
   bool doInitialization(Module &M) override;
 
@@ -63,7 +63,7 @@ class PhysicalRegisterUsageInfo : public ImmutablePass {
   /// and 1 means content of register will be preserved around function call.
   DenseMap<const Function *, std::vector<uint32_t>> RegMasks;
 
-  const LLVMTargetMachine *TM = nullptr;
+  const TargetMachine *TM = nullptr;
 };
 
 } // end namespace llvm
diff --git a/llvm/include/llvm/CodeGen/ScheduleDAG.h b/llvm/include/llvm/CodeGen/ScheduleDAG.h
index 53265b286c7c87..54e65335edf3a2 100644
--- a/llvm/include/llvm/CodeGen/ScheduleDAG.h
+++ b/llvm/include/llvm/CodeGen/ScheduleDAG.h
@@ -32,7 +32,7 @@ namespace llvm {
 
 template <class GraphType> struct GraphTraits;
 template<class Graph> class GraphWriter;
-class LLVMTargetMachine;
+class TargetMachine;
 class MachineFunction;
 class MachineRegisterInfo;
 class MCInstrDesc;
@@ -571,7 +571,7 @@ class TargetRegisterInfo;
 
   class ScheduleDAG {
   public:
-    const LLVMTargetMachine &TM;        ///< Target processor
+    const TargetMachine &TM;            ///< Target processor
     const TargetInstrInfo *TII;         ///< Target instruction information
     const TargetRegisterInfo *TRI;      ///< Target processor register info
     MachineFunction &MF;                ///< Machine function
diff --git a/llvm/include/llvm/CodeGen/TargetPassConfig.h b/llvm/include/llvm/CodeGen/TargetPassConfig.h
index 2f5951e3ec3bce..85f87de521855f 100644
--- a/llvm/include/llvm/CodeGen/TargetPassConfig.h
+++ b/llvm/include/llvm/CodeGen/TargetPassConfig.h
@@ -21,7 +21,7 @@
 
 namespace llvm {
 
-class LLVMTargetMachine;
+class TargetMachine;
 struct MachineSchedContext;
 class PassConfigImpl;
 class ScheduleDAGInstrs;
@@ -120,7 +120,7 @@ class TargetPassConfig : public ImmutablePass {
   void setStartStopPasses();
 
 protected:
-  LLVMTargetMachine *TM;
+  TargetMachine *TM;
   PassConfigImpl *Impl = nullptr; // Internal data structures
   bool Initialized = false; // Flagged after all passes are configured.
 
@@ -148,7 +148,7 @@ class TargetPassConfig : public ImmutablePass {
   bool addCoreISelPasses();
 
 public:
-  TargetPassConfig(LLVMTargetMachine &TM, PassManagerBase &pm);
+  TargetPassConfig(TargetMachine &TM, PassManagerBase &PM);
   // Dummy constructor.
   TargetPassConfig();
 
@@ -413,7 +413,7 @@ class TargetPassConfig : public ImmutablePass {
   virtual void addFastRegAlloc();
 
   /// addOptimizedRegAlloc - Add passes related to register allocation.
-  /// LLVMTargetMachine provides standard regalloc passes for most targets.
+  /// CodeGenCommonTMImpl provides standard regalloc passes for most targets.
   virtual void addOptimizedRegAlloc();
 
   /// addPreRewrite - Add passes to the optimized register allocation pipeline
@@ -497,7 +497,7 @@ class TargetPassConfig : public ImmutablePass {
 };
 
 void registerCodeGenCallback(PassInstrumentationCallbacks &PIC,
-                             LLVMTargetMachine &);
+                             TargetMachine &);
 
 } // end namespace llvm
 
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index 13bc4700d87029..08629d656552d7 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -438,7 +438,7 @@ template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
   Error addFastRegAlloc(AddMachinePass &) const;
 
   /// addOptimizedRegAlloc - Add passes related to register allocation.
-  /// LLVMTargetMachine provides standard regalloc passes for most targets.
+  /// CodeGenCommonTMImpl provides standard regalloc passes for most targets.
   void addOptimizedRegAlloc(AddMachinePass &) const;
 
   /// Add passes that optimize machine instructions after register allocation.
diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h
index c3e9d41315f617..9bdb110bd36839 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -5,9 +5,9 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
-//
-// This file defines the TargetMachine and LLVMTargetMachine classes.
-//
+///
+/// This file defines the TargetMachine class.
+///
 //===----------------------------------------------------------------------===//
 
 #ifndef LLVM_TARGET_TARGETMACHINE_H
@@ -16,6 +16,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/MC/MCStreamer.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Error.h"
@@ -40,7 +41,6 @@ class MCAsmInfo;
 class MCContext;
 class MCInstrInfo;
 class MCRegisterInfo;
-class MCStreamer;
 class MCSubtargetInfo;
 class MCSymbol;
 class raw_pwrite_stream;
@@ -60,13 +60,13 @@ class TargetSubtargetInfo;
 // The old pass manager infrastructure is hidden in a legacy namespace now.
 namespace legacy {
 class PassManagerBase;
-}
+} // namespace legacy
 using legacy::PassManagerBase;
 
 struct MachineFunctionInfo;
 namespace yaml {
 struct MachineFunctionInfo;
-}
+} // namespace yaml
 
 //===----------------------------------------------------------------------===//
 ///
@@ -434,40 +434,12 @@ class TargetMachine {
       function_ref<void(std::unique_ptr<Module> MPart)> ModuleCallback) {
     return false;
   }
-};
-
-/// This class describes a target machine that is implemented with the LLVM
-/// target-independent code generator.
-///
-class LLVMTargetMachine : public TargetMachine {
-protected: // Can only create subclasses.
-  LLVMTargetMachine(const Target &T, StringRef DataLayoutString,
-                    const Triple &TT, StringRef CPU, StringRef FS,
-                    const TargetOptions &Options, Reloc::Model RM,
-                    CodeModel::Model CM, CodeGenOptLevel OL);
-
-  void initAsmInfo();
-
-public:
-  /// Get a TargetTransformInfo implementation for the target.
-  ///
-  /// The TTI returned uses the common code generator to answer queries about
-  /// the IR.
-  TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
 
   /// Create a pass configuration object to be used by addPassToEmitX methods
   /// for generating a pipeline of CodeGen passes.
-  virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
-
-  /// Add passes to the specified pass manager to get the specified file
-  /// emitted.  Typically this will involve several steps of code generation.
-  /// \p MMIWP is an optional parameter that, if set to non-nullptr,
-  /// will be used to set the MachineModuloInfo for this PM.
-  bool
-  addPassesToEmitFile(PassManagerBase &PM, raw_pwrite_stream &Out,
-                      raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
-                      bool DisableVerify = true,
-                      MachineModuleInfoWrapperPass *MMIWP = nullptr) override;
+  virtual TargetPassConfig *createPassConfig(PassManagerBase &PM) {
+    return nullptr;
+  }
 
   virtual Error buildCodeGenPipeline(ModulePassManager &, raw_pwrite_stream &,
                                      raw_pwrite_stream *, CodeGenFileType,
@@ -477,14 +449,6 @@ class LLVMTargetMachine : public TargetMachine {
                                    inconvertibleErrorCode());
   }
 
-  /// Add passes to the specified pass manager to get machine code emitted with
-  /// the MCJIT. This method returns true if machine code is not supported. It
-  /// fills the MCContext Ctx pointer which can be used to build custom
-  /// MCStreamer.
-  bool addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx,
-                         raw_pwrite_stream &Out,
-                         bool DisableVerify = true) override;
-
   /// Returns true if the target is expected to pass all machine verifier
   /// checks. This is a stopgap measure to fix targets one by one. We will
   /// remove this at some point and always enable the verifier when
@@ -493,13 +457,17 @@ class LLVMTargetMachine : public TargetMachine {
 
   /// Adds an AsmPrinter pa...
[truncated]

Copy link

github-actions bot commented Oct 5, 2024

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Discourse for more information.

Copy link

github-actions bot commented Oct 5, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.


} // namespace llvm

#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing end of file line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed, but please check this again. My editor either doesn't show it to me or puts too many whitespaces at the end, causing clang format to complain.

@@ -256,7 +256,7 @@ struct LandingPadInfo {

class LLVM_ABI MachineFunction {
Function &F;
const LLVMTargetMachine &Target;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect all of the references in the codegen infrastructure to refer to the codegen dependent subclass

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's a need anymore. I'm hoping CodeGenCommonTMImpl is treated as just a set of function implementation, and there won't be any hard requirement on subclassing it if you want to use the target independent code generator (CodeGen) library.

In other words, a Target can just ignore everything in CodeGenCommonTMImpl and start from scratch, but still use the CodeGen library.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're in MachineFunction, you are definitely using CodeGen. So why wouldn't MachineFunction reference the lowest common subclass for codegen?

/// for targets that make use of the independent code generator (CodeGen)
/// library. Must not be used directly in code unless to inherit its
/// implementation.
class CodeGenCommonTMImpl : public TargetMachine {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this name needs work. CodeGenTargetMachine maybe?

Copy link
Contributor Author

@matinraayai matinraayai Oct 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally I named it CodeGenTargetMachine, but I picked an ugly name on purpose to remind people not to use this class directly in their code unless they are subclassing it for their targets.

Again, my goal was to remove the need to static cast every time you need a CodeGen-specific feature of the TargetMachine, it's already in the interface. The target of choice has the freedom to not use it and either a) start from scratch in order to use the target-independent code generator, or b) use its own code generation scheme.

This is essentially the best middle ground I found between completely removing LLVMTargetMachine and not breaking the compilation process. With this change, it's as if LLVMTargetMachine was removed from the user's perspective. Meanwhile, this shouldn't cause any havoc on the toolchain compilation process, as all library requirements remain the same (i.e. there's no requirement to link to CodeGen unless you're using the CodeGen-related TM interfaces).

Copy link
Contributor

@arsenm arsenm Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still should probably go for the less ugly name (at least the TM part)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree that we should have a slightly nicer name, maybe CodeGenTargetMachineImpl. at least spelling out TargetMachine instead of TM


Expected<std::unique_ptr<MCStreamer>>
createMCStreamer(raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut,
CodeGenFileType FileType, MCContext &Ctx) override;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #108690 I'm also trying to use callbacks to avoid these functions in new pass manager.

@matinraayai
Copy link
Contributor Author

@arsenm @paperchalice any suggestions on what I should change here? I can either:

  1. Make CodeGenTargetMachine behave the same way it did before, and add a dyn_cast option to it to confirm whether a TargetMachine was implemented with code gen support; or
  2. Keep the PR the way it is; i.e. CodeGenTargetMachine is just a set of function implementations a TargetMachine can inherit.

@paperchalice
Copy link
Contributor

  1. Make CodeGenTargetMachine behave the same way it did before, and add a dyn_cast option to it to confirm whether a TargetMachine was implemented with code gen support; or
  2. Keep the PR the way it is; i.e. CodeGenTargetMachine is just a set of function implementations a TargetMachine can inherit.

I'd prefer 2, because IIUC all targets in lib/Target inherit LLVMTargetMachine. For long-term goal, I would prefer to avoid concept like LLVMTargetMachine, but this is off-topic.

@matinraayai
Copy link
Contributor Author

matinraayai commented Nov 11, 2024

@aeubanks I put the RFC in my commit message. I'm also putting it here for reference: https://discourse.llvm.org/t/rfc-reworking-the-targetmachine-interface/82478
I changed the name to CodeGenTargetMachineImpl as I wanted to emphasize that it should not be used directly in code unless to inherit its methods. @arsenm I can change the name to CodeGenTargetMachine if it's still too ugly.

@aeubanks
Copy link
Contributor

lgtm

@aeubanks
Copy link
Contributor

although precommit CI looks relevant

@matinraayai
Copy link
Contributor Author

@aeubanks which one? I just fixed the issues regarding TM usage added in the past 2 weeks.

although precommit CI looks relevant

@aeubanks
Copy link
Contributor

looks good now

@matinraayai
Copy link
Contributor Author

@arsenm @aeubanks this should be good to merge. Please merge it ASAP to prevent any more surprise new uses of TM in master that require migrating.

@arsenm arsenm merged commit bb3f5e1 into llvm:main Nov 14, 2024
10 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 14, 2024

LLVM Buildbot has detected a new failure on builder arc-builder running on arc-worker while building llvm,offload at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/3/builds/7655

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
751.291 [2250/16/1885] Building CXX object lib/Target/ARC/CMakeFiles/LLVMARCCodeGen.dir/ARCRegisterInfo.cpp.o
751.406 [2249/16/1886] Building CXX object lib/LineEditor/CMakeFiles/LLVMLineEditor.dir/LineEditor.cpp.o
751.417 [2248/16/1887] Linking CXX static library lib/libLLVMLineEditor.a
751.450 [2247/16/1888] Building CXX object lib/Target/ARC/CMakeFiles/LLVMARCCodeGen.dir/ARCISelLowering.cpp.o
751.473 [2246/16/1889] Building CXX object lib/SandboxIR/CMakeFiles/LLVMSandboxIR.dir/Use.cpp.o
752.889 [2245/16/1890] Building CXX object lib/SandboxIR/CMakeFiles/LLVMSandboxIR.dir/Region.cpp.o
753.129 [2244/16/1891] Building CXX object lib/SandboxIR/CMakeFiles/LLVMSandboxIR.dir/Value.cpp.o
753.688 [2243/16/1892] Building CXX object lib/AsmParser/CMakeFiles/LLVMAsmParser.dir/LLLexer.cpp.o
753.871 [2242/16/1893] Building CXX object lib/SandboxIR/CMakeFiles/LLVMSandboxIR.dir/Tracker.cpp.o
754.463 [2241/16/1894] Building CXX object lib/Target/ARC/CMakeFiles/LLVMARCCodeGen.dir/ARCTargetMachine.cpp.o
FAILED: lib/Target/ARC/CMakeFiles/LLVMARCCodeGen.dir/ARCTargetMachine.cpp.o 
/usr/bin/c++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Target/ARC -I/buildbot/worker/arc-folder/llvm-project/llvm/lib/Target/ARC -Iinclude -I/buildbot/worker/arc-folder/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -fvisibility=hidden  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT lib/Target/ARC/CMakeFiles/LLVMARCCodeGen.dir/ARCTargetMachine.cpp.o -MF lib/Target/ARC/CMakeFiles/LLVMARCCodeGen.dir/ARCTargetMachine.cpp.o.d -o lib/Target/ARC/CMakeFiles/LLVMARCCodeGen.dir/ARCTargetMachine.cpp.o -c /buildbot/worker/arc-folder/llvm-project/llvm/lib/Target/ARC/ARCTargetMachine.cpp
/buildbot/worker/arc-folder/llvm-project/llvm/lib/Target/ARC/ARCTargetMachine.cpp: In constructor 'llvm::ARCTargetMachine::ARCTargetMachine(const llvm::Target&, const llvm::Triple&, llvm::StringRef, llvm::StringRef, const llvm::TargetOptions&, std::optional<llvm::Reloc::Model>, std::optional<llvm::CodeModel::Model>, llvm::CodeGenOptLevel, bool)':
/buildbot/worker/arc-folder/llvm-project/llvm/lib/Target/ARC/ARCTargetMachine.cpp:36:7: error: class 'llvm::ARCTargetMachine' does not have any field named 'CodeGenCommonTMImpl'
   36 |     : CodeGenCommonTMImpl(T,
      |       ^~~~~~~~~~~~~~~~~~~
/buildbot/worker/arc-folder/llvm-project/llvm/lib/Target/ARC/ARCTargetMachine.cpp:42:61: error: no matching function for call to 'llvm::CodeGenTargetMachineImpl::CodeGenTargetMachineImpl()'
   42 |       Subtarget(TT, std::string(CPU), std::string(FS), *this) {
      |                                                             ^
In file included from /buildbot/worker/arc-folder/llvm-project/llvm/lib/Target/ARC/ARCTargetMachine.h:17,
                 from /buildbot/worker/arc-folder/llvm-project/llvm/lib/Target/ARC/ARCTargetMachine.cpp:12:
/buildbot/worker/arc-folder/llvm-project/llvm/include/llvm/CodeGen/CodeGenTargetMachineImpl.h:25:3: note: candidate: 'llvm::CodeGenTargetMachineImpl::CodeGenTargetMachineImpl(const llvm::Target&, llvm::StringRef, const llvm::Triple&, llvm::StringRef, llvm::StringRef, const llvm::TargetOptions&, llvm::Reloc::Model, llvm::CodeModel::Model, llvm::CodeGenOptLevel)'
   25 |   CodeGenTargetMachineImpl(const Target &T, StringRef DataLayoutString,
      |   ^~~~~~~~~~~~~~~~~~~~~~~~
/buildbot/worker/arc-folder/llvm-project/llvm/include/llvm/CodeGen/CodeGenTargetMachineImpl.h:25:3: note:   candidate expects 9 arguments, 0 provided
756.032 [2241/15/1895] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/GCOV.cpp.o
757.157 [2241/14/1896] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/PGOCtxProfReader.cpp.o
757.332 [2241/13/1897] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/PGOCtxProfWriter.cpp.o
757.504 [2241/12/1898] Building CXX object lib/AsmParser/CMakeFiles/LLVMAsmParser.dir/Parser.cpp.o
757.803 [2241/11/1899] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/InstrProfCorrelator.cpp.o
758.149 [2241/10/1900] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/MemProf.cpp.o
759.781 [2241/9/1901] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/ItaniumManglingCanonicalizer.cpp.o
759.924 [2241/8/1902] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/ProfileSummaryBuilder.cpp.o
760.213 [2241/7/1903] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/InstrProf.cpp.o
760.952 [2241/6/1904] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/SampleProf.cpp.o
762.248 [2241/5/1905] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/MemProfReader.cpp.o
762.467 [2241/4/1906] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/InstrProfWriter.cpp.o
763.208 [2241/3/1907] Building CXX object lib/ProfileData/CMakeFiles/LLVMProfileData.dir/InstrProfReader.cpp.o
767.704 [2241/2/1908] Building CXX object lib/AsmParser/CMakeFiles/LLVMAsmParser.dir/LLParser.cpp.o
780.739 [2241/1/1909] Building CXX object lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86ISelLowering.cpp.o
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 14, 2024

LLVM Buildbot has detected a new failure on builder clang-m68k-linux-cross running on suse-gary-m68k-cross while building llvm,offload at step 4 "build stage 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/2045

Here is the relevant piece of the build log for the reference
Step 4 (build stage 1) failure: 'ninja' (failure)
...
[2848/4717] Building CXX object lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/Attributor.cpp.o
[2849/4717] Building CXX object lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/GISel/M68kCallLowering.cpp.o
[2850/4717] Building CXX object lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/M68kAsmPrinter.cpp.o
[2851/4717] Building CXX object lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/M68kMachineFunction.cpp.o
[2852/4717] Building CXX object lib/Transforms/Vectorize/CMakeFiles/LLVMVectorize.dir/LoopVectorize.cpp.o
[2853/4717] Building CXX object lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/M68kRegisterInfo.cpp.o
[2854/4717] Building CXX object lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/M68kFrameLowering.cpp.o
[2855/4717] Building CXX object lib/Target/X86/MCTargetDesc/CMakeFiles/LLVMX86Desc.dir/X86MCTargetDesc.cpp.o
[2856/4717] Building CXX object lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/LowerTypeTests.cpp.o
[2857/4717] Building CXX object lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/M68kTargetMachine.cpp.o
FAILED: lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/M68kTargetMachine.cpp.o 
/usr/bin/c++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/lib/Target/M68k -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/lib/Target/M68k -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17 -fvisibility=hidden  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/M68kTargetMachine.cpp.o -MF lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/M68kTargetMachine.cpp.o.d -o lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/M68kTargetMachine.cpp.o -c /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/lib/Target/M68k/M68kTargetMachine.cpp
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/lib/Target/M68k/M68kTargetMachine.cpp: In constructor ‘llvm::M68kTargetMachine::M68kTargetMachine(const llvm::Target&, const llvm::Triple&, llvm::StringRef, llvm::StringRef, const llvm::TargetOptions&, std::optional<llvm::Reloc::Model>, std::optional<llvm::CodeModel::Model>, llvm::CodeGenOptLevel, bool)’:
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/lib/Target/M68k/M68kTargetMachine.cpp:103:7: error: class ‘llvm::M68kTargetMachine’ does not have any field named ‘CodeGenCommonTMImpl’
  103 |     : CodeGenCommonTMImpl(T, computeDataLayout(TT, CPU, Options), TT, CPU, FS,
      |       ^~~~~~~~~~~~~~~~~~~
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/lib/Target/M68k/M68kTargetMachine.cpp:107:35: error: no matching function for call to ‘llvm::CodeGenTargetMachineImpl::CodeGenTargetMachineImpl()’
  107 |       Subtarget(TT, CPU, FS, *this) {
      |                                   ^
In file included from /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/lib/Target/M68k/M68kTargetMachine.h:20,
                 from /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/lib/Target/M68k/M68kTargetMachine.cpp:14:
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/include/llvm/CodeGen/CodeGenTargetMachineImpl.h:25:3: note: candidate: ‘llvm::CodeGenTargetMachineImpl::CodeGenTargetMachineImpl(const llvm::Target&, llvm::StringRef, const llvm::Triple&, llvm::StringRef, llvm::StringRef, const llvm::TargetOptions&, llvm::Reloc::Model, llvm::CodeModel::Model, llvm::CodeGenOptLevel)’
   25 |   CodeGenTargetMachineImpl(const Target &T, StringRef DataLayoutString,
      |   ^~~~~~~~~~~~~~~~~~~~~~~~
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/include/llvm/CodeGen/CodeGenTargetMachineImpl.h:25:3: note:   candidate expects 9 arguments, 0 provided
[2858/4717] Building CXX object lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/M68kMCInstLower.cpp.o
[2859/4717] Building CXX object lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/M68kISelDAGToDAG.cpp.o
[2860/4717] Building CXX object lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/M68kInstrInfo.cpp.o
[2861/4717] Building CXX object lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/M68kSubtarget.cpp.o
[2862/4717] Building CXX object lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/M68kTargetObjectFile.cpp.o
[2863/4717] Building CXX object lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/GISel/M68kInstructionSelector.cpp.o
[2864/4717] Building CXX object lib/Target/M68k/CMakeFiles/LLVMM68kCodeGen.dir/M68kISelLowering.cpp.o
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/lib/Target/M68k/M68kISelLowering.cpp: In function ‘void lowerOverflowArithmetic(llvm::SDValue, llvm::SelectionDAG&, llvm::SDValue&, llvm::SDValue&, unsigned int&)’:
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/lib/Target/M68k/M68kISelLowering.cpp:1597:25: warning: enumerated mismatch in conditional expression: ‘llvm::ISD::NodeType’ vs ‘llvm::M68kISD::NodeType’ [-Wenum-compare]
 1597 |     BaseOp = NoOverflow ? ISD::MUL : M68kISD::UMUL;
      |              ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/lib/Target/M68k/M68kISelLowering.cpp:1603:25: warning: enumerated mismatch in conditional expression: ‘llvm::ISD::NodeType’ vs ‘llvm::M68kISD::NodeType’ [-Wenum-compare]
 1603 |     BaseOp = NoOverflow ? ISD::MUL : M68kISD::SMUL;
      |              ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
[2865/4717] Building CXX object lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/WholeProgramDevirt.cpp.o
[2866/4717] Building CXX object tools/clang/tools/extra/clang-tidy/readability/CMakeFiles/obj.clangTidyReadabilityModule.dir/AvoidNestedConditionalOperatorCheck.cpp.o
[2867/4717] Building CXX object tools/clang/tools/extra/clang-tidy/utils/CMakeFiles/obj.clangTidyUtils.dir/RenamerClangTidyCheck.cpp.o
[2868/4717] Building CXX object tools/clang/tools/extra/clang-tidy/readability/CMakeFiles/obj.clangTidyReadabilityModule.dir/AvoidUnconditionalPreprocessorIfCheck.cpp.o
[2869/4717] Building CXX object tools/clang/tools/extra/clang-tidy/readability/CMakeFiles/obj.clangTidyReadabilityModule.dir/AvoidConstParamsInDecls.cpp.o
[2870/4717] Building CXX object lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/SampleProfile.cpp.o
[2871/4717] Building CXX object tools/clang/tools/extra/clang-tidy/readability/CMakeFiles/obj.clangTidyReadabilityModule.dir/AvoidReturnWithVoidValueCheck.cpp.o
[2872/4717] Building CXX object tools/clang/tools/extra/clang-tidy/readability/CMakeFiles/obj.clangTidyReadabilityModule.dir/DeleteNullPointerCheck.cpp.o
[2873/4717] Building CXX object tools/clang/tools/extra/clang-tidy/readability/CMakeFiles/obj.clangTidyReadabilityModule.dir/BracesAroundStatementsCheck.cpp.o
[2874/4717] Building CXX object tools/clang/tools/extra/clang-tidy/readability/CMakeFiles/obj.clangTidyReadabilityModule.dir/ContainerContainsCheck.cpp.o

@matinraayai
Copy link
Contributor Author

@arsenm I pushed some fixes for the build failures detected by @llvm-ci. I'm not sure how the test CI missed them in the first place. Can you review and merge these new changes again please?

@nikic
Copy link
Contributor

nikic commented Nov 14, 2024

@matinraayai You'll have to open a new PR on top of main for that, it's not possible to push commits to a PR that has been merged.

@arsenm
Copy link
Contributor

arsenm commented Nov 14, 2024

What's broken is the experimental targets, which in theory you shouldn't have to worry about. You still get the build failure notifications, so this is a dumb system. We should either not notify on experimental target builds, or get rid of the concept entirely

@matinraayai
Copy link
Contributor Author

@nikic @arsenm I made another PR at #116290, but if the test CI won't be able to report any potential issues with the experimental targets I'm not sure how I can proceed besides building my fork on my local machine for all targets.

bogner pushed a commit that referenced this pull request Nov 15, 2024
…al Targets (#116290)

This PR fixes a set of build issues with experimental targets happened
in result of merging #111234 to master.
@bogner
Copy link
Contributor

bogner commented Nov 15, 2024

What's broken is the experimental targets, which in theory you shouldn't have to worry about. You still get the build failure notifications, so this is a dumb system. We should either not notify on experimental target builds, or get rid of the concept entirely

I posted https://discourse.llvm.org/t/rfc-llvm-experimental-targets-to-build-helps-no-one/83148 saying we should really just get rid of the experimental targets concept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

9 participants