Skip to content

Support SFrame command-line and .cfi_section syntax #149935

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
Jul 23, 2025

Conversation

Sterling-Augustine
Copy link
Contributor

This PR adds support for the llvm-mc command-line flag "--gsframe" and adds ".sframe" to the legal values passed ".cfi_section". It plumbs the option through the cfi handling code a fair amount. Code to support actual section generation follows in a future PR.

These options match the gnu-assembler's support syntax for sframes, on both the command line and in assembly files.

First in a series of changes that will allow llvm-mc to produce sframe .cfi sections. For more information about sframes, see https://sourceware.org/binutils/docs-2.44/sframe-spec.html

and the llvm-RFC here:
https://discourse.llvm.org/t/rfc-adding-sframe-support-to-llvm/86900

This PR adds support for the llvm-mc command-line flag "--gsframe" and
adds ".sframe" to the legal values passed ".cfi_section". It plumbs
the option through the cfi handling code a fair amount.  Code to
support actual section generation follows in a future PR.

These options match the gnu-assembler's support syntax for sframes, on
both the command line and in assembly files.

First in a series of changes that will allow llvm-mc to produce
sframe .cfi sections. For more information about sframes, see
https://sourceware.org/binutils/docs-2.44/sframe-spec.html

and the llvm-RFC here:
https://discourse.llvm.org/t/rfc-adding-sframe-support-to-llvm/86900
@llvmbot llvmbot added llvm:codegen debuginfo mc Machine (object) code labels Jul 21, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 21, 2025

@llvm/pr-subscribers-mc

@llvm/pr-subscribers-debuginfo

Author: None (Sterling-Augustine)

Changes

This PR adds support for the llvm-mc command-line flag "--gsframe" and adds ".sframe" to the legal values passed ".cfi_section". It plumbs the option through the cfi handling code a fair amount. Code to support actual section generation follows in a future PR.

These options match the gnu-assembler's support syntax for sframes, on both the command line and in assembly files.

First in a series of changes that will allow llvm-mc to produce sframe .cfi sections. For more information about sframes, see https://sourceware.org/binutils/docs-2.44/sframe-spec.html

and the llvm-RFC here:
https://discourse.llvm.org/t/rfc-adding-sframe-support-to-llvm/86900


Full diff: https://github.com/llvm/llvm-project/pull/149935.diff

13 Files Affected:

  • (modified) llvm/include/llvm/MC/MCObjectStreamer.h (+2-1)
  • (modified) llvm/include/llvm/MC/MCStreamer.h (+1-1)
  • (modified) llvm/include/llvm/MC/MCTargetOptions.h (+3)
  • (modified) llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h (+2)
  • (modified) llvm/lib/CodeGen/AsmPrinter/ARMException.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp (+4-2)
  • (modified) llvm/lib/MC/MCAsmStreamer.cpp (+15-6)
  • (modified) llvm/lib/MC/MCObjectStreamer.cpp (+3-2)
  • (modified) llvm/lib/MC/MCParser/AsmParser.cpp (+6-3)
  • (modified) llvm/lib/MC/MCStreamer.cpp (+1-1)
  • (modified) llvm/lib/MC/MCTargetOptionsCommandFlags.cpp (+7)
  • (modified) llvm/test/MC/ELF/AArch64/cfi.s (+3-1)
  • (modified) llvm/test/MC/ELF/cfi.s (+3-1)
diff --git a/llvm/include/llvm/MC/MCObjectStreamer.h b/llvm/include/llvm/MC/MCObjectStreamer.h
index 2ceeba22abccd..aea93e9dc7e4f 100644
--- a/llvm/include/llvm/MC/MCObjectStreamer.h
+++ b/llvm/include/llvm/MC/MCObjectStreamer.h
@@ -40,6 +40,7 @@ class MCObjectStreamer : public MCStreamer {
   std::unique_ptr<MCAssembler> Assembler;
   bool EmitEHFrame;
   bool EmitDebugFrame;
+  bool EmitSFrame;
 
   struct PendingAssignment {
     MCSymbol *Symbol;
@@ -70,7 +71,7 @@ class MCObjectStreamer : public MCStreamer {
 
   void emitFrames(MCAsmBackend *MAB);
   MCSymbol *emitCFILabel() override;
-  void emitCFISections(bool EH, bool Debug) override;
+  void emitCFISections(bool EH, bool Debug, bool SFrame) override;
 
 public:
   void visitUsedSymbol(const MCSymbol &Sym) override;
diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h
index 4bfc8f921ef11..dfaf3487e11a7 100644
--- a/llvm/include/llvm/MC/MCStreamer.h
+++ b/llvm/include/llvm/MC/MCStreamer.h
@@ -986,7 +986,7 @@ class LLVM_ABI MCStreamer {
                                                const MCSymbol *Lo);
 
   virtual MCSymbol *getDwarfLineTableSymbol(unsigned CUID);
-  virtual void emitCFISections(bool EH, bool Debug);
+  virtual void emitCFISections(bool EH, bool Debug, bool SFrame);
   void emitCFIStartProc(bool IsSimple, SMLoc Loc = SMLoc());
   void emitCFIEndProc();
   virtual void emitCFIDefCfa(int64_t Register, int64_t Offset, SMLoc Loc = {});
diff --git a/llvm/include/llvm/MC/MCTargetOptions.h b/llvm/include/llvm/MC/MCTargetOptions.h
index d95adf92b9a83..235d58d585b40 100644
--- a/llvm/include/llvm/MC/MCTargetOptions.h
+++ b/llvm/include/llvm/MC/MCTargetOptions.h
@@ -102,6 +102,9 @@ class MCTargetOptions {
   // functions on Darwins.
   bool EmitCompactUnwindNonCanonical : 1;
 
+  // Whether to emit SFrame unwind sections.
+  bool EmitSFrameUnwind : 1;
+
   // Whether or not to use full register names on PowerPC.
   bool PPCUseFullRegisterNames : 1;
 
diff --git a/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h b/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
index b057effd88128..adfdccdb5ab77 100644
--- a/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
+++ b/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
@@ -40,6 +40,8 @@ LLVM_ABI EmitDwarfUnwindType getEmitDwarfUnwind();
 
 LLVM_ABI bool getEmitCompactUnwindNonCanonical();
 
+LLVM_ABI bool getEmitSFrameUnwind();
+
 LLVM_ABI bool getShowMCInst();
 
 LLVM_ABI bool getFatalWarnings();
diff --git a/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp b/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp
index de6ebcf0c3419..51342c6b91345 100644
--- a/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp
@@ -39,7 +39,7 @@ void ARMException::beginFunction(const MachineFunction *MF) {
   if (CFISecType == AsmPrinter::CFISection::Debug) {
     if (!hasEmittedCFISections) {
       if (Asm->getModuleCFISectionType() == AsmPrinter::CFISection::Debug)
-        Asm->OutStreamer->emitCFISections(false, true);
+        Asm->OutStreamer->emitCFISections(false, true, false);
       hasEmittedCFISections = true;
     }
 
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
index 4fac4bbc98477..6b8d08cb201d6 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
@@ -109,9 +109,11 @@ void DwarfCFIException::beginBasicBlockSection(const MachineBasicBlock &MBB) {
     // chose not to be verbose in that case. And with `ForceDwarfFrameSection`,
     // we should always emit .debug_frame.
     if (CFISecType == AsmPrinter::CFISection::Debug ||
-        Asm->TM.Options.ForceDwarfFrameSection)
+        Asm->TM.Options.ForceDwarfFrameSection ||
+        Asm->TM.Options.MCOptions.EmitSFrameUnwind)
       Asm->OutStreamer->emitCFISections(
-          CFISecType == AsmPrinter::CFISection::EH, true);
+          CFISecType == AsmPrinter::CFISection::EH, true,
+          Asm->TM.Options.MCOptions.EmitSFrameUnwind);
     hasEmittedCFISections = true;
   }
 
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index 67c53e01a6111..7119ef4a2bbcd 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -345,7 +345,7 @@ class MCAsmStreamer final : public MCStreamer {
   void emitIdent(StringRef IdentString) override;
   void emitCFIBKeyFrame() override;
   void emitCFIMTETaggedFrame() override;
-  void emitCFISections(bool EH, bool Debug) override;
+  void emitCFISections(bool EH, bool Debug, bool SFrame) override;
   void emitCFIDefCfa(int64_t Register, int64_t Offset, SMLoc Loc) override;
   void emitCFIDefCfaOffset(int64_t Offset, SMLoc Loc) override;
   void emitCFIDefCfaRegister(int64_t Register, SMLoc Loc) override;
@@ -1906,15 +1906,24 @@ void MCAsmStreamer::emitIdent(StringRef IdentString) {
   EmitEOL();
 }
 
-void MCAsmStreamer::emitCFISections(bool EH, bool Debug) {
-  MCStreamer::emitCFISections(EH, Debug);
+void MCAsmStreamer::emitCFISections(bool EH, bool Debug, bool SFrame) {
+  MCStreamer::emitCFISections(EH, Debug, SFrame);
   OS << "\t.cfi_sections ";
+  bool C = false;
   if (EH) {
     OS << ".eh_frame";
-    if (Debug)
-      OS << ", .debug_frame";
-  } else if (Debug) {
+    C = true;
+  }
+  if (Debug) {
+    if (C)
+      OS << ", ";
     OS << ".debug_frame";
+    C = true;
+  }
+  if (SFrame) {
+    if (C)
+      OS << ", ";
+    OS << ".sframe";
   }
 
   EmitEOL();
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index 42f4cf49d7f38..d7f4be1bfb573 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -130,10 +130,11 @@ void MCObjectStreamer::visitUsedSymbol(const MCSymbol &Sym) {
   Assembler->registerSymbol(Sym);
 }
 
-void MCObjectStreamer::emitCFISections(bool EH, bool Debug) {
-  MCStreamer::emitCFISections(EH, Debug);
+void MCObjectStreamer::emitCFISections(bool EH, bool Debug, bool SFrame) {
+  MCStreamer::emitCFISections(EH, Debug, SFrame);
   EmitEHFrame = EH;
   EmitDebugFrame = Debug;
+  EmitSFrame = SFrame;
 }
 
 void MCObjectStreamer::emitValueImpl(const MCExpr *Value, unsigned Size,
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index d0b6ea4cfd562..eda5e8c37f7b8 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -4093,27 +4093,30 @@ bool AsmParser::parseDirectiveCVFPOData() {
 }
 
 /// parseDirectiveCFISections
-/// ::= .cfi_sections section [, section]
+/// ::= .cfi_sections section [, section][, section]
 bool AsmParser::parseDirectiveCFISections() {
   StringRef Name;
   bool EH = false;
   bool Debug = false;
+  bool SFrame = false;
 
   if (!parseOptionalToken(AsmToken::EndOfStatement)) {
     for (;;) {
       if (parseIdentifier(Name))
-        return TokError("expected .eh_frame or .debug_frame");
+        return TokError("expected .eh_frame, .debug_frame, or .sframe");
       if (Name == ".eh_frame")
         EH = true;
       else if (Name == ".debug_frame")
         Debug = true;
+      else if (Name == ".sframe")
+        SFrame = true;
       if (parseOptionalToken(AsmToken::EndOfStatement))
         break;
       if (parseComma())
         return true;
     }
   }
-  getStreamer().emitCFISections(EH, Debug);
+  getStreamer().emitCFISections(EH, Debug, SFrame);
   return false;
 }
 
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index 30198c97d8ab9..e14a32f5dc0ce 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -415,7 +415,7 @@ void MCStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
 void MCStreamer::emitConditionalAssignment(MCSymbol *Symbol,
                                            const MCExpr *Value) {}
 
-void MCStreamer::emitCFISections(bool EH, bool Debug) {}
+void MCStreamer::emitCFISections(bool EH, bool Debug, bool SFrame) {}
 
 void MCStreamer::emitCFIStartProc(bool IsSimple, SMLoc Loc) {
   if (!FrameInfoStack.empty() &&
diff --git a/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp b/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
index 2adc29172f9dd..ff95ff78fd53a 100644
--- a/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
+++ b/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
@@ -41,6 +41,7 @@ MCOPT(int, DwarfVersion)
 MCOPT(bool, Dwarf64)
 MCOPT(EmitDwarfUnwindType, EmitDwarfUnwind)
 MCOPT(bool, EmitCompactUnwindNonCanonical)
+MCOPT(bool, EmitSFrameUnwind)
 MCOPT(bool, ShowMCInst)
 MCOPT(bool, FatalWarnings)
 MCOPT(bool, NoWarn)
@@ -105,6 +106,11 @@ llvm::mc::RegisterMCTargetOptionsFlags::RegisterMCTargetOptionsFlags() {
           false)); // By default, use DWARF for non-canonical personalities.
   MCBINDOPT(EmitCompactUnwindNonCanonical);
 
+  static cl::opt<bool> EmitSFrameUnwind(
+      "gsframe", cl::desc("Whether to emit .sframe unwind sections."),
+      cl::init(false));
+  MCBINDOPT(EmitSFrameUnwind);
+
   static cl::opt<bool> ShowMCInst(
       "asm-show-inst",
       cl::desc("Emit internal instruction representation to assembly file"));
@@ -188,6 +194,7 @@ MCTargetOptions llvm::mc::InitMCTargetOptionsFromFlags() {
   Options.X86Sse2Avx = getX86Sse2Avx();
   Options.EmitDwarfUnwind = getEmitDwarfUnwind();
   Options.EmitCompactUnwindNonCanonical = getEmitCompactUnwindNonCanonical();
+  Options.EmitSFrameUnwind = getEmitSFrameUnwind();
   Options.AsSecureLogFile = getAsSecureLogFile();
 
   return Options;
diff --git a/llvm/test/MC/ELF/AArch64/cfi.s b/llvm/test/MC/ELF/AArch64/cfi.s
index 6bdf03cc7bb85..7047f92bab8fe 100644
--- a/llvm/test/MC/ELF/AArch64/cfi.s
+++ b/llvm/test/MC/ELF/AArch64/cfi.s
@@ -557,12 +557,14 @@ f37:
 // CHECK-NEXT:  }
 
 .ifdef ERR
-// ERR: [[#@LINE+1]]:15: error: expected .eh_frame or .debug_frame
+// ERR: [[#@LINE+1]]:15: error: expected .eh_frame, .debug_frame, or .sframe
 .cfi_sections $
 // ERR: [[#@LINE+1]]:28: error: expected comma
 .cfi_sections .debug_frame $
 // ERR: [[#@LINE+1]]:39: error: expected comma
 .cfi_sections .debug_frame, .eh_frame $
+// ERR: [[#@LINE+1]]:48: error: expected comma
+.cfi_sections .debug_frame, .eh_frame, .sframe $
 
 // ERR: [[#@LINE+1]]:16: error: unexpected token
 .cfi_startproc $
diff --git a/llvm/test/MC/ELF/cfi.s b/llvm/test/MC/ELF/cfi.s
index 3bd16aec4613e..b7f937104dbf2 100644
--- a/llvm/test/MC/ELF/cfi.s
+++ b/llvm/test/MC/ELF/cfi.s
@@ -445,12 +445,14 @@ f37:
 // CHECK:        }
 
 .ifdef ERR
-// ERR: [[#@LINE+1]]:15: error: expected .eh_frame or .debug_frame
+// ERR: [[#@LINE+1]]:15: error: expected .eh_frame, .debug_frame, or .sframe
 .cfi_sections $
 // ERR: [[#@LINE+1]]:28: error: expected comma
 .cfi_sections .debug_frame $
 // ERR: [[#@LINE+1]]:39: error: expected comma
 .cfi_sections .debug_frame, .eh_frame $
+// ERR: [[#@LINE+1]]:48: error: expected comma
+.cfi_sections .debug_frame, .eh_frame, .sframe $
 
 // ERR: [[#@LINE+1]]:16: error: unexpected token
 .cfi_startproc $

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. Please wait before landing in case someone else has comments but I don't think this will be controversial.

@Sterling-Augustine Sterling-Augustine merged commit f9d0bd0 into llvm:main Jul 23, 2025
13 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 23, 2025

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

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

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'Clang :: Driver/femit-dwarf-unwind.c' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
rm -rf /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Driver/Output/femit-dwarf-unwind.c.tmp; mkdir /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Driver/Output/femit-dwarf-unwind.c.tmp # RUN: at line 3
+ rm -rf /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Driver/Output/femit-dwarf-unwind.c.tmp
+ mkdir /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Driver/Output/femit-dwarf-unwind.c.tmp
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang -target x86_64-apple-macos11.0 -c /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Driver/femit-dwarf-unwind.c -o /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Driver/Output/femit-dwarf-unwind.c.tmp/x86_64.o -femit-compact-unwind-non-canonical # RUN: at line 4
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang -target x86_64-apple-macos11.0 -c /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Driver/femit-dwarf-unwind.c -o /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Driver/Output/femit-dwarf-unwind.c.tmp/x86_64.o -femit-compact-unwind-non-canonical
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang -target x86_64-apple-macos11.0 -femit-dwarf-unwind=no-compact-unwind -femit-compact-unwind-non-canonical -c /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Driver/femit-dwarf-unwind.c -o /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Driver/Output/femit-dwarf-unwind.c.tmp/x86_64-no-dwarf.o # RUN: at line 5
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang -target x86_64-apple-macos11.0 -femit-dwarf-unwind=no-compact-unwind -femit-compact-unwind-non-canonical -c /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Driver/femit-dwarf-unwind.c -o /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Driver/Output/femit-dwarf-unwind.c.tmp/x86_64-no-dwarf.o
llvm-objdump --macho --dwarf=frames /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Driver/Output/femit-dwarf-unwind.c.tmp/x86_64.o | /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Driver/femit-dwarf-unwind.c --check-prefix=WITH-FDE # RUN: at line 6
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Driver/femit-dwarf-unwind.c --check-prefix=WITH-FDE
+ llvm-objdump --macho --dwarf=frames /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Driver/Output/femit-dwarf-unwind.c.tmp/x86_64.o
llvm-objdump --macho --dwarf=frames /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Driver/Output/femit-dwarf-unwind.c.tmp/x86_64-no-dwarf.o | /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Driver/femit-dwarf-unwind.c --check-prefix=NO-FDE # RUN: at line 7
+ llvm-objdump --macho --dwarf=frames /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/test/Driver/Output/femit-dwarf-unwind.c.tmp/x86_64-no-dwarf.o
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Driver/femit-dwarf-unwind.c --check-prefix=NO-FDE
�[1m/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Driver/femit-dwarf-unwind.c:10:16: �[0m�[0;1;31merror: �[0m�[1mNO-FDE-NOT: excluded string found in input
�[0m// NO-FDE-NOT: FDE
�[0;1;32m               ^
�[0m�[1m<stdin>:23:28: �[0m�[0;1;30mnote: �[0m�[1mfound here
�[0m00000018 0000001c 00000000 FDE cie=00000000 pc=00000000...0000000b
�[0;1;32m                           ^~~
�[0m
Input file: <stdin>
Check file: /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Driver/femit-dwarf-unwind.c

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

Input was:
<<<<<<
�[1m�[0m�[0;1;30m        1: �[0m�[1m�[0;1;46m �[0m
�[0;1;30m        2: �[0m�[1m�[0;1;46m.debug_frame contents: �[0m
�[0;1;30m        3: �[0m�[1m�[0;1;46m �[0m
�[0;1;30m        4: �[0m�[1m�[0;1;46m00000000 00000014 ffffffff CIE �[0m
�[0;1;30m        5: �[0m�[1m�[0;1;46m Format: DWARF32 �[0m
�[0;1;30m        6: �[0m�[1m�[0;1;46m Version: 4 �[0m
�[0;1;30m        7: �[0m�[1m�[0;1;46m Augmentation: "" �[0m
�[0;1;30m        8: �[0m�[1m�[0;1;46m Address size: 8 �[0m
�[0;1;30m        9: �[0m�[1m�[0;1;46m Segment desc size: 0 �[0m
�[0;1;30m       10: �[0m�[1m�[0;1;46m Code alignment factor: 1 �[0m
�[0;1;30m       11: �[0m�[1m�[0;1;46m Data alignment factor: -8 �[0m
�[0;1;30m       12: �[0m�[1m�[0;1;46m Return address column: 16 �[0m
�[0;1;30m       13: �[0m�[1m�[0;1;46m �[0m
�[0;1;30m       14: �[0m�[1m�[0;1;46m DW_CFA_def_cfa: reg7 +8 �[0m
�[0;1;30m       15: �[0m�[1m�[0;1;46m DW_CFA_offset: reg16 -8 �[0m
�[0;1;30m       16: �[0m�[1m�[0;1;46m DW_CFA_nop: �[0m
�[0;1;30m       17: �[0m�[1m�[0;1;46m DW_CFA_nop: �[0m
�[0;1;30m       18: �[0m�[1m�[0;1;46m DW_CFA_nop: �[0m
...

@dyung
Copy link
Collaborator

dyung commented Jul 23, 2025

Hi @Sterling-Augustine, I see you made a revert commit, do you plan to apply that change? Or are you still investigating the failure?

@Sterling-Augustine
Copy link
Contributor Author

I cannot reproduce the failure. The test works fine locally with ninja check-clang-driver and the log is clean. Please advise.

@dyung
Copy link
Collaborator

dyung commented Jul 23, 2025

I cannot reproduce the failure. The test works fine locally with ninja check-clang-driver and the log is clean. Please advise.

Did you try with the PS4 target as the default triple?

@dyung
Copy link
Collaborator

dyung commented Jul 23, 2025

This bot is also failing on that test but just targets a native linux target: https://lab.llvm.org/buildbot/#/builders/174/builds/21595

@ilovepi
Copy link
Contributor

ilovepi commented Jul 23, 2025

We're seeing this happen consistently on builds w/o assertions or backtraces. I've only seen it pop up once on an asserts enabled builds.

Bot: https://ci.chromium.org/ui/p/fuchsia/builders/prod/clang-host-linux-x64/b8708533047641712833/overview

CMake: https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8708522043377870369/+/u/clang/configure/l_execution_details

@Sterling-Augustine
Copy link
Contributor Author

Revert is merged. Still haven't managed to reproduce this.

@dyung
Copy link
Collaborator

dyung commented Jul 23, 2025

Revert is merged. Still haven't managed to reproduce this.

You can try the cmake commands used by each of the bots:

cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -DCLANG_ENABLE_ARCMT=OFF -DCLANG_ENABLE_CLANGD=OFF -DLLVM_BUILD_RUNTIME=OFF -DLLVM_CCACHE_BUILD=ON -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-scei-ps4 -DLLVM_ENABLE_ASSERTIONS=ON '-DLLVM_LIT_ARGS=--verbose -j100 --timeout=900' -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_USE_LINKER=gold '-DLLVM_ENABLE_PROJECTS=llvm;cross-project-tests;lld;clang-tools-extra;clang' -GNinja ../llvm-project/llvm
cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -DCLANG_ENABLE_CLANGD=OFF -DLLVM_BUILD_RUNTIME=ON -DLLVM_BUILD_TESTS=ON -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_INCLUDE_EXAMPLES=OFF '-DLLVM_LIT_ARGS=--verbose --timeout=900' -DLLVM_USE_LINKER=gold '-DLLVM_ENABLE_PROJECTS=llvm;cross-project-tests;clang;lld;clang-tools-extra' -DLLVM_ENABLE_RUNTIMES=compiler-rt -GNinja ../llvm-project/llvm

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 23, 2025

LLVM Buildbot has detected a new failure on builder premerge-monolithic-linux running on premerge-linux-1 while building llvm at step 7 "test-build-unified-tree-check-all".

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

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'Flang :: Driver/save-mlir-temps.f90' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
/build/buildbot/premerge-monolithic-linux/build/tools/flang/test/Driver/Output/save-mlir-temps.f90.tmp /build/buildbot/premerge-monolithic-linux/build/tools/flang/test/Driver
save-mlir-temps.s: Assembler messages:
save-mlir-temps.s:7: Error: junk at end of line, first unrecognized character is `.'
flang-22: error: assembler command failed with exit code 1 (use -v to see invocation)

--
Command Output (stderr):
--
not /build/buildbot/premerge-monolithic-linux/build/bin/flang -fc1 -emit-llvm-bc -save-temps=#invalid-dir -o - /build/buildbot/premerge-monolithic-linux/llvm-project/flang/test/Driver/save-mlir-temps.f90 2>&1 | /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck /build/buildbot/premerge-monolithic-linux/llvm-project/flang/test/Driver/save-mlir-temps.f90 -check-prefix=MLIR-ERROR # RUN: at line 16
+ /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck /build/buildbot/premerge-monolithic-linux/llvm-project/flang/test/Driver/save-mlir-temps.f90 -check-prefix=MLIR-ERROR
+ not /build/buildbot/premerge-monolithic-linux/build/bin/flang -fc1 -emit-llvm-bc -save-temps=#invalid-dir -o - /build/buildbot/premerge-monolithic-linux/llvm-project/flang/test/Driver/save-mlir-temps.f90
rm -rf /build/buildbot/premerge-monolithic-linux/build/tools/flang/test/Driver/Output/save-mlir-temps.f90.tmp && mkdir -p /build/buildbot/premerge-monolithic-linux/build/tools/flang/test/Driver/Output/save-mlir-temps.f90.tmp # RUN: at line 22
+ rm -rf /build/buildbot/premerge-monolithic-linux/build/tools/flang/test/Driver/Output/save-mlir-temps.f90.tmp
+ mkdir -p /build/buildbot/premerge-monolithic-linux/build/tools/flang/test/Driver/Output/save-mlir-temps.f90.tmp
pushd /build/buildbot/premerge-monolithic-linux/build/tools/flang/test/Driver/Output/save-mlir-temps.f90.tmp && /build/buildbot/premerge-monolithic-linux/build/bin/flang -c -fno-integrated-as -save-temps=cwd -o out.o /build/buildbot/premerge-monolithic-linux/llvm-project/flang/test/Driver/save-mlir-temps.f90 2>&1 # RUN: at line 23
+ pushd /build/buildbot/premerge-monolithic-linux/build/tools/flang/test/Driver/Output/save-mlir-temps.f90.tmp
+ /build/buildbot/premerge-monolithic-linux/build/bin/flang -c -fno-integrated-as -save-temps=cwd -o out.o /build/buildbot/premerge-monolithic-linux/llvm-project/flang/test/Driver/save-mlir-temps.f90

--

********************


@Sterling-Augustine
Copy link
Contributor Author

Never did manage to reproduce this, but I did find a single uninitialized bit (asan does't check bitfields), which I'm guessing is the source of the trouble. Reapplied with that fix in 29e8599

If the failure reappears, just immediately revert and I'll dig deeper.

mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Jul 28, 2025
This PR adds support for the llvm-mc command-line flag "--gsframe" and
adds ".sframe" to the legal values passed ".cfi_section". It plumbs the
option through the cfi handling code a fair amount. Code to support
actual section generation follows in a future PR.

These options match the gnu-assembler's support syntax for sframes, on
both the command line and in assembly files.

First in a series of changes that will allow llvm-mc to produce sframe
.cfi sections. For more information about sframes, see
https://sourceware.org/binutils/docs-2.44/sframe-spec.html

and the llvm-RFC here:
https://discourse.llvm.org/t/rfc-adding-sframe-support-to-llvm/86900
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debuginfo llvm:codegen mc Machine (object) code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants