[llvm] d941d59 - Revert "[MC] Omit DWARF unwind info if compact unwind is present where eligible"

Jez Ng via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 12 07:47:16 PDT 2022


Author: Jez Ng
Date: 2022-06-12T10:47:08-04:00
New Revision: d941d597837d9e1405086f008c9bd6a71e7263c9

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

LOG: Revert "[MC] Omit DWARF unwind info if compact unwind is present where eligible"

This reverts commit ef501bf85d8c869248e51371f0e74bcec0e7b229.

Added: 
    

Modified: 
    clang/include/clang/Basic/CodeGenOptions.def
    clang/include/clang/Driver/Options.td
    clang/lib/CodeGen/BackendUtil.cpp
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/tools/driver/cc1as_main.cpp
    llvm/include/llvm/MC/MCContext.h
    llvm/include/llvm/MC/MCTargetOptions.h
    llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
    llvm/lib/CodeGen/LLVMTargetMachine.cpp
    llvm/lib/CodeGen/MachineModuleInfo.cpp
    llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
    llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
    llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
    llvm/lib/MC/MCContext.cpp
    llvm/lib/MC/MCDwarf.cpp
    llvm/lib/MC/MCObjectFileInfo.cpp
    llvm/lib/MC/MCTargetOptions.cpp
    llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
    llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

Removed: 
    clang/test/Driver/femit-dwarf-unwind.c
    clang/test/Driver/femit-dwarf-unwind.s
    llvm/test/MC/MachO/emit-dwarf-unwind.s
    llvm/test/MC/X86/compact-unwind-mode-dwarf.s


################################################################################
diff  --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def
index 8e89106993c26..d8f667dc387bb 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -114,10 +114,6 @@ CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is enabl
 CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
                                           ///< enabled.
 
-///< Set when -femit-dwarf-unwind is passed.
-ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
-                llvm::EmitDwarfUnwindType::Default)
-
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 

diff  --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 002cd6cc8cb17..95840760f7746 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3044,13 +3044,6 @@ def fmacro_prefix_map_EQ
 defm force_dwarf_frame : BoolFOption<"force-dwarf-frame",
   CodeGenOpts<"ForceDwarfFrameSection">, DefaultFalse,
   PosFlag<SetTrue, [CC1Option], "Always emit a debug frame section">, NegFlag<SetFalse>>;
-def femit_dwarf_unwind_EQ : Joined<["-"], "femit-dwarf-unwind=">,
-  Group<f_Group>, Flags<[CC1Option, CC1AsOption]>,
-  HelpText<"When to emit DWARF unwind (EH frame) info">,
-  Values<"always,no-compact-unwind,default">,
-  NormalizedValues<["Always", "NoCompactUnwind", "Default"]>,
-  NormalizedValuesScope<"llvm::EmitDwarfUnwindType">,
-  MarshallingInfoEnum<CodeGenOpts<"EmitDwarfUnwind">, "Default">;
 def g_Flag : Flag<["-"], "g">, Group<g_Group>,
   HelpText<"Generate source-level debug information">;
 def gline_tables_only : Flag<["-"], "gline-tables-only">, Group<gN_Group>,

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 4b294c254e476..0de15b1e48078 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -453,7 +453,6 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
   }
 
   Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
-  Options.MCOptions.EmitDwarfUnwind = CodeGenOpts.getEmitDwarfUnwind();
   Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;
   Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;
   Options.MCOptions.MCUseDwarfDirectory =

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 62e891ce38c49..ceac142653ebe 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2518,8 +2518,6 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
                    DefaultIncrementalLinkerCompatible))
     CmdArgs.push_back("-mincremental-linker-compatible");
 
-  Args.AddLastArg(CmdArgs, options::OPT_femit_dwarf_unwind_EQ);
-
   // If you add more args here, also add them to the block below that
   // starts with "// If CollectArgsForIntegratedAssembler() isn't called below".
 
@@ -4624,7 +4622,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
     }
     Args.ClaimAllArgs(options::OPT_Wa_COMMA);
     Args.ClaimAllArgs(options::OPT_Xassembler);
-    Args.ClaimAllArgs(options::OPT_femit_dwarf_unwind_EQ);
   }
 
   if (isa<AnalyzeJobAction>(JA)) {

diff  --git a/clang/test/Driver/femit-dwarf-unwind.c b/clang/test/Driver/femit-dwarf-unwind.c
deleted file mode 100644
index 3101e1db7b9d4..0000000000000
--- a/clang/test/Driver/femit-dwarf-unwind.c
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: rm -rf %t; mkdir %t
-// RUN: %clang -target x86_64-apple-macos11.0 -c %s -o %t/x86_64.o
-// RUN: %clang -target x86_64-apple-macos11.0 -femit-dwarf-unwind=no-compact-unwind -c %s -o %t/x86_64-no-dwarf.o
-// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64.o | FileCheck %s --check-prefix=WITH-FDE
-// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64-no-dwarf.o | FileCheck %s --check-prefix=NO-FDE
-
-// WITH-FDE: FDE
-// NO-FDE-NOT: FDE
-
-int foo() {
-  return 1;
-}

diff  --git a/clang/test/Driver/femit-dwarf-unwind.s b/clang/test/Driver/femit-dwarf-unwind.s
deleted file mode 100644
index 881925c76abd4..0000000000000
--- a/clang/test/Driver/femit-dwarf-unwind.s
+++ /dev/null
@@ -1,15 +0,0 @@
-// RUN: rm -rf %t; mkdir %t
-// RUN: %clang -target x86_64-apple-macos11.0 -c %s -o %t/x86_64.o
-// RUN: %clang -target x86_64-apple-macos11.0 -femit-dwarf-unwind=no-compact-unwind -c %s -o %t/x86_64-no-dwarf.o
-// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64.o | FileCheck %s --check-prefix=WITH-FDE
-// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64-no-dwarf.o | FileCheck %s --check-prefix=NO-FDE
-
-// WITH-FDE: FDE
-// NO-FDE-NOT: FDE
-
-.text
-_foo:
-  .cfi_startproc
-  .cfi_def_cfa_offset 8
-  ret
-  .cfi_endproc

diff  --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp
index 264f747d6d740..6a11c25553ba3 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -137,9 +137,6 @@ struct AssemblerInvocation {
   unsigned IncrementalLinkerCompatible : 1;
   unsigned EmbedBitcode : 1;
 
-  /// Whether to emit DWARF unwind info.
-  EmitDwarfUnwindType EmitDwarfUnwind;
-
   /// The name of the relocation model to use.
   std::string RelocationModel;
 
@@ -320,14 +317,6 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
                             .Default(0);
   }
 
-  if (auto *A = Args.getLastArg(OPT_femit_dwarf_unwind_EQ)) {
-    Opts.EmitDwarfUnwind =
-        llvm::StringSwitch<EmitDwarfUnwindType>(A->getValue())
-            .Case("always", EmitDwarfUnwindType::Always)
-            .Case("no-compact-unwind", EmitDwarfUnwindType::NoCompactUnwind)
-            .Case("default", EmitDwarfUnwindType::Default);
-  }
-
   return Success;
 }
 
@@ -378,8 +367,6 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
   assert(MRI && "Unable to create target register info!");
 
   MCTargetOptions MCOptions;
-  MCOptions.EmitDwarfUnwind = Opts.EmitDwarfUnwind;
-
   std::unique_ptr<MCAsmInfo> MAI(
       TheTarget->createMCAsmInfo(*MRI, Opts.Triple, MCOptions));
   assert(MAI && "Unable to create target asm info!");

diff  --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h
index c3a4e57fdd753..5b81ba31b83c5 100644
--- a/llvm/include/llvm/MC/MCContext.h
+++ b/llvm/include/llvm/MC/MCContext.h
@@ -67,7 +67,6 @@ template <typename T> class SmallVectorImpl;
 class SMDiagnostic;
 class SMLoc;
 class SourceMgr;
-enum class EmitDwarfUnwindType;
 
 /// Context object for machine code objects.  This class owns all of the
 /// sections that it creates.
@@ -773,7 +772,6 @@ class MCContext {
   bool getGenDwarfForAssembly() { return GenDwarfForAssembly; }
   void setGenDwarfForAssembly(bool Value) { GenDwarfForAssembly = Value; }
   unsigned getGenDwarfFileNumber() { return GenDwarfFileNumber; }
-  EmitDwarfUnwindType emitDwarfUnwindInfo() const;
 
   void setGenDwarfFileNumber(unsigned FileNumber) {
     GenDwarfFileNumber = FileNumber;

diff  --git a/llvm/include/llvm/MC/MCTargetOptions.h b/llvm/include/llvm/MC/MCTargetOptions.h
index 9c906cdc90d02..93712a6b7d44b 100644
--- a/llvm/include/llvm/MC/MCTargetOptions.h
+++ b/llvm/include/llvm/MC/MCTargetOptions.h
@@ -31,12 +31,6 @@ enum class DebugCompressionType {
   Z,    ///< zlib style complession
 };
 
-enum class EmitDwarfUnwindType {
-  Always,          // Always emit dwarf unwind
-  NoCompactUnwind, // Only emit if compact unwind isn't available
-  Default,         // Default behavior is based on the target
-};
-
 class StringRef;
 
 class MCTargetOptions {
@@ -62,9 +56,6 @@ class MCTargetOptions {
   bool PreserveAsmComments : 1;
 
   bool Dwarf64 : 1;
-
-  EmitDwarfUnwindType EmitDwarfUnwind;
-
   int DwarfVersion = 0;
 
   enum DwarfDirectory {

diff  --git a/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h b/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
index d51e740177f77..1894841989166 100644
--- a/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
+++ b/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
@@ -20,7 +20,6 @@
 namespace llvm {
 
 class MCTargetOptions;
-enum class EmitDwarfUnwindType;
 
 namespace mc {
 
@@ -33,8 +32,6 @@ int getDwarfVersion();
 
 bool getDwarf64();
 
-EmitDwarfUnwindType getEmitDwarfUnwind();
-
 bool getShowMCInst();
 
 bool getFatalWarnings();

diff  --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
index 3192dcadb5f5e..af05dbced04e1 100644
--- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp
+++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
@@ -264,9 +264,6 @@ bool LLVMTargetMachine::addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx,
          "Cannot emit MC with limited codegen pipeline");
 
   Ctx = &MMIWP->getMMI().getContext();
-  // libunwind is unable to load compact unwind dynamically, so we must generate
-  // DWARF unwind info for the JIT.
-  Options.MCOptions.EmitDwarfUnwind = EmitDwarfUnwindType::Always;
   if (Options.MCOptions.MCSaveTempLabels)
     Ctx->setAllowTemporaryLabels(false);
 

diff  --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp
index 23d55a5df9f57..07ada255eb83d 100644
--- a/llvm/lib/CodeGen/MachineModuleInfo.cpp
+++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp
@@ -60,7 +60,7 @@ MachineModuleInfo::MachineModuleInfo(MachineModuleInfo &&MMI)
     : TM(std::move(MMI.TM)),
       Context(MMI.TM.getTargetTriple(), MMI.TM.getMCAsmInfo(),
               MMI.TM.getMCRegisterInfo(), MMI.TM.getMCSubtargetInfo(), nullptr,
-              &MMI.TM.Options.MCOptions, false),
+              nullptr, false),
       MachineFunctions(std::move(MMI.MachineFunctions)) {
   Context.setObjectFileInfo(MMI.TM.getObjFileLowering());
   ObjFileMMI = MMI.ObjFileMMI;
@@ -72,7 +72,7 @@ MachineModuleInfo::MachineModuleInfo(MachineModuleInfo &&MMI)
 MachineModuleInfo::MachineModuleInfo(const LLVMTargetMachine *TM)
     : TM(*TM), Context(TM->getTargetTriple(), TM->getMCAsmInfo(),
                        TM->getMCRegisterInfo(), TM->getMCSubtargetInfo(),
-                       nullptr, &TM->Options.MCOptions, false) {
+                       nullptr, nullptr, false) {
   Context.setObjectFileInfo(TM->getObjFileLowering());
   initialize();
 }
@@ -81,7 +81,7 @@ MachineModuleInfo::MachineModuleInfo(const LLVMTargetMachine *TM,
                                      MCContext *ExtContext)
     : TM(*TM), Context(TM->getTargetTriple(), TM->getMCAsmInfo(),
                        TM->getMCRegisterInfo(), TM->getMCSubtargetInfo(),
-                       nullptr, &TM->Options.MCOptions, false),
+                       nullptr, nullptr, false),
       ExternalContext(ExtContext) {
   Context.setObjectFileInfo(TM->getObjFileLowering());
   initialize();

diff  --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
index 4ac901daa5c83..ed912280ac826 100644
--- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -19,7 +19,6 @@
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Mangler.h"
 #include "llvm/IR/Module.h"
-#include "llvm/MC/MCContext.h"
 #include "llvm/Object/Archive.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/DynamicLibrary.h"

diff  --git a/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp b/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
index fad7428e1f906..f342470052581 100644
--- a/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp
@@ -12,7 +12,6 @@
 #include "llvm/ExecutionEngine/ObjectCache.h"
 #include "llvm/IR/LegacyPassManager.h"
 #include "llvm/IR/Module.h"
-#include "llvm/MC/MCContext.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"

diff  --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
index bc42eebf3fec9..820d1dbad8f20 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
@@ -95,16 +95,18 @@ void RTDyldMemoryManager::registerEHFramesInProcess(uint8_t *Addr,
   // and projects/libunwind/src/UnwindLevel1-gcc-ext.c.
   const char *P = (const char *)Addr;
   const char *End = P + Size;
-  while (P != End)
+  do  {
     P = processFDE(P, false);
+  } while(P != End);
 }
 
 void RTDyldMemoryManager::deregisterEHFramesInProcess(uint8_t *Addr,
                                                       size_t Size) {
   const char *P = (const char *)Addr;
   const char *End = P + Size;
-  while (P != End)
+  do  {
     P = processFDE(P, true);
+  } while(P != End);
 }
 
 #else

diff  --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 52bf48b6d242b..887969fcd8410 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -877,12 +877,6 @@ void MCContext::RemapDebugPaths() {
 // Dwarf Management
 //===----------------------------------------------------------------------===//
 
-EmitDwarfUnwindType MCContext::emitDwarfUnwindInfo() const {
-  if (!TargetOptions)
-    return EmitDwarfUnwindType::Default;
-  return TargetOptions->EmitDwarfUnwind;
-}
-
 void MCContext::setGenDwarfRootFile(StringRef InputFileName, StringRef Buffer) {
   // MCDwarf needs the root file as well as the compilation directory.
   // If we find a '.file 0' directive that will supersede these values.

diff  --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index d151b8b3f89a6..6152b3e5210e2 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -1842,6 +1842,8 @@ template <> struct DenseMapInfo<CIEKey> {
 
 void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
                                bool IsEH) {
+  Streamer.generateCompactUnwindEncodings(MAB);
+
   MCContext &Context = Streamer.getContext();
   const MCObjectFileInfo *MOFI = Context.getObjectFileInfo();
   const MCAsmInfo *AsmInfo = Context.getAsmInfo();
@@ -1851,7 +1853,6 @@ void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
   // Emit the compact unwind info if available.
   bool NeedsEHFrameSection = !MOFI->getSupportsCompactUnwindWithoutEHFrame();
   if (IsEH && MOFI->getCompactUnwindSection()) {
-    Streamer.generateCompactUnwindEncodings(MAB);
     bool SectionEmitted = false;
     for (const MCDwarfFrameInfo &Frame : FrameArray) {
       if (Frame.CompactUnwindEncoding == 0) continue;

diff  --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index bb39e5aaad7f4..0d08976d98942 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -64,18 +64,8 @@ void MCObjectFileInfo::initMachOMCObjectFileInfo(const Triple &T) {
       (T.getArch() == Triple::aarch64 || T.getArch() == Triple::aarch64_32))
     SupportsCompactUnwindWithoutEHFrame = true;
 
-  switch (Ctx->emitDwarfUnwindInfo()) {
-  case EmitDwarfUnwindType::Always:
-    OmitDwarfIfHaveCompactUnwind = false;
-    break;
-  case EmitDwarfUnwindType::NoCompactUnwind:
+  if (T.isWatchABI())
     OmitDwarfIfHaveCompactUnwind = true;
-    break;
-  case EmitDwarfUnwindType::Default:
-    OmitDwarfIfHaveCompactUnwind =
-        T.isWatchABI() || SupportsCompactUnwindWithoutEHFrame;
-    break;
-  }
 
   FDECFIEncoding = dwarf::DW_EH_PE_pcrel;
 

diff  --git a/llvm/lib/MC/MCTargetOptions.cpp b/llvm/lib/MC/MCTargetOptions.cpp
index c2946da3ee66f..bb48182c6622b 100644
--- a/llvm/lib/MC/MCTargetOptions.cpp
+++ b/llvm/lib/MC/MCTargetOptions.cpp
@@ -17,7 +17,6 @@ MCTargetOptions::MCTargetOptions()
       MCSaveTempLabels(false), MCIncrementalLinkerCompatible(false),
       ShowMCEncoding(false), ShowMCInst(false), AsmVerbose(false),
       PreserveAsmComments(true), Dwarf64(false),
-      EmitDwarfUnwind(EmitDwarfUnwindType::Default),
       MCUseDwarfDirectory(DefaultDwarfDirectory) {}
 
 StringRef MCTargetOptions::getABIName() const {

diff  --git a/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp b/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
index a310dc894021f..762c8d43063c7 100644
--- a/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
+++ b/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
@@ -1,4 +1,5 @@
-//===-- MCTargetOptionsCommandFlags.cpp -----------------------*- C++ //-*-===//
+//===-- MCTargetOptionsCommandFlags.cpp --------------------------*- C++
+//-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -38,7 +39,6 @@ MCOPT_EXP(bool, RelaxAll)
 MCOPT(bool, IncrementalLinkerCompatible)
 MCOPT(int, DwarfVersion)
 MCOPT(bool, Dwarf64)
-MCOPT(EmitDwarfUnwindType, EmitDwarfUnwind)
 MCOPT(bool, ShowMCInst)
 MCOPT(bool, FatalWarnings)
 MCOPT(bool, NoWarn)
@@ -73,19 +73,6 @@ llvm::mc::RegisterMCTargetOptionsFlags::RegisterMCTargetOptionsFlags() {
       cl::desc("Generate debugging info in the 64-bit DWARF format"));
   MCBINDOPT(Dwarf64);
 
-  static cl::opt<EmitDwarfUnwindType> EmitDwarfUnwind(
-      "emit-dwarf-unwind", cl::desc("Whether to emit DWARF EH frame entries."),
-      cl::init(EmitDwarfUnwindType::Default),
-      cl::values(clEnumValN(EmitDwarfUnwindType::Always, "always",
-                            "Always emit EH frame entries"),
-                 clEnumValN(EmitDwarfUnwindType::NoCompactUnwind,
-                            "no-compact-unwind",
-                            "Only emit EH frame entries when compact unwind is "
-                            "not available"),
-                 clEnumValN(EmitDwarfUnwindType::Default, "default",
-                            "Use target platform default")));
-  MCBINDOPT(EmitDwarfUnwind);
-
   static cl::opt<bool> ShowMCInst(
       "asm-show-inst",
       cl::desc("Emit internal instruction representation to assembly file"));
@@ -129,7 +116,5 @@ MCTargetOptions llvm::mc::InitMCTargetOptionsFromFlags() {
   Options.MCNoWarn = getNoWarn();
   Options.MCNoDeprecatedWarn = getNoDeprecatedWarn();
   Options.MCNoTypeCheck = getNoTypeCheck();
-  Options.EmitDwarfUnwind = getEmitDwarfUnwind();
-
   return Options;
 }

diff  --git a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
index 2d92b8d5b574b..f09c3b36ff3a8 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -1377,7 +1377,7 @@ class DarwinX86AsmBackend : public X86AsmBackend {
       default:
         // Any other CFI directives indicate a frame that we aren't prepared
         // to represent via compact unwind, so just bail out.
-        return CU::UNWIND_MODE_DWARF;
+        return 0;
       case MCCFIInstruction::OpDefCfaRegister: {
         // Defines a frame pointer. E.g.
         //
@@ -1391,7 +1391,7 @@ class DarwinX86AsmBackend : public X86AsmBackend {
         // generate a compact unwinding representation, so bail out.
         if (*MRI.getLLVMRegNum(Inst.getRegister(), true) !=
             (Is64Bit ? X86::RBP : X86::EBP))
-          return CU::UNWIND_MODE_DWARF;
+          return 0;
 
         // Reset the counts.
         memset(SavedRegs, 0, sizeof(SavedRegs));

diff  --git a/llvm/test/MC/MachO/emit-dwarf-unwind.s b/llvm/test/MC/MachO/emit-dwarf-unwind.s
deleted file mode 100644
index 89dc56b8aa87f..0000000000000
--- a/llvm/test/MC/MachO/emit-dwarf-unwind.s
+++ /dev/null
@@ -1,33 +0,0 @@
-// RUN: rm -rf %t; mkdir %t
-// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj -o %t/x86_64.o
-// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64.o | FileCheck %s --check-prefix TWO-FDES
-// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj -o %t/arm64.o
-// RUN: llvm-objdump --macho --dwarf=frames %t/arm64.o | FileCheck %s --check-prefix ONE-FDE
-// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind no-compact-unwind -o %t/x86_64-no-dwarf.o
-// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64-no-dwarf.o | FileCheck %s --check-prefix ONE-FDE
-// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind always -o %t/arm64-dwarf.o
-// RUN: llvm-objdump --macho --dwarf=frames %t/arm64-dwarf.o | FileCheck %s --check-prefix TWO-FDES
-
-// TWO-FDES: FDE
-// TWO-FDES: FDE
-
-// ONE-FDE-NOT: FDE
-// ONE-FDE:     FDE
-// ONE-FDE-NOT: FDE
-
-_main:
-  .cfi_startproc
-  .cfi_def_cfa_offset 16
-  ret
-  .cfi_endproc
-
-_foo:
-  .cfi_startproc
-  .cfi_def_cfa_offset 16
-  /// This encodes DW_CFA_GNU_args_size which cannot be expressed using compact
-  /// unwind, so we must use DWARf unwind for this function.
-  .cfi_escape 0x2e, 0x10
-  ret
-  .cfi_endproc
-
-.subsections_via_symbols

diff  --git a/llvm/test/MC/X86/compact-unwind-mode-dwarf.s b/llvm/test/MC/X86/compact-unwind-mode-dwarf.s
deleted file mode 100644
index ca051b07b59ef..0000000000000
--- a/llvm/test/MC/X86/compact-unwind-mode-dwarf.s
+++ /dev/null
@@ -1,50 +0,0 @@
-// RUN: llvm-mc -triple x86_64-apple-macos10.6 -filetype=obj %s -o %t.o
-// RUN: llvm-objdump --macho --unwind-info --dwarf=frames %t.o | FileCheck %s
-
-/// For functions whose unwind info cannot be encoded with compact unwind, make
-/// sure that we encode them using DWARF unwind, and make sure we emit a compact
-/// unwind entry that indicates that a DWARF encoding is being used.
-
-_f:
-  .cfi_startproc
-  ## This encodes DW_CFA_GNU_args_size which cannot be expressed using compact
-  ## unwind, so we must use DWARF unwind instead.
-  .cfi_escape 0x2e, 0x10
-  ret
-  .cfi_endproc
-
-_g:
-  .cfi_startproc
-  ## This encodes DW_CFA_GNU_args_size which cannot be expressed using compact
-  ## unwind, so we must use DWARF unwind instead.
-  .cfi_escape 0x2e, 0x10
-  ret
-  .cfi_endproc
-
-// CHECK: Contents of __compact_unwind section:
-// CHECK:   Entry at offset 0x0:
-// CHECK:     start:                0x[[#%x,F:]] _f
-// CHECK:     length:               0x1
-// CHECK:     compact encoding:     0x04000000
-// CHECK:   Entry at offset 0x20:
-// CHECK:     start:                0x[[#%x,G:]] _g
-// CHECK:     length:               0x1
-// CHECK:     compact encoding:     0x04000000
-
-// CHECK: .eh_frame contents:
-// CHECK: 00000000 00000014 00000000 CIE
-// CHECK:   Format:                DWARF32
-// CHECK:   Version:               1
-// CHECK:   Augmentation:          "zR"
-// CHECK:   Code alignment factor: 1
-// CHECK:   Data alignment factor: -8
-// CHECK:   Return address column: 16
-// CHECK:   Augmentation data:     10
-
-// CHECK: FDE cie=00000000 pc=[[#%.8x,F]]...
-// CHECK:   Format:       DWARF32
-// CHECK:   DW_CFA_GNU_args_size: +16
-
-// CHECK: FDE cie=00000000 pc=[[#%.8x,G]]...
-// CHECK:   Format:       DWARF32
-// CHECK:   DW_CFA_GNU_args_size: +16


        


More information about the llvm-commits mailing list