Skip to content

[MC][AArch64][ARM][X86] Push target-dependent assembler flags into targets #139844

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 1 commit into from
May 18, 2025

Conversation

jrtc27
Copy link
Collaborator

@jrtc27 jrtc27 commented May 14, 2025

The .syntax unified directive and .codeX/.code X directives are, other
than some simple common printing code, exclusively implemented in the
targets themselves. Thus, remove the corresponding MCAF_* flags and
reimplement the directives solely within the targets. This avoids
exposing all targets to all other targets' flags.

Since MCAF_SubsectionsViaSymbols is all that remains, convert it to its
own function like other directives, simplifying its implementation.

Note that, on X86, we now always need a target streamer when parsing
assembly, as it's now used for directives that aren't COFF-specific. It
still does not however need to do anything when producing a non-COFF
object file, so this commit does not introduce any new target streamers.

There is some churn in test output, and corresponding UTC regex changes,
due to comments no longer being flushed by these various directives (and
EmitEOL is not exposed outside MCAsmStreamer.cpp so we couldn't do so
even if we wanted to), but that was a bit odd to be doing anyway.

This is motivated by Morello LLVM, which adds yet another assembler flag
to distinguish A64 and C64 instruction sets, but did not update every
switch and so emits warnings during the build. Rather than fix those
warnings it seems better to instead make the problem not exist in the
first place via this change.

…rgets

The .syntax unified directive and .codeX/.code X directives are, other
than some simple common printing code, exclusively implemented in the
targets themselves. Thus, remove the corresponding MCAF_* flags and
reimplement the directives solely within the targets. This avoids
exposing all targets to all other targets' flags.

Since MCAF_SubsectionsViaSymbols is all that remains, convert it to its
own function like other directives, simplifying its implementation.

Note that, on X86, we now always need a target streamer when parsing
assembly, as it's now used for directives that aren't COFF-specific. It
still does not however need to do anything when producing a non-COFF
object file, so this commit does not introduce any new target streamers.

There is some churn in test output, and corresponding UTC regex changes,
due to comments no longer being flushed by these various directives (and
EmitEOL is not exposed outside MCAsmStreamer.cpp so we couldn't do so
even if we wanted to), but that was a bit odd to be doing anyway.

This is motivated by Morello LLVM, which adds yet another assembler flag
to distinguish A64 and C64 instruction sets, but did not update every
switch and so emits warnings during the build. Rather than fix those
warnings it seems better to instead make the problem not exist in the
first place via this change.
@llvmbot
Copy link
Member

llvmbot commented May 14, 2025

@llvm/pr-subscribers-testing-tools
@llvm/pr-subscribers-debuginfo
@llvm/pr-subscribers-llvm-binary-utilities
@llvm/pr-subscribers-mc

@llvm/pr-subscribers-backend-arm

Author: Jessica Clarke (jrtc27)

Changes

The .syntax unified directive and .codeX/.code X directives are, other
than some simple common printing code, exclusively implemented in the
targets themselves. Thus, remove the corresponding MCAF_* flags and
reimplement the directives solely within the targets. This avoids
exposing all targets to all other targets' flags.

Since MCAF_SubsectionsViaSymbols is all that remains, convert it to its
own function like other directives, simplifying its implementation.

Note that, on X86, we now always need a target streamer when parsing
assembly, as it's now used for directives that aren't COFF-specific. It
still does not however need to do anything when producing a non-COFF
object file, so this commit does not introduce any new target streamers.

There is some churn in test output, and corresponding UTC regex changes,
due to comments no longer being flushed by these various directives (and
EmitEOL is not exposed outside MCAsmStreamer.cpp so we couldn't do so
even if we wanted to), but that was a bit odd to be doing anyway.

This is motivated by Morello LLVM, which adds yet another assembler flag
to distinguish A64 and C64 instruction sets, but did not update every
switch and so emits warnings during the build. Rather than fix those
warnings it seems better to instead make the problem not exist in the
first place via this change.


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

