[llvm] f729c09 - MC: Inline createMachObjectWriter into MCAsmBackend

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 24 11:05:11 PDT 2024


Author: Fangrui Song
Date: 2024-07-24T11:05:05-07:00
New Revision: f729c09c3a56ec41b558eff1a6475a8d8bd20d41

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

LOG: MC: Inline createMachObjectWriter into MCAsmBackend

We could do the same to COFF once WinCOFFObjectWriter is cleaned up
(#100303).

Added: 
    

Modified: 
    llvm/include/llvm/MC/MCMachObjectWriter.h
    llvm/lib/MC/MCAsmBackend.cpp
    llvm/lib/MC/MachObjectWriter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/MC/MCMachObjectWriter.h b/llvm/include/llvm/MC/MCMachObjectWriter.h
index 4df9c92ae368d..77652c7ff53a3 100644
--- a/llvm/include/llvm/MC/MCMachObjectWriter.h
+++ b/llvm/include/llvm/MC/MCMachObjectWriter.h
@@ -353,18 +353,6 @@ class MachObjectWriter final : public MCObjectWriter {
 
   uint64_t writeObject(MCAssembler &Asm) override;
 };
-
-/// Construct a new Mach-O writer instance.
-///
-/// This routine takes ownership of the target writer subclass.
-///
-/// \param MOTW - The target specific Mach-O writer subclass.
-/// \param OS - The stream to write to.
-/// \returns The constructed object writer.
-std::unique_ptr<MCObjectWriter>
-createMachObjectWriter(std::unique_ptr<MCMachObjectTargetWriter> MOTW,
-                       raw_pwrite_stream &OS, bool IsLittleEndian);
-
 } // end namespace llvm
 
 #endif // LLVM_MC_MCMACHOBJECTWRITER_H

diff  --git a/llvm/lib/MC/MCAsmBackend.cpp b/llvm/lib/MC/MCAsmBackend.cpp
index 7433f41c9e0fb..bab3485b50614 100644
--- a/llvm/lib/MC/MCAsmBackend.cpp
+++ b/llvm/lib/MC/MCAsmBackend.cpp
@@ -35,8 +35,8 @@ MCAsmBackend::createObjectWriter(raw_pwrite_stream &OS) const {
   bool IsLE = Endian == llvm::endianness::little;
   switch (TW->getFormat()) {
   case Triple::MachO:
-    return createMachObjectWriter(cast<MCMachObjectTargetWriter>(std::move(TW)),
-                                  OS, IsLE);
+    return std::make_unique<MachObjectWriter>(
+        cast<MCMachObjectTargetWriter>(std::move(TW)), OS, IsLE);
   case Triple::COFF:
     return createWinCOFFObjectWriter(
         cast<MCWinCOFFObjectTargetWriter>(std::move(TW)), OS);

diff  --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index 97fe254e4e979..8596f457574a3 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -1108,10 +1108,3 @@ uint64_t MachObjectWriter::writeObject(MCAssembler &Asm) {
 
   return NumBytesWritten();
 }
-
-std::unique_ptr<MCObjectWriter>
-llvm::createMachObjectWriter(std::unique_ptr<MCMachObjectTargetWriter> MOTW,
-                             raw_pwrite_stream &OS, bool IsLittleEndian) {
-  return std::make_unique<MachObjectWriter>(std::move(MOTW), OS,
-                                             IsLittleEndian);
-}


        


More information about the llvm-commits mailing list