38 Files Affected:

  • (modified) llvm/include/llvm/MC/MCAsmBackend.h (-3)
  • (modified) llvm/include/llvm/MC/MCAsmInfo.h (-10)
  • (modified) llvm/include/llvm/MC/MCDirectives.h (-8)
  • (modified) llvm/include/llvm/MC/MCELFStreamer.h (-1)
  • (modified) llvm/include/llvm/MC/MCStreamer.h (+7-2)
  • (modified) llvm/include/llvm/MC/MCWasmStreamer.h (-1)
  • (modified) llvm/include/llvm/MC/MCWinCOFFStreamer.h (-1)
  • (modified) llvm/lib/MC/MCAsmInfo.cpp (-3)
  • (modified) llvm/lib/MC/MCAsmStreamer.cpp (+3-10)
  • (modified) llvm/lib/MC/MCELFStreamer.cpp (-5)
  • (modified) llvm/lib/MC/MCMachOStreamer.cpp (+3-14)
  • (modified) llvm/lib/MC/MCNullStreamer.cpp (+1)
  • (modified) llvm/lib/MC/MCParser/DarwinAsmParser.cpp (+1-1)
  • (modified) llvm/lib/MC/MCStreamer.cpp (+4-1)
  • (modified) llvm/lib/MC/MCWasmStreamer.cpp (-8)
  • (modified) llvm/lib/MC/MCWinCOFFStreamer.cpp (-16)
  • (modified) llvm/lib/Object/RecordStreamer.h (+4-3)
  • (modified) llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp (+1-1)
  • (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp (-1)
  • (modified) llvm/lib/Target/ARM/ARMAsmPrinter.cpp (+17-9)
  • (modified) llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (+9-7)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp (+3-17)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h (+2-8)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h (+2-3)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendELF.h (+2-3)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendWinCOFF.h (+2-2)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp (+17-19)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMMCAsmInfo.cpp (-6)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp (+3)
  • (modified) llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp (+4-4)
  • (modified) llvm/lib/Target/X86/MCTargetDesc/X86TargetStreamer.h (+4)
  • (modified) llvm/lib/Target/X86/MCTargetDesc/X86WinCOFFTargetStreamer.cpp (+12-2)
  • (modified) llvm/lib/Target/X86/X86AsmPrinter.cpp (+6-3)
  • (modified) llvm/test/CodeGen/ARM/ldrd.ll (+6-6)
  • (modified) llvm/test/CodeGen/ARM/thumb-function-section-reloc.ll (+2-2)
  • (modified) llvm/test/CodeGen/Thumb/thumb-shrink-wrapping.ll (+8-8)
  • (modified) llvm/test/DebugInfo/ARM/header.ll (+2-2)
  • (modified) llvm/utils/UpdateTestChecks/asm.py (+11-5)
diff --git a/llvm/include/llvm/MC/MCAsmBackend.h b/llvm/include/llvm/MC/MCAsmBackend.h
index 691988ae1f1df..455812c0b10aa 100644
--- a/llvm/include/llvm/MC/MCAsmBackend.h
+++ b/llvm/include/llvm/MC/MCAsmBackend.h
@@ -213,9 +213,6 @@ class MCAsmBackend {
   /// Give backend an opportunity to finish layout after relaxation
   virtual void finishLayout(MCAssembler const &Asm) const {}
 
-  /// Handle any target-specific assembler flags. By default, do nothing.
-  virtual void handleAssemblerFlag(MCAssemblerFlag Flag) {}
-
   /// Generate the compact unwind encoding for the CFI instructions.
   virtual uint64_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
                                                  const MCContext *Ctxt) const {
diff --git a/llvm/include/llvm/MC/MCAsmInfo.h b/llvm/include/llvm/MC/MCAsmInfo.h
index 950dc952d0b44..3a31957f2f6be 100644
--- a/llvm/include/llvm/MC/MCAsmInfo.h
+++ b/llvm/include/llvm/MC/MCAsmInfo.h
@@ -166,13 +166,6 @@ class MCAsmInfo {
   const char *InlineAsmStart;
   const char *InlineAsmEnd;
 
-  /// These are assembly directives that tells the assembler to interpret the
-  /// following instructions differently.  Defaults to ".code16", ".code32",
-  /// ".code64".
-  const char *Code16Directive;
-  const char *Code32Directive;
-  const char *Code64Directive;
-
   /// Which dialect of an assembler variant to use.  Defaults to 0
   unsigned AssemblerDialect = 0;
 
@@ -544,9 +537,6 @@ class MCAsmInfo {
 
   const char *getInlineAsmStart() const { return InlineAsmStart; }
   const char *getInlineAsmEnd() const { return InlineAsmEnd; }
-  const char *getCode16Directive() const { return Code16Directive; }
-  const char *getCode32Directive() const { return Code32Directive; }
-  const char *getCode64Directive() const { return Code64Directive; }
   unsigned getAssemblerDialect() const { return AssemblerDialect; }
   bool doesAllowAtInName() const { return AllowAtInName; }
   void setAllowAtInName(bool V) { AllowAtInName = V; }
diff --git a/llvm/include/llvm/MC/MCDirectives.h b/llvm/include/llvm/MC/MCDirectives.h
index fcab56ff0a740..f8b7e05b3719b 100644
--- a/llvm/include/llvm/MC/MCDirectives.h
+++ b/llvm/include/llvm/MC/MCDirectives.h
@@ -50,14 +50,6 @@ enum MCSymbolAttr {
   MCSA_Memtag,                  ///< .memtag (ELF)
 };
 
-enum MCAssemblerFlag {
-  MCAF_SyntaxUnified,         ///< .syntax (ARM/ELF)
-  MCAF_SubsectionsViaSymbols, ///< .subsections_via_symbols (MachO)
-  MCAF_Code16,                ///< .code16 (X86) / .code 16 (ARM)
-  MCAF_Code32,                ///< .code32 (X86) / .code 32 (ARM)
-  MCAF_Code64                 ///< .code64 (X86)
-};
-
 enum MCDataRegionType {
   MCDR_DataRegion,            ///< .data_region
   MCDR_DataRegionJT8,         ///< .data_region jt8
diff --git a/llvm/include/llvm/MC/MCELFStreamer.h b/llvm/include/llvm/MC/MCELFStreamer.h
index f084268aad181..f00b1645347f1 100644
--- a/llvm/include/llvm/MC/MCELFStreamer.h
+++ b/llvm/include/llvm/MC/MCELFStreamer.h
@@ -53,7 +53,6 @@ class MCELFStreamer : public MCObjectStreamer {
   void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
   void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCDataFragment &F,
                       uint64_t Offset) override;
-  void emitAssemblerFlag(MCAssemblerFlag Flag) override;
   void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
   bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
   void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h
index beed370858d78..1f5014843c5da 100644
--- a/llvm/include/llvm/MC/MCStreamer.h
+++ b/llvm/include/llvm/MC/MCStreamer.h
@@ -169,6 +169,11 @@ class ARMTargetStreamer : public MCTargetStreamer {
 
   virtual void annotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE);
 
+  virtual void emitSyntaxUnified();
+
+  virtual void emitCode16();
+  virtual void emitCode32();
+
   // Note in the output that the specified \p Symbol is a Thumb mode function.
   virtual void emitThumbFunc(MCSymbol *Symbol);
   virtual void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value);
@@ -471,8 +476,8 @@ class MCStreamer {
 
   virtual void emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol);
 
-  /// Note in the output the specified \p Flag.
-  virtual void emitAssemblerFlag(MCAssemblerFlag Flag);
+  /// Emit a .subsection_via_symbols directive.
+  virtual void emitSubsectionsViaSymbols();
 
   /// Emit the given list \p Options of strings as linker
   /// options into the output.
diff --git a/llvm/include/llvm/MC/MCWasmStreamer.h b/llvm/include/llvm/MC/MCWasmStreamer.h
index 02fda9635f1f8..1b97e765fdf48 100644
--- a/llvm/include/llvm/MC/MCWasmStreamer.h
+++ b/llvm/include/llvm/MC/MCWasmStreamer.h
@@ -44,7 +44,6 @@ class MCWasmStreamer : public MCObjectStreamer {
   void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
   void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCDataFragment &F,
                       uint64_t Offset) override;
-  void emitAssemblerFlag(MCAssemblerFlag Flag) override;
   void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
   bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
   void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
diff --git a/llvm/include/llvm/MC/MCWinCOFFStreamer.h b/llvm/include/llvm/MC/MCWinCOFFStreamer.h
index bc01362b779b5..b474ececb21d6 100644
--- a/llvm/include/llvm/MC/MCWinCOFFStreamer.h
+++ b/llvm/include/llvm/MC/MCWinCOFFStreamer.h
@@ -45,7 +45,6 @@ class MCWinCOFFStreamer : public MCObjectStreamer {
   void initSections(bool NoExecStack, const MCSubtargetInfo &STI) override;
   void changeSection(MCSection *Section, uint32_t Subsection = 0) override;
   void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
-  void emitAssemblerFlag(MCAssemblerFlag Flag) override;
   bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
   void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
   void beginCOFFSymbolDef(MCSymbol const *Symbol) override;
diff --git a/llvm/lib/MC/MCAsmInfo.cpp b/llvm/lib/MC/MCAsmInfo.cpp
index 49e8db209102b..86759c32bb752 100644
--- a/llvm/lib/MC/MCAsmInfo.cpp
+++ b/llvm/lib/MC/MCAsmInfo.cpp
@@ -48,9 +48,6 @@ MCAsmInfo::MCAsmInfo() {
   LinkerPrivateGlobalPrefix = "";
   InlineAsmStart = "APP";
   InlineAsmEnd = "NO_APP";
-  Code16Directive = ".code16";
-  Code32Directive = ".code32";
-  Code64Directive = ".code64";
   ZeroDirective = "\t.zero\t";
   AsciiDirective = "\t.ascii\t";
   AscizDirective = "\t.asciz\t";
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index 42e62459d9730..f670335045cb1 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -182,7 +182,7 @@ class MCAsmStreamer final : public MCStreamer {
 
   void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
 
-  void emitAssemblerFlag(MCAssemblerFlag Flag) override;
+  void emitSubsectionsViaSymbols() override;
   void emitLinkerOptions(ArrayRef<std::string> Options) override;
   void emitDataRegion(MCDataRegionType Kind) override;
   void emitVersionMin(MCVersionMinType Kind, unsigned Major, unsigned Minor,
@@ -597,15 +597,8 @@ void MCAsmStreamer::emitGNUAttribute(unsigned Tag, unsigned Value) {
   OS << "\t.gnu_attribute " << Tag << ", " << Value << "\n";
 }
 
-void MCAsmStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
-  switch (Flag) {
-  case MCAF_SyntaxUnified:         OS << "\t.syntax unified"; break;
-  case MCAF_SubsectionsViaSymbols: OS << ".subsections_via_symbols"; break;
-  case MCAF_Code16:                OS << '\t'<< MAI->getCode16Directive();break;
-  case MCAF_Code32:                OS << '\t'<< MAI->getCode32Directive();break;
-  case MCAF_Code64:                OS << '\t'<< MAI->getCode64Directive();break;
-  }
-  EmitEOL();
+void MCAsmStreamer::emitSubsectionsViaSymbols() {
+  OS << ".subsections_via_symbols\n";
 }
 
 void MCAsmStreamer::emitLinkerOptions(ArrayRef<std::string> Options) {
diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp
index 5cf67f018b452..7006ac9dda7c2 100644
--- a/llvm/lib/MC/MCELFStreamer.cpp
+++ b/llvm/lib/MC/MCELFStreamer.cpp
@@ -84,11 +84,6 @@ void MCELFStreamer::emitLabelAtPos(MCSymbol *S, SMLoc Loc, MCDataFragment &F,
     Symbol->setType(ELF::STT_TLS);
 }
 
-void MCELFStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
-  // Let the target do whatever target specific stuff it needs to do.
-  getAssembler().getBackend().handleAssemblerFlag(Flag);
-}
-
 // If bundle alignment is used and there are any instructions in the section, it
 // needs to be aligned to at least the bundle size.
 static void setSectionAlignmentForBundling(const MCAssembler &Assembler,
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index 9b7152f561175..4cf602b7e4563 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -89,7 +89,7 @@ class MCMachOStreamer : public MCObjectStreamer {
   void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
   void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
   void emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol) override;
-  void emitAssemblerFlag(MCAssemblerFlag Flag) override;
+  void emitSubsectionsViaSymbols() override;
   void emitLinkerOptions(ArrayRef<std::string> Options) override;
   void emitDataRegion(MCDataRegionType Kind) override;
   void emitVersionMin(MCVersionMinType Kind, unsigned Major, unsigned Minor,
@@ -209,19 +209,8 @@ void MCMachOStreamer::emitDataRegionEnd() {
   emitLabel(Data.End);
 }
 
-void MCMachOStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
-  // Let the target do whatever target specific stuff it needs to do.
-  getAssembler().getBackend().handleAssemblerFlag(Flag);
-  // Do any generic stuff we need to do.
-  switch (Flag) {
-  case MCAF_SyntaxUnified: return; // no-op here.
-  case MCAF_Code16: return; // Change parsing mode; no-op here.
-  case MCAF_Code32: return; // Change parsing mode; no-op here.
-  case MCAF_Code64: return; // Change parsing mode; no-op here.
-  case MCAF_SubsectionsViaSymbols:
-    getWriter().setSubsectionsViaSymbols(true);
-    return;
-  }
+void MCMachOStreamer::emitSubsectionsViaSymbols() {
+  getWriter().setSubsectionsViaSymbols(true);
 }
 
 void MCMachOStreamer::emitLinkerOptions(ArrayRef<std::string> Options) {
diff --git a/llvm/lib/MC/MCNullStreamer.cpp b/llvm/lib/MC/MCNullStreamer.cpp
index e84830eb20a72..f76b2f754b189 100644
--- a/llvm/lib/MC/MCNullStreamer.cpp
+++ b/llvm/lib/MC/MCNullStreamer.cpp
@@ -38,6 +38,7 @@ namespace {
 
     void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
                           Align ByteAlignment) override {}
+    void emitSubsectionsViaSymbols() override {};
     void beginCOFFSymbolDef(const MCSymbol *Symbol) override {}
     void emitCOFFSymbolStorageClass(int StorageClass) override {}
     void emitCOFFSymbolType(int Type) override {}
diff --git a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
index 5dc9cb64c46ae..de134e25e842f 100644
--- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
@@ -817,7 +817,7 @@ bool DarwinAsmParser::parseDirectiveSubsectionsViaSymbols(StringRef, SMLoc) {
 
   Lex();
 
-  getStreamer().emitAssemblerFlag(MCAF_SubsectionsViaSymbols);
+  getStreamer().emitSubsectionsViaSymbols();
 
   return false;
 }
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index a1968423a1250..618a35b9596aa 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -1245,7 +1245,10 @@ void MCStreamer::emitAbsoluteSymbolDiffAsULEB128(const MCSymbol *Hi,
   emitULEB128Value(Diff);
 }
 
-void MCStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {}
+void MCStreamer::emitSubsectionsViaSymbols() {
+  llvm_unreachable(
+      "emitSubsectionsViaSymbols only supported on Mach-O targets");
+}
 void MCStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
 void MCStreamer::beginCOFFSymbolDef(const MCSymbol *Symbol) {
   llvm_unreachable("this directive only supported on COFF targets");
diff --git a/llvm/lib/MC/MCWasmStreamer.cpp b/llvm/lib/MC/MCWasmStreamer.cpp
index cddd250cc0005..9920ff9106fca 100644
--- a/llvm/lib/MC/MCWasmStreamer.cpp
+++ b/llvm/lib/MC/MCWasmStreamer.cpp
@@ -59,14 +59,6 @@ void MCWasmStreamer::emitLabelAtPos(MCSymbol *S, SMLoc Loc, MCDataFragment &F,
     Symbol->setTLS();
 }
 
-void MCWasmStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
-  // Let the target do whatever target specific stuff it needs to do.
-  getAssembler().getBackend().handleAssemblerFlag(Flag);
-
-  // Do any generic stuff we need to do.
-  llvm_unreachable("invalid assembler flag!");
-}
-
 void MCWasmStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
   MCAssembler &Asm = getAssembler();
   auto *SectionWasm = cast<MCSectionWasm>(Section);
diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp b/llvm/lib/MC/MCWinCOFFStreamer.cpp
index e03f7b5b6d418..ee7a7c87eb22f 100644
--- a/llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -184,22 +184,6 @@ void MCWinCOFFStreamer::emitLabel(MCSymbol *S, SMLoc Loc) {
   MCObjectStreamer::emitLabel(Symbol, Loc);
 }
 
-void MCWinCOFFStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
-  // Let the target do whatever target specific stuff it needs to do.
-  getAssembler().getBackend().handleAssemblerFlag(Flag);
-
-  switch (Flag) {
-  // None of these require COFF specific handling.
-  case MCAF_SyntaxUnified:
-  case MCAF_Code16:
-  case MCAF_Code32:
-  case MCAF_Code64:
-    break;
-  case MCAF_SubsectionsViaSymbols:
-    llvm_unreachable("COFF doesn't support .subsections_via_symbols");
-  }
-}
-
 bool MCWinCOFFStreamer::emitSymbolAttribute(MCSymbol *S,
                                             MCSymbolAttr Attribute) {
   auto *Symbol = cast<MCSymbolCOFF>(S);
diff --git a/llvm/lib/Object/RecordStreamer.h b/llvm/lib/Object/RecordStreamer.h
index d9ef27c790168..edb6e3ae118bf 100644
--- a/llvm/lib/Object/RecordStreamer.h
+++ b/llvm/lib/Object/RecordStreamer.h
@@ -54,9 +54,10 @@ class RecordStreamer : public MCStreamer {
   void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
                         Align ByteAlignment) override;
 
-  // Ignore COFF-specific directives; we do not need any information from them,
-  // but the default implementation of these methods crashes, so we override
-  // them with versions that do nothing.
+  // Ignore format-specific directives; we do not need any information from
+  // them, but the default implementation of these methods crashes, so we
+  // override them with versions that do nothing.
+  void emitSubsectionsViaSymbols() override {};
   void beginCOFFSymbolDef(const MCSymbol *Symbol) override {}
   void emitCOFFSymbolStorageClass(int StorageClass) override {}
   void emitCOFFSymbolType(int Type) override {}
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index a53606851d0a2..d8422f488870e 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -961,7 +961,7 @@ void AArch64AsmPrinter::emitEndOfAsmFile(Module &M) {
     // implementation of multiple entry points).  If this doesn't occur, the
     // linker can safely perform dead code stripping.  Since LLVM never
     // generates code that does this, it is always safe to set.
-    OutStreamer->emitAssemblerFlag(MCAF_SubsectionsViaSymbols);
+    OutStreamer->emitSubsectionsViaSymbols();
   }
 
   if (TT.isOSBinFormatELF()) {
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp
index 83daa836e650d..e8a88f7f31401 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp
@@ -108,7 +108,6 @@ AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(const Triple &T) {
   CommentString = "//";
   PrivateGlobalPrefix = ".L";
   PrivateLabelPrefix = ".L";
-  Code32Directive = ".code\t32";
 
   Data16bitsDirective = "\t.hword\t";
   Data32bitsDirective = "\t.word\t";
diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
index 2505a67727aad..13efd70c0f22b 100644
--- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
+++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
@@ -66,10 +66,10 @@ void ARMAsmPrinter::emitFunctionEntryLabel() {
   auto &TS =
       static_cast<ARMTargetStreamer &>(*OutStreamer->getTargetStreamer());
   if (AFI->isThumbFunction()) {
-    OutStreamer->emitAssemblerFlag(MCAF_Code16);
+    TS.emitCode16();
     TS.emitThumbFunc(CurrentFnSym);
   } else {
-    OutStreamer->emitAssemblerFlag(MCAF_Code32);
+    TS.emitCode32();
   }
 
   // Emit symbol for CMSE non-secure entry point
@@ -171,7 +171,9 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   // These are created per function, rather than per TU, since it's
   // relatively easy to exceed the thumb branch range within a TU.
   if (! ThumbIndirectPads.empty()) {
-    OutStreamer->emitAssemblerFlag(MCAF_Code16);
+    auto &TS =
+        static_cast<ARMTargetStreamer &>(*OutStreamer->getTargetStreamer());
+    TS.emitCode16();
     emitAlignment(Align(2));
     for (std::pair<unsigned, MCSymbol *> &TIP : ThumbIndirectPads) {
       OutStreamer->emitLabel(TIP.second);
@@ -489,24 +491,30 @@ void ARMAsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
   // the start mode, then restore the start mode.
   const bool WasThumb = isThumb(StartInfo);
   if (!EndInfo || WasThumb != isThumb(*EndInfo)) {
-    OutStreamer->emitAssemblerFlag(WasThumb ? MCAF_Code16 : MCAF_Code32);
+    auto &TS =
+        static_cast<ARMTargetStreamer &>(*OutStreamer->getTargetStreamer());
+    if (WasThumb)
+      TS.emitCode16();
+    else
+      TS.emitCode32();
   }
 }
 
 void ARMAsmPrinter::emitStartOfAsmFile(Module &M) {
   const Triple &TT = TM.getTargetTriple();
+  auto &TS =
+      static_cast<ARMTargetStreamer &>(*OutStreamer->getTargetStreamer());
   // Use unified assembler syntax.
-  OutStreamer->emitAssemblerFlag(MCAF_SyntaxUnified);
+  TS.emitSyntaxUnified();
 
   // Emit ARM Build Attributes
   if (TT.isOSBinFormatELF())
     emitAttributes();
 
   // Use the triple's architecture and subarchitecture to determine
-  // if we're thumb for the purposes of the top level code16 assembler
-  // flag.
+  // if we're thumb for the purposes of the top level code16 state.
   if (!M.getModuleInlineAsm().empty() && TT.isThumb())
-    OutStreamer->emitAssemblerFlag(MCAF_Code16);
+    TS.emitCode16();
 }
 
 static void
@@ -575,7 +583,7 @@ void ARMAsmPrinter::emitEndOfAsmFile(Module &M) {
     // implementation of multiple entry points).  If this doesn't occur, the
     // linker can safely perform dead code stripping.  Since LLVM never
     // generates code that does this, it is always safe to set.
-    OutStreamer->emitAssemblerFlag(MCAF_SubsectionsViaSymbols);
+    OutStreamer->emitSubsectionsViaSymbols();
   }
 
   // The last attribute to be emitted is ABI_optimization_goals
diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
index 48ad8a8994ae8..85b107c6085d3 100644
--- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -11654,7 +11654,7 @@ bool ARMAsmParser::parseDirectiveThumb(SMLoc L) {
   if (!isThumb())
     SwitchMode();
 
-  getParser().getStreamer().emitAssemblerFlag(MCAF_Code16);
+  getTargetStreamer().emitCode16();
   getParser().getStreamer().emitCodeAlignment(Align(2), &getSTI(), 0);
   return false;
 }
@@ -11667,7 +11667,7 @@ bool ARMAsmParser::parseDirectiveARM(SMLoc L) {
 
   if (isThumb())
     SwitchMode();
-  getParser().getStreamer().emitAssemblerFlag(MCAF_Code32);
+  getTargetStreamer().emitCode32();
   getParser().getStreamer().emitCodeAlignment(Align(4), &getSTI(), 0);
   return false;
 }
@@ -11715,7 +11715,7 @@ bool ARMAsmParser::parseDirectiveThumbFunc(SMLoc L) {
   if (!isThumb())
     SwitchMode();
 
-  getParser().getStreamer().emitAssemblerFlag(MCAF_Code16);
+  getTargetStreamer().emitCode16();
 
   NextSymbolIsThumb = true;
   return false;
@@ -11768,14 +11768,14 @@ bool ARMAsmParser::parseDirectiveCode(SMLoc L) {
 
     i...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented May 14, 2025

@llvm/pr-subscribers-backend-x86

Author: Jessica Clarke (jrtc27)

Changes

The .syntax unified directive and .codeX/.code X directives are, other
than some simple common printing code, exclusively implemented in the
targets themselves. Thus, remove the corresponding MCAF_* flags and
reimplement the directives solely within the targets. This avoids
exposing all targets to all other targets' flags.

Since MCAF_SubsectionsViaSymbols is all that remains, convert it to its
own function like other directives, simplifying its implementation.

Note that, on X86, we now always need a target streamer when parsing
assembly, as it's now used for directives that aren't COFF-specific. It
still does not however need to do anything when producing a non-COFF
object file, so this commit does not introduce any new target streamers.

There is some churn in test output, and corresponding UTC regex changes,
due to comments no longer being flushed by these various directives (and
EmitEOL is not exposed outside MCAsmStreamer.cpp so we couldn't do so
even if we wanted to), but that was a bit odd to be doing anyway.

This is motivated by Morello LLVM, which adds yet another assembler flag
to distinguish A64 and C64 instruction sets, but did not update every
switch and so emits warnings during the build. Rather than fix those
warnings it seems better to instead make the problem not exist in the
first place via this change.


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

38 Files Affected:

  • (modified) llvm/include/llvm/MC/MCAsmBackend.h (-3)
  • (modified) llvm/include/llvm/MC/MCAsmInfo.h (-10)
  • (modified) llvm/include/llvm/MC/MCDirectives.h (-8)
  • (modified) llvm/include/llvm/MC/MCELFStreamer.h (-1)
  • (modified) llvm/include/llvm/MC/MCStreamer.h (+7-2)
  • (modified) llvm/include/llvm/MC/MCWasmStreamer.h (-1)
  • (modified) llvm/include/llvm/MC/MCWinCOFFStreamer.h (-1)
  • (modified) llvm/lib/MC/MCAsmInfo.cpp (-3)
  • (modified) llvm/lib/MC/MCAsmStreamer.cpp (+3-10)
  • (modified) llvm/lib/MC/MCELFStreamer.cpp (-5)
  • (modified) llvm/lib/MC/MCMachOStreamer.cpp (+3-14)
  • (modified) llvm/lib/MC/MCNullStreamer.cpp (+1)
  • (modified) llvm/lib/MC/MCParser/DarwinAsmParser.cpp (+1-1)
  • (modified) llvm/lib/MC/MCStreamer.cpp (+4-1)
  • (modified) llvm/lib/MC/MCWasmStreamer.cpp (-8)
  • (modified) llvm/lib/MC/MCWinCOFFStreamer.cpp (-16)
  • (modified) llvm/lib/Object/RecordStreamer.h (+4-3)
  • (modified) llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp (+1-1)
  • (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp (-1)
  • (modified) llvm/lib/Target/ARM/ARMAsmPrinter.cpp (+17-9)
  • (modified) llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (+9-7)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp (+3-17)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h (+2-8)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h (+2-3)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendELF.h (+2-3)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendWinCOFF.h (+2-2)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp (+17-19)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMMCAsmInfo.cpp (-6)
  • (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp (+3)
  • (modified) llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp (+4-4)
  • (modified) llvm/lib/Target/X86/MCTargetDesc/X86TargetStreamer.h (+4)
  • (modified) llvm/lib/Target/X86/MCTargetDesc/X86WinCOFFTargetStreamer.cpp (+12-2)
  • (modified) llvm/lib/Target/X86/X86AsmPrinter.cpp (+6-3)
  • (modified) llvm/test/CodeGen/ARM/ldrd.ll (+6-6)
  • (modified) llvm/test/CodeGen/ARM/thumb-function-section-reloc.ll (+2-2)
  • (modified) llvm/test/CodeGen/Thumb/thumb-shrink-wrapping.ll (+8-8)
  • (modified) llvm/test/DebugInfo/ARM/header.ll (+2-2)
  • (modified) llvm/utils/UpdateTestChecks/asm.py (+11-5)
diff --git a/llvm/include/llvm/MC/MCAsmBackend.h b/llvm/include/llvm/MC/MCAsmBackend.h
index 691988ae1f1df..455812c0b10aa 100644
--- a/llvm/include/llvm/MC/MCAsmBackend.h
+++ b/llvm/include/llvm/MC/MCAsmBackend.h
@@ -213,9 +213,6 @@ class MCAsmBackend {
   /// Give backend an opportunity to finish layout after relaxation
   virtual void finishLayout(MCAssembler const &Asm) const {}
 
-  /// Handle any target-specific assembler flags. By default, do nothing.
-  virtual void handleAssemblerFlag(MCAssemblerFlag Flag) {}
-
   /// Generate the compact unwind encoding for the CFI instructions.
   virtual uint64_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
                                                  const MCContext *Ctxt) const {
diff --git a/llvm/include/llvm/MC/MCAsmInfo.h b/llvm/include/llvm/MC/MCAsmInfo.h
index 950dc952d0b44..3a31957f2f6be 100644
--- a/llvm/include/llvm/MC/MCAsmInfo.h
+++ b/llvm/include/llvm/MC/MCAsmInfo.h
@@ -166,13 +166,6 @@ class MCAsmInfo {
   const char *InlineAsmStart;
   const char *InlineAsmEnd;
 
-  /// These are assembly directives that tells the assembler to interpret the
-  /// following instructions differently.  Defaults to ".code16", ".code32",
-  /// ".code64".
-  const char *Code16Directive;
-  const char *Code32Directive;
-  const char *Code64Directive;
-
   /// Which dialect of an assembler variant to use.  Defaults to 0
   unsigned AssemblerDialect = 0;
 
@@ -544,9 +537,6 @@ class MCAsmInfo {
 
   const char *getInlineAsmStart() const { return InlineAsmStart; }
   const char *getInlineAsmEnd() const { return InlineAsmEnd; }
-  const char *getCode16Directive() const { return Code16Directive; }
-  const char *getCode32Directive() const { return Code32Directive; }
-  const char *getCode64Directive() const { return Code64Directive; }
   unsigned getAssemblerDialect() const { return AssemblerDialect; }
   bool doesAllowAtInName() const { return AllowAtInName; }
   void setAllowAtInName(bool V) { AllowAtInName = V; }
diff --git a/llvm/include/llvm/MC/MCDirectives.h b/llvm/include/llvm/MC/MCDirectives.h
index fcab56ff0a740..f8b7e05b3719b 100644
--- a/llvm/include/llvm/MC/MCDirectives.h
+++ b/llvm/include/llvm/MC/MCDirectives.h
@@ -50,14 +50,6 @@ enum MCSymbolAttr {
   MCSA_Memtag,                  ///< .memtag (ELF)
 };
 
-enum MCAssemblerFlag {
-  MCAF_SyntaxUnified,         ///< .syntax (ARM/ELF)
-  MCAF_SubsectionsViaSymbols, ///< .subsections_via_symbols (MachO)
-  MCAF_Code16,                ///< .code16 (X86) / .code 16 (ARM)
-  MCAF_Code32,                ///< .code32 (X86) / .code 32 (ARM)
-  MCAF_Code64                 ///< .code64 (X86)
-};
-
 enum MCDataRegionType {
   MCDR_DataRegion,            ///< .data_region
   MCDR_DataRegionJT8,         ///< .data_region jt8
diff --git a/llvm/include/llvm/MC/MCELFStreamer.h b/llvm/include/llvm/MC/MCELFStreamer.h
index f084268aad181..f00b1645347f1 100644
--- a/llvm/include/llvm/MC/MCELFStreamer.h
+++ b/llvm/include/llvm/MC/MCELFStreamer.h
@@ -53,7 +53,6 @@ class MCELFStreamer : public MCObjectStreamer {
   void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
   void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCDataFragment &F,
                       uint64_t Offset) override;
-  void emitAssemblerFlag(MCAssemblerFlag Flag) override;
   void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
   bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
   void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h
index beed370858d78..1f5014843c5da 100644
--- a/llvm/include/llvm/MC/MCStreamer.h
+++ b/llvm/include/llvm/MC/MCStreamer.h
@@ -169,6 +169,11 @@ class ARMTargetStreamer : public MCTargetStreamer {
 
   virtual void annotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE);
 
+  virtual void emitSyntaxUnified();
+
+  virtual void emitCode16();
+  virtual void emitCode32();
+
   // Note in the output that the specified \p Symbol is a Thumb mode function.
   virtual void emitThumbFunc(MCSymbol *Symbol);
   virtual void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value);
@@ -471,8 +476,8 @@ class MCStreamer {
 
   virtual void emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol);
 
-  /// Note in the output the specified \p Flag.
-  virtual void emitAssemblerFlag(MCAssemblerFlag Flag);
+  /// Emit a .subsection_via_symbols directive.
+  virtual void emitSubsectionsViaSymbols();
 
   /// Emit the given list \p Options of strings as linker
   /// options into the output.
diff --git a/llvm/include/llvm/MC/MCWasmStreamer.h b/llvm/include/llvm/MC/MCWasmStreamer.h
index 02fda9635f1f8..1b97e765fdf48 100644
--- a/llvm/include/llvm/MC/MCWasmStreamer.h
+++ b/llvm/include/llvm/MC/MCWasmStreamer.h
@@ -44,7 +44,6 @@ class MCWasmStreamer : public MCObjectStreamer {
   void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
   void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCDataFragment &F,
                       uint64_t Offset) override;
-  void emitAssemblerFlag(MCAssemblerFlag Flag) override;
   void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
   bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
   void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
diff --git a/llvm/include/llvm/MC/MCWinCOFFStreamer.h b/llvm/include/llvm/MC/MCWinCOFFStreamer.h
index bc01362b779b5..b474ececb21d6 100644
--- a/llvm/include/llvm/MC/MCWinCOFFStreamer.h
+++ b/llvm/include/llvm/MC/MCWinCOFFStreamer.h
@@ -45,7 +45,6 @@ class MCWinCOFFStreamer : public MCObjectStreamer {
   void initSections(bool NoExecStack, const MCSubtargetInfo &STI) override;
   void changeSection(MCSection *Section, uint32_t Subsection = 0) override;
   void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
-  void emitAssemblerFlag(MCAssemblerFlag Flag) override;
   bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
   void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
   void beginCOFFSymbolDef(MCSymbol const *Symbol) override;
diff --git a/llvm/lib/MC/MCAsmInfo.cpp b/llvm/lib/MC/MCAsmInfo.cpp
index 49e8db209102b..86759c32bb752 100644
--- a/llvm/lib/MC/MCAsmInfo.cpp
+++ b/llvm/lib/MC/MCAsmInfo.cpp
@@ -48,9 +48,6 @@ MCAsmInfo::MCAsmInfo() {
   LinkerPrivateGlobalPrefix = "";
   InlineAsmStart = "APP";
   InlineAsmEnd = "NO_APP";
-  Code16Directive = ".code16";
-  Code32Directive = ".code32";
-  Code64Directive = ".code64";
   ZeroDirective = "\t.zero\t";
   AsciiDirective = "\t.ascii\t";
   AscizDirective = "\t.asciz\t";
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index 42e62459d9730..f670335045cb1 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -182,7 +182,7 @@ class MCAsmStreamer final : public MCStreamer {
 
   void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
 
-  void emitAssemblerFlag(MCAssemblerFlag Flag) override;
+  void emitSubsectionsViaSymbols() override;
   void emitLinkerOptions(ArrayRef<std::string> Options) override;
   void emitDataRegion(MCDataRegionType Kind) override;
   void emitVersionMin(MCVersionMinType Kind, unsigned Major, unsigned Minor,
@@ -597,15 +597,8 @@ void MCAsmStreamer::emitGNUAttribute(unsigned Tag, unsigned Value) {
   OS << "\t.gnu_attribute " << Tag << ", " << Value << "\n";
 }
 
-void MCAsmStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
-  switch (Flag) {
-  case MCAF_SyntaxUnified:         OS << "\t.syntax unified"; break;
-  case MCAF_SubsectionsViaSymbols: OS << ".subsections_via_symbols"; break;
-  case MCAF_Code16:                OS << '\t'<< MAI->getCode16Directive();break;
-  case MCAF_Code32:                OS << '\t'<< MAI->getCode32Directive();break;
-  case MCAF_Code64:                OS << '\t'<< MAI->getCode64Directive();break;
-  }
-  EmitEOL();
+void MCAsmStreamer::emitSubsectionsViaSymbols() {
+  OS << ".subsections_via_symbols\n";
 }
 
 void MCAsmStreamer::emitLinkerOptions(ArrayRef<std::string> Options) {
diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp
index 5cf67f018b452..7006ac9dda7c2 100644
--- a/llvm/lib/MC/MCELFStreamer.cpp
+++ b/llvm/lib/MC/MCELFStreamer.cpp
@@ -84,11 +84,6 @@ void MCELFStreamer::emitLabelAtPos(MCSymbol *S, SMLoc Loc, MCDataFragment &F,
     Symbol->setType(ELF::STT_TLS);
 }
 
-void MCELFStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
-  // Let the target do whatever target specific stuff it needs to do.
-  getAssembler().getBackend().handleAssemblerFlag(Flag);
-}
-
 // If bundle alignment is used and there are any instructions in the section, it
 // needs to be aligned to at least the bundle size.
 static void setSectionAlignmentForBundling(const MCAssembler &Assembler,
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index 9b7152f561175..4cf602b7e4563 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -89,7 +89,7 @@ class MCMachOStreamer : public MCObjectStreamer {
   void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
   void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
   void emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol) override;
-  void emitAssemblerFlag(MCAssemblerFlag Flag) override;
+  void emitSubsectionsViaSymbols() override;
   void emitLinkerOptions(ArrayRef<std::string> Options) override;
   void emitDataRegion(MCDataRegionType Kind) override;
   void emitVersionMin(MCVersionMinType Kind, unsigned Major, unsigned Minor,
@@ -209,19 +209,8 @@ void MCMachOStreamer::emitDataRegionEnd() {
   emitLabel(Data.End);
 }
 
-void MCMachOStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
-  // Let the target do whatever target specific stuff it needs to do.
-  getAssembler().getBackend().handleAssemblerFlag(Flag);
-  // Do any generic stuff we need to do.
-  switch (Flag) {
-  case MCAF_SyntaxUnified: return; // no-op here.
-  case MCAF_Code16: return; // Change parsing mode; no-op here.
-  case MCAF_Code32: return; // Change parsing mode; no-op here.
-  case MCAF_Code64: return; // Change parsing mode; no-op here.
-  case MCAF_SubsectionsViaSymbols:
-    getWriter().setSubsectionsViaSymbols(true);
-    return;
-  }
+void MCMachOStreamer::emitSubsectionsViaSymbols() {
+  getWriter().setSubsectionsViaSymbols(true);
 }
 
 void MCMachOStreamer::emitLinkerOptions(ArrayRef<std::string> Options) {
diff --git a/llvm/lib/MC/MCNullStreamer.cpp b/llvm/lib/MC/MCNullStreamer.cpp
index e84830eb20a72..f76b2f754b189 100644
--- a/llvm/lib/MC/MCNullStreamer.cpp
+++ b/llvm/lib/MC/MCNullStreamer.cpp
@@ -38,6 +38,7 @@ namespace {
 
     void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
                           Align ByteAlignment) override {}
+    void emitSubsectionsViaSymbols() override {};
     void beginCOFFSymbolDef(const MCSymbol *Symbol) override {}
     void emitCOFFSymbolStorageClass(int StorageClass) override {}
     void emitCOFFSymbolType(int Type) override {}
diff --git a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
index 5dc9cb64c46ae..de134e25e842f 100644
--- a/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/DarwinAsmParser.cpp
@@ -817,7 +817,7 @@ bool DarwinAsmParser::parseDirectiveSubsectionsViaSymbols(StringRef, SMLoc) {
 
   Lex();
 
-  getStreamer().emitAssemblerFlag(MCAF_SubsectionsViaSymbols);
+  getStreamer().emitSubsectionsViaSymbols();
 
   return false;
 }
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index a1968423a1250..618a35b9596aa 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -1245,7 +1245,10 @@ void MCStreamer::emitAbsoluteSymbolDiffAsULEB128(const MCSymbol *Hi,
   emitULEB128Value(Diff);
 }
 
-void MCStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {}
+void MCStreamer::emitSubsectionsViaSymbols() {
+  llvm_unreachable(
+      "emitSubsectionsViaSymbols only supported on Mach-O targets");
+}
 void MCStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
 void MCStreamer::beginCOFFSymbolDef(const MCSymbol *Symbol) {
   llvm_unreachable("this directive only supported on COFF targets");
diff --git a/llvm/lib/MC/MCWasmStreamer.cpp b/llvm/lib/MC/MCWasmStreamer.cpp
index cddd250cc0005..9920ff9106fca 100644
--- a/llvm/lib/MC/MCWasmStreamer.cpp
+++ b/llvm/lib/MC/MCWasmStreamer.cpp
@@ -59,14 +59,6 @@ void MCWasmStreamer::emitLabelAtPos(MCSymbol *S, SMLoc Loc, MCDataFragment &F,
     Symbol->setTLS();
 }
 
-void MCWasmStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
-  // Let the target do whatever target specific stuff it needs to do.
-  getAssembler().getBackend().handleAssemblerFlag(Flag);
-
-  // Do any generic stuff we need to do.
-  llvm_unreachable("invalid assembler flag!");
-}
-
 void MCWasmStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
   MCAssembler &Asm = getAssembler();
   auto *SectionWasm = cast<MCSectionWasm>(Section);
diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp b/llvm/lib/MC/MCWinCOFFStreamer.cpp
index e03f7b5b6d418..ee7a7c87eb22f 100644
--- a/llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -184,22 +184,6 @@ void MCWinCOFFStreamer::emitLabel(MCSymbol *S, SMLoc Loc) {
   MCObjectStreamer::emitLabel(Symbol, Loc);
 }
 
-void MCWinCOFFStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
-  // Let the target do whatever target specific stuff it needs to do.
-  getAssembler().getBackend().handleAssemblerFlag(Flag);
-
-  switch (Flag) {
-  // None of these require COFF specific handling.
-  case MCAF_SyntaxUnified:
-  case MCAF_Code16:
-  case MCAF_Code32:
-  case MCAF_Code64:
-    break;
-  case MCAF_SubsectionsViaSymbols:
-    llvm_unreachable("COFF doesn't support .subsections_via_symbols");
-  }
-}
-
 bool MCWinCOFFStreamer::emitSymbolAttribute(MCSymbol *S,
                                             MCSymbolAttr Attribute) {
   auto *Symbol = cast<MCSymbolCOFF>(S);
diff --git a/llvm/lib/Object/RecordStreamer.h b/llvm/lib/Object/RecordStreamer.h
index d9ef27c790168..edb6e3ae118bf 100644
--- a/llvm/lib/Object/RecordStreamer.h
+++ b/llvm/lib/Object/RecordStreamer.h
@@ -54,9 +54,10 @@ class RecordStreamer : public MCStreamer {
   void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
                         Align ByteAlignment) override;
 
-  // Ignore COFF-specific directives; we do not need any information from them,
-  // but the default implementation of these methods crashes, so we override
-  // them with versions that do nothing.
+  // Ignore format-specific directives; we do not need any information from
+  // them, but the default implementation of these methods crashes, so we
+  // override them with versions that do nothing.
+  void emitSubsectionsViaSymbols() override {};
   void beginCOFFSymbolDef(const MCSymbol *Symbol) override {}
   void emitCOFFSymbolStorageClass(int StorageClass) override {}
   void emitCOFFSymbolType(int Type) override {}
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index a53606851d0a2..d8422f488870e 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -961,7 +961,7 @@ void AArch64AsmPrinter::emitEndOfAsmFile(Module &M) {
     // implementation of multiple entry points).  If this doesn't occur, the
     // linker can safely perform dead code stripping.  Since LLVM never
     // generates code that does this, it is always safe to set.
-    OutStreamer->emitAssemblerFlag(MCAF_SubsectionsViaSymbols);
+    OutStreamer->emitSubsectionsViaSymbols();
   }
 
   if (TT.isOSBinFormatELF()) {
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp
index 83daa836e650d..e8a88f7f31401 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp
@@ -108,7 +108,6 @@ AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(const Triple &T) {
   CommentString = "//";
   PrivateGlobalPrefix = ".L";
   PrivateLabelPrefix = ".L";
-  Code32Directive = ".code\t32";
 
   Data16bitsDirective = "\t.hword\t";
   Data32bitsDirective = "\t.word\t";
diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
index 2505a67727aad..13efd70c0f22b 100644
--- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
+++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp
@@ -66,10 +66,10 @@ void ARMAsmPrinter::emitFunctionEntryLabel() {
   auto &TS =
       static_cast<ARMTargetStreamer &>(*OutStreamer->getTargetStreamer());
   if (AFI->isThumbFunction()) {
-    OutStreamer->emitAssemblerFlag(MCAF_Code16);
+    TS.emitCode16();
     TS.emitThumbFunc(CurrentFnSym);
   } else {
-    OutStreamer->emitAssemblerFlag(MCAF_Code32);
+    TS.emitCode32();
   }
 
   // Emit symbol for CMSE non-secure entry point
@@ -171,7 +171,9 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   // These are created per function, rather than per TU, since it's
   // relatively easy to exceed the thumb branch range within a TU.
   if (! ThumbIndirectPads.empty()) {
-    OutStreamer->emitAssemblerFlag(MCAF_Code16);
+    auto &TS =
+        static_cast<ARMTargetStreamer &>(*OutStreamer->getTargetStreamer());
+    TS.emitCode16();
     emitAlignment(Align(2));
     for (std::pair<unsigned, MCSymbol *> &TIP : ThumbIndirectPads) {
       OutStreamer->emitLabel(TIP.second);
@@ -489,24 +491,30 @@ void ARMAsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
   // the start mode, then restore the start mode.
   const bool WasThumb = isThumb(StartInfo);
   if (!EndInfo || WasThumb != isThumb(*EndInfo)) {
-    OutStreamer->emitAssemblerFlag(WasThumb ? MCAF_Code16 : MCAF_Code32);
+    auto &TS =
+        static_cast<ARMTargetStreamer &>(*OutStreamer->getTargetStreamer());
+    if (WasThumb)
+      TS.emitCode16();
+    else
+      TS.emitCode32();
   }
 }
 
 void ARMAsmPrinter::emitStartOfAsmFile(Module &M) {
   const Triple &TT = TM.getTargetTriple();
+  auto &TS =
+      static_cast<ARMTargetStreamer &>(*OutStreamer->getTargetStreamer());
   // Use unified assembler syntax.
-  OutStreamer->emitAssemblerFlag(MCAF_SyntaxUnified);
+  TS.emitSyntaxUnified();
 
   // Emit ARM Build Attributes
   if (TT.isOSBinFormatELF())
     emitAttributes();
 
   // Use the triple's architecture and subarchitecture to determine
-  // if we're thumb for the purposes of the top level code16 assembler
-  // flag.
+  // if we're thumb for the purposes of the top level code16 state.
   if (!M.getModuleInlineAsm().empty() && TT.isThumb())
-    OutStreamer->emitAssemblerFlag(MCAF_Code16);
+    TS.emitCode16();
 }
 
 static void
@@ -575,7 +583,7 @@ void ARMAsmPrinter::emitEndOfAsmFile(Module &M) {
     // implementation of multiple entry points).  If this doesn't occur, the
     // linker can safely perform dead code stripping.  Since LLVM never
     // generates code that does this, it is always safe to set.
-    OutStreamer->emitAssemblerFlag(MCAF_SubsectionsViaSymbols);
+    OutStreamer->emitSubsectionsViaSymbols();
   }
 
   // The last attribute to be emitted is ABI_optimization_goals
diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
index 48ad8a8994ae8..85b107c6085d3 100644
--- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -11654,7 +11654,7 @@ bool ARMAsmParser::parseDirectiveThumb(SMLoc L) {
   if (!isThumb())
     SwitchMode();
 
-  getParser().getStreamer().emitAssemblerFlag(MCAF_Code16);
+  getTargetStreamer().emitCode16();
   getParser().getStreamer().emitCodeAlignment(Align(2), &getSTI(), 0);
   return false;
 }
@@ -11667,7 +11667,7 @@ bool ARMAsmParser::parseDirectiveARM(SMLoc L) {
 
   if (isThumb())
     SwitchMode();
-  getParser().getStreamer().emitAssemblerFlag(MCAF_Code32);
+  getTargetStreamer().emitCode32();
   getParser().getStreamer().emitCodeAlignment(Align(4), &getSTI(), 0);
   return false;
 }
@@ -11715,7 +11715,7 @@ bool ARMAsmParser::parseDirectiveThumbFunc(SMLoc L) {
   if (!isThumb())
     SwitchMode();
 
-  getParser().getStreamer().emitAssemblerFlag(MCAF_Code16);
+  getTargetStreamer().emitCode16();
 
   NextSymbolIsThumb = true;
   return false;
@@ -11768,14 +11768,14 @@ bool ARMAsmParser::parseDirectiveCode(SMLoc L) {
 
     i...
[truncated]

Copy link
Member

@lenary lenary left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -32,7 +32,7 @@ class string:
)

ASM_FUNCTION_ARM_RE = re.compile(
r"^(?P<func>[0-9a-zA-Z_$]+):\n" # f: (name of function)
r'^(?P<func>[0-9a-zA-Z_$]+):[ \t]*@+[ \t]*@"?(?P=func)"?\n' # f: (name of function)
Copy link
Member

Choose a reason for hiding this comment

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

LGTM. Seems that other targets already check the comment that contains the function name

@@ -50,14 +50,6 @@ enum MCSymbolAttr {
MCSA_Memtag, ///< .memtag (ELF)
};

enum MCAssemblerFlag {
Copy link
Member

Choose a reason for hiding this comment

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

Nice! I agree that it's better to handle these very target-specific flags into XXXTargetStreamer

OutStreamer->emitAssemblerFlag(MCAF_Code16);
if (M.getModuleInlineAsm().empty() && is16) {
auto *XTS =
static_cast<X86TargetStreamer *>(OutStreamer->getTargetStreamer());
Copy link
Member

Choose a reason for hiding this comment

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

X86AsmPrinter should probably define a convenience method that returns X86TargetStreamer

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, these targets probably should. I encourage those who care about these backends to do cleanup work there :) Similarly, it would be nice if ARMELFStreamer didn't have its own IsThumb state to keep in sync with the actual subtarget. But those kinds of cleanups are future work.

@@ -171,7 +171,9 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
// These are created per function, rather than per TU, since it's
// relatively easy to exceed the thumb branch range within a TU.
if (! ThumbIndirectPads.empty()) {
OutStreamer->emitAssemblerFlag(MCAF_Code16);
auto &TS =
Copy link
Member

Choose a reason for hiding this comment

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

ARMAsmPrinter should probably define a convenience method that returns ARMTargetStreamer. The cast appears to occur in quite a few functions.

@jrtc27 jrtc27 merged commit 1b41599 into llvm:main May 18, 2025
19 checks passed
@jrtc27 jrtc27 deleted the upstream-mcaf branch May 18, 2025 19:09
@llvm-ci
Copy link
Collaborator

llvm-ci commented May 18, 2025

LLVM Buildbot has detected a new failure on builder fuchsia-x86_64-linux running on fuchsia-debian-64-us-central1-a-1 while building llvm at step 4 "annotate".

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

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure)
...
  Passed           : 46002 (97.93%)
  Expectedly Failed:    27 (0.06%)
[1368/1370] Linking CXX executable unittests/Transforms/Scalar/ScalarTests
[1369/1370] Running the LLVM regression tests
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld.lld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/ld.lld
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/lld-link
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/ld64.lld
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/wasm-ld
-- Testing: 59199 tests, 60 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80..
FAIL: LLVM :: tools/dsymutil/X86/op-convert-offset.test (52189 of 59199)
******************** TEST 'LLVM :: tools/dsymutil/X86/op-convert-offset.test' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
warning: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o: timestamp mismatch between object file (2025-05-18 17:26:41.396730365) and debug map (2022-07-12 20:49:30.000000000)
warning: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o: timestamp mismatch between object file (2025-05-18 17:26:41.396730365) and debug map (2022-07-12 20:49:30.000000000)
warning: cann't read address attribute value.
note: while processing op-convert-offset1.c

--
Command Output (stderr):
--
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/dsymutil -oso-prepend-path /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset -o /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 # RUN: at line 23
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/dsymutil -oso-prepend-path /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset -o /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o 2>&1 | /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix OBJ # RUN: at line 24
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix OBJ
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 | /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix DSYM # RUN: at line 25
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix DSYM
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/dsymutil --linker parallel -oso-prepend-path /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs   /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset   -o /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 # RUN: at line 27
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/dsymutil --linker parallel -oso-prepend-path /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset -o /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/llvm-dwarfdump    /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o 2>&1    | /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix OBJ # RUN: at line 30
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix OBJ
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 | /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix DSYM # RUN: at line 33
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix DSYM
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test:45:7: error: DSYM: expected string not found in input
DSYM: 0x00000084: DW_TAG_base_type
      ^
<stdin>:1:1: note: scanning from here
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM/Contents/Resources/DWARF/op-convert-offset: file format Mach-O 64-bit x86-64
^
<stdin>:16:1: note: possible intended match here
0x0000001e: DW_TAG_base_type
^
Step 7 (check) failure: check (failure)
...
  Passed           : 46002 (97.93%)
  Expectedly Failed:    27 (0.06%)
[1368/1370] Linking CXX executable unittests/Transforms/Scalar/ScalarTests
[1369/1370] Running the LLVM regression tests
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld.lld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/ld.lld
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/lld-link
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/ld64.lld
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/wasm-ld
-- Testing: 59199 tests, 60 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80..
FAIL: LLVM :: tools/dsymutil/X86/op-convert-offset.test (52189 of 59199)
******************** TEST 'LLVM :: tools/dsymutil/X86/op-convert-offset.test' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
warning: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o: timestamp mismatch between object file (2025-05-18 17:26:41.396730365) and debug map (2022-07-12 20:49:30.000000000)
warning: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o: timestamp mismatch between object file (2025-05-18 17:26:41.396730365) and debug map (2022-07-12 20:49:30.000000000)
warning: cann't read address attribute value.
note: while processing op-convert-offset1.c

--
Command Output (stderr):
--
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/dsymutil -oso-prepend-path /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset -o /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 # RUN: at line 23
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/dsymutil -oso-prepend-path /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset -o /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o 2>&1 | /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix OBJ # RUN: at line 24
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix OBJ
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 | /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix DSYM # RUN: at line 25
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix DSYM
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/dsymutil --linker parallel -oso-prepend-path /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs   /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset   -o /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 # RUN: at line 27
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/dsymutil --linker parallel -oso-prepend-path /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset -o /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/llvm-dwarfdump    /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o 2>&1    | /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix OBJ # RUN: at line 30
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix OBJ
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 | /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix DSYM # RUN: at line 33
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/llvm-dwarfdump /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix DSYM
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test:45:7: error: DSYM: expected string not found in input
DSYM: 0x00000084: DW_TAG_base_type
      ^
<stdin>:1:1: note: scanning from here
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-dbgsc2jm/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM/Contents/Resources/DWARF/op-convert-offset: file format Mach-O 64-bit x86-64
^
<stdin>:16:1: note: possible intended match here
0x0000001e: DW_TAG_base_type
^

@llvm-ci
Copy link
Collaborator

llvm-ci commented May 18, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-gcc-ubuntu-no-asserts running on doug-worker-6 while building llvm at step 6 "test-build-unified-tree-check-all".

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

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: tools/dsymutil/X86/op-convert-offset.test' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
warning: /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o: timestamp mismatch between object file (2025-03-11 17:27:45.671531848) and debug map (2022-07-12 20:49:30.000000000)
warning: /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o: timestamp mismatch between object file (2025-03-11 17:27:45.671531848) and debug map (2022-07-12 20:49:30.000000000)
warning: cann't read address attribute value.
note: while processing op-convert-offset1.c

--
Command Output (stderr):
--
/home/buildbot/buildbot-root/gcc-no-asserts/build/bin/dsymutil -oso-prepend-path /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset -o /home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 # RUN: at line 23
+ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/dsymutil -oso-prepend-path /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset -o /home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
/home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o 2>&1 | /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/FileCheck /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix OBJ # RUN: at line 24
+ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o
+ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/FileCheck /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix OBJ
/home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump /home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 | /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/FileCheck /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix DSYM # RUN: at line 25
+ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump /home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
+ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/FileCheck /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix DSYM
/home/buildbot/buildbot-root/gcc-no-asserts/build/bin/dsymutil --linker parallel -oso-prepend-path /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs   /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset   -o /home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 # RUN: at line 27
+ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/dsymutil --linker parallel -oso-prepend-path /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset -o /home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
/home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump    /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o 2>&1    | /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/FileCheck /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix OBJ # RUN: at line 30
+ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o
+ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/FileCheck /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix OBJ
/home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump /home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 | /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/FileCheck /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix DSYM # RUN: at line 33
+ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump /home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
+ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/FileCheck /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix DSYM
�[1m/home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test:45:7: �[0m�[0;1;31merror: �[0m�[1mDSYM: expected string not found in input
�[0mDSYM: 0x00000084: DW_TAG_base_type
�[0;1;32m      ^
�[0m�[1m<stdin>:1:1: �[0m�[0;1;30mnote: �[0m�[1mscanning from here
�[0m/home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM/Contents/Resources/DWARF/op-convert-offset: file format Mach-O 64-bit x86-64
�[0;1;32m^
�[0m�[1m<stdin>:16:1: �[0m�[0;1;30mnote: �[0m�[1mpossible intended match here
�[0m0x0000001e: DW_TAG_base_type
�[0;1;32m^
�[0m
Input file: <stdin>
Check file: /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test

-dump-input=help explains the following input dump.

Input was:
<<<<<<
�[1m�[0m�[0;1;30m            1: �[0m�[1m�[0;1;46m/home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM/Contents/Resources/DWARF/op-convert-offset: file format Mach-O 64-bit x86-64 �[0m
�[0;1;31mcheck:45'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
�[0m�[0;1;30m            2: �[0m�[1m�[0;1;46m �[0m
�[0;1;31mcheck:45'0     ~
...

ajaden-codes pushed a commit to Jaddyen/llvm-project that referenced this pull request Jun 6, 2025
…rgets (llvm#139844)

The .syntax unified directive and .codeX/.code X directives are, other
than some simple common printing code, exclusively implemented in the
targets themselves. Thus, remove the corresponding MCAF_* flags and
reimplement the directives solely within the targets. This avoids
exposing all targets to all other targets' flags.

Since MCAF_SubsectionsViaSymbols is all that remains, convert it to its
own function like other directives, simplifying its implementation.

Note that, on X86, we now always need a target streamer when parsing
assembly, as it's now used for directives that aren't COFF-specific. It
still does not however need to do anything when producing a non-COFF
object file, so this commit does not introduce any new target streamers.

There is some churn in test output, and corresponding UTC regex changes,
due to comments no longer being flushed by these various directives (and
EmitEOL is not exposed outside MCAsmStreamer.cpp so we couldn't do so
even if we wanted to), but that was a bit odd to be doing anyway.

This is motivated by Morello LLVM, which adds yet another assembler flag
to distinguish A64 and C64 instruction sets, but did not update every
switch and so emits warnings during the build. Rather than fix those
warnings it seems better to instead make the problem not exist in the
first place via this change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants