<div dir="ltr">Please include details about the reason for a revert in the revert commit message - helpful for folks following along/looking to see if a given revert addresses an issue they're seeing, etc.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 12, 2022 at 7:47 AM Jez Ng via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Author: Jez Ng<br>
Date: 2022-06-12T10:47:08-04:00<br>
New Revision: d941d597837d9e1405086f008c9bd6a71e7263c9<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/d941d597837d9e1405086f008c9bd6a71e7263c9" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/d941d597837d9e1405086f008c9bd6a71e7263c9</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/d941d597837d9e1405086f008c9bd6a71e7263c9.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/d941d597837d9e1405086f008c9bd6a71e7263c9.diff</a><br>
<br>
LOG: Revert "[MC] Omit DWARF unwind info if compact unwind is present where eligible"<br>
<br>
This reverts commit ef501bf85d8c869248e51371f0e74bcec0e7b229.<br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
    clang/include/clang/Basic/CodeGenOptions.def<br>
    clang/include/clang/Driver/Options.td<br>
    clang/lib/CodeGen/BackendUtil.cpp<br>
    clang/lib/Driver/ToolChains/Clang.cpp<br>
    clang/tools/driver/cc1as_main.cpp<br>
    llvm/include/llvm/MC/MCContext.h<br>
    llvm/include/llvm/MC/MCTargetOptions.h<br>
    llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h<br>
    llvm/lib/CodeGen/LLVMTargetMachine.cpp<br>
    llvm/lib/CodeGen/MachineModuleInfo.cpp<br>
    llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp<br>
    llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp<br>
    llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp<br>
    llvm/lib/MC/MCContext.cpp<br>
    llvm/lib/MC/MCDwarf.cpp<br>
    llvm/lib/MC/MCObjectFileInfo.cpp<br>
    llvm/lib/MC/MCTargetOptions.cpp<br>
    llvm/lib/MC/MCTargetOptionsCommandFlags.cpp<br>
    llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp<br>
<br>
Removed: <br>
    clang/test/Driver/femit-dwarf-unwind.c<br>
    clang/test/Driver/femit-dwarf-unwind.s<br>
    llvm/test/MC/MachO/emit-dwarf-unwind.s<br>
    llvm/test/MC/X86/compact-unwind-mode-dwarf.s<br>
<br>
<br>
################################################################################<br>
diff  --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def<br>
index 8e89106993c26..d8f667dc387bb 100644<br>
--- a/clang/include/clang/Basic/CodeGenOptions.def<br>
+++ b/clang/include/clang/Basic/CodeGenOptions.def<br>
@@ -114,10 +114,6 @@ CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is enabl<br>
 CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is<br>
                                           ///< enabled.<br>
<br>
-///< Set when -femit-dwarf-unwind is passed.<br>
-ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,<br>
-                llvm::EmitDwarfUnwindType::Default)<br>
-<br>
 ///< Set when -fxray-always-emit-customevents is enabled.<br>
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)<br>
<br>
<br>
diff  --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td<br>
index 002cd6cc8cb17..95840760f7746 100644<br>
--- a/clang/include/clang/Driver/Options.td<br>
+++ b/clang/include/clang/Driver/Options.td<br>
@@ -3044,13 +3044,6 @@ def fmacro_prefix_map_EQ<br>
 defm force_dwarf_frame : BoolFOption<"force-dwarf-frame",<br>
   CodeGenOpts<"ForceDwarfFrameSection">, DefaultFalse,<br>
   PosFlag<SetTrue, [CC1Option], "Always emit a debug frame section">, NegFlag<SetFalse>>;<br>
-def femit_dwarf_unwind_EQ : Joined<["-"], "femit-dwarf-unwind=">,<br>
-  Group<f_Group>, Flags<[CC1Option, CC1AsOption]>,<br>
-  HelpText<"When to emit DWARF unwind (EH frame) info">,<br>
-  Values<"always,no-compact-unwind,default">,<br>
-  NormalizedValues<["Always", "NoCompactUnwind", "Default"]>,<br>
-  NormalizedValuesScope<"llvm::EmitDwarfUnwindType">,<br>
-  MarshallingInfoEnum<CodeGenOpts<"EmitDwarfUnwind">, "Default">;<br>
 def g_Flag : Flag<["-"], "g">, Group<g_Group>,<br>
   HelpText<"Generate source-level debug information">;<br>
 def gline_tables_only : Flag<["-"], "gline-tables-only">, Group<gN_Group>,<br>
<br>
diff  --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp<br>
index 4b294c254e476..0de15b1e48078 100644<br>
--- a/clang/lib/CodeGen/BackendUtil.cpp<br>
+++ b/clang/lib/CodeGen/BackendUtil.cpp<br>
@@ -453,7 +453,6 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,<br>
   }<br>
<br>
   Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;<br>
-  Options.MCOptions.EmitDwarfUnwind = CodeGenOpts.getEmitDwarfUnwind();<br>
   Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;<br>
   Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;<br>
   Options.MCOptions.MCUseDwarfDirectory =<br>
<br>
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp<br>
index 62e891ce38c49..ceac142653ebe 100644<br>
--- a/clang/lib/Driver/ToolChains/Clang.cpp<br>
+++ b/clang/lib/Driver/ToolChains/Clang.cpp<br>
@@ -2518,8 +2518,6 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,<br>
                    DefaultIncrementalLinkerCompatible))<br>
     CmdArgs.push_back("-mincremental-linker-compatible");<br>
<br>
-  Args.AddLastArg(CmdArgs, options::OPT_femit_dwarf_unwind_EQ);<br>
-<br>
   // If you add more args here, also add them to the block below that<br>
   // starts with "// If CollectArgsForIntegratedAssembler() isn't called below".<br>
<br>
@@ -4624,7 +4622,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,<br>
     }<br>
     Args.ClaimAllArgs(options::OPT_Wa_COMMA);<br>
     Args.ClaimAllArgs(options::OPT_Xassembler);<br>
-    Args.ClaimAllArgs(options::OPT_femit_dwarf_unwind_EQ);<br>
   }<br>
<br>
   if (isa<AnalyzeJobAction>(JA)) {<br>
<br>
diff  --git a/clang/test/Driver/femit-dwarf-unwind.c b/clang/test/Driver/femit-dwarf-unwind.c<br>
deleted file mode 100644<br>
index 3101e1db7b9d4..0000000000000<br>
--- a/clang/test/Driver/femit-dwarf-unwind.c<br>
+++ /dev/null<br>
@@ -1,12 +0,0 @@<br>
-// RUN: rm -rf %t; mkdir %t<br>
-// RUN: %clang -target x86_64-apple-macos11.0 -c %s -o %t/x86_64.o<br>
-// RUN: %clang -target x86_64-apple-macos11.0 -femit-dwarf-unwind=no-compact-unwind -c %s -o %t/x86_64-no-dwarf.o<br>
-// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64.o | FileCheck %s --check-prefix=WITH-FDE<br>
-// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64-no-dwarf.o | FileCheck %s --check-prefix=NO-FDE<br>
-<br>
-// WITH-FDE: FDE<br>
-// NO-FDE-NOT: FDE<br>
-<br>
-int foo() {<br>
-  return 1;<br>
-}<br>
<br>
diff  --git a/clang/test/Driver/femit-dwarf-unwind.s b/clang/test/Driver/femit-dwarf-unwind.s<br>
deleted file mode 100644<br>
index 881925c76abd4..0000000000000<br>
--- a/clang/test/Driver/femit-dwarf-unwind.s<br>
+++ /dev/null<br>
@@ -1,15 +0,0 @@<br>
-// RUN: rm -rf %t; mkdir %t<br>
-// RUN: %clang -target x86_64-apple-macos11.0 -c %s -o %t/x86_64.o<br>
-// RUN: %clang -target x86_64-apple-macos11.0 -femit-dwarf-unwind=no-compact-unwind -c %s -o %t/x86_64-no-dwarf.o<br>
-// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64.o | FileCheck %s --check-prefix=WITH-FDE<br>
-// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64-no-dwarf.o | FileCheck %s --check-prefix=NO-FDE<br>
-<br>
-// WITH-FDE: FDE<br>
-// NO-FDE-NOT: FDE<br>
-<br>
-.text<br>
-_foo:<br>
-  .cfi_startproc<br>
-  .cfi_def_cfa_offset 8<br>
-  ret<br>
-  .cfi_endproc<br>
<br>
diff  --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp<br>
index 264f747d6d740..6a11c25553ba3 100644<br>
--- a/clang/tools/driver/cc1as_main.cpp<br>
+++ b/clang/tools/driver/cc1as_main.cpp<br>
@@ -137,9 +137,6 @@ struct AssemblerInvocation {<br>
   unsigned IncrementalLinkerCompatible : 1;<br>
   unsigned EmbedBitcode : 1;<br>
<br>
-  /// Whether to emit DWARF unwind info.<br>
-  EmitDwarfUnwindType EmitDwarfUnwind;<br>
-<br>
   /// The name of the relocation model to use.<br>
   std::string RelocationModel;<br>
<br>
@@ -320,14 +317,6 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,<br>
                             .Default(0);<br>
   }<br>
<br>
-  if (auto *A = Args.getLastArg(OPT_femit_dwarf_unwind_EQ)) {<br>
-    Opts.EmitDwarfUnwind =<br>
-        llvm::StringSwitch<EmitDwarfUnwindType>(A->getValue())<br>
-            .Case("always", EmitDwarfUnwindType::Always)<br>
-            .Case("no-compact-unwind", EmitDwarfUnwindType::NoCompactUnwind)<br>
-            .Case("default", EmitDwarfUnwindType::Default);<br>
-  }<br>
-<br>
   return Success;<br>
 }<br>
<br>
@@ -378,8 +367,6 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,<br>
   assert(MRI && "Unable to create target register info!");<br>
<br>
   MCTargetOptions MCOptions;<br>
-  MCOptions.EmitDwarfUnwind = Opts.EmitDwarfUnwind;<br>
-<br>
   std::unique_ptr<MCAsmInfo> MAI(<br>
       TheTarget->createMCAsmInfo(*MRI, Opts.Triple, MCOptions));<br>
   assert(MAI && "Unable to create target asm info!");<br>
<br>
diff  --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h<br>
index c3a4e57fdd753..5b81ba31b83c5 100644<br>
--- a/llvm/include/llvm/MC/MCContext.h<br>
+++ b/llvm/include/llvm/MC/MCContext.h<br>
@@ -67,7 +67,6 @@ template <typename T> class SmallVectorImpl;<br>
 class SMDiagnostic;<br>
 class SMLoc;<br>
 class SourceMgr;<br>
-enum class EmitDwarfUnwindType;<br>
<br>
 /// Context object for machine code objects.  This class owns all of the<br>
 /// sections that it creates.<br>
@@ -773,7 +772,6 @@ class MCContext {<br>
   bool getGenDwarfForAssembly() { return GenDwarfForAssembly; }<br>
   void setGenDwarfForAssembly(bool Value) { GenDwarfForAssembly = Value; }<br>
   unsigned getGenDwarfFileNumber() { return GenDwarfFileNumber; }<br>
-  EmitDwarfUnwindType emitDwarfUnwindInfo() const;<br>
<br>
   void setGenDwarfFileNumber(unsigned FileNumber) {<br>
     GenDwarfFileNumber = FileNumber;<br>
<br>
diff  --git a/llvm/include/llvm/MC/MCTargetOptions.h b/llvm/include/llvm/MC/MCTargetOptions.h<br>
index 9c906cdc90d02..93712a6b7d44b 100644<br>
--- a/llvm/include/llvm/MC/MCTargetOptions.h<br>
+++ b/llvm/include/llvm/MC/MCTargetOptions.h<br>
@@ -31,12 +31,6 @@ enum class DebugCompressionType {<br>
   Z,    ///< zlib style complession<br>
 };<br>
<br>
-enum class EmitDwarfUnwindType {<br>
-  Always,          // Always emit dwarf unwind<br>
-  NoCompactUnwind, // Only emit if compact unwind isn't available<br>
-  Default,         // Default behavior is based on the target<br>
-};<br>
-<br>
 class StringRef;<br>
<br>
 class MCTargetOptions {<br>
@@ -62,9 +56,6 @@ class MCTargetOptions {<br>
   bool PreserveAsmComments : 1;<br>
<br>
   bool Dwarf64 : 1;<br>
-<br>
-  EmitDwarfUnwindType EmitDwarfUnwind;<br>
-<br>
   int DwarfVersion = 0;<br>
<br>
   enum DwarfDirectory {<br>
<br>
diff  --git a/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h b/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h<br>
index d51e740177f77..1894841989166 100644<br>
--- a/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h<br>
+++ b/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h<br>
@@ -20,7 +20,6 @@<br>
 namespace llvm {<br>
<br>
 class MCTargetOptions;<br>
-enum class EmitDwarfUnwindType;<br>
<br>
 namespace mc {<br>
<br>
@@ -33,8 +32,6 @@ int getDwarfVersion();<br>
<br>
 bool getDwarf64();<br>
<br>
-EmitDwarfUnwindType getEmitDwarfUnwind();<br>
-<br>
 bool getShowMCInst();<br>
<br>
 bool getFatalWarnings();<br>
<br>
diff  --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp<br>
index 3192dcadb5f5e..af05dbced04e1 100644<br>
--- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp<br>
+++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp<br>
@@ -264,9 +264,6 @@ bool LLVMTargetMachine::addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx,<br>
          "Cannot emit MC with limited codegen pipeline");<br>
<br>
   Ctx = &MMIWP->getMMI().getContext();<br>
-  // libunwind is unable to load compact unwind dynamically, so we must generate<br>
-  // DWARF unwind info for the JIT.<br>
-  Options.MCOptions.EmitDwarfUnwind = EmitDwarfUnwindType::Always;<br>
   if (Options.MCOptions.MCSaveTempLabels)<br>
     Ctx->setAllowTemporaryLabels(false);<br>
<br>
<br>
diff  --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp<br>
index 23d55a5df9f57..07ada255eb83d 100644<br>
--- a/llvm/lib/CodeGen/MachineModuleInfo.cpp<br>
+++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp<br>
@@ -60,7 +60,7 @@ MachineModuleInfo::MachineModuleInfo(MachineModuleInfo &&MMI)<br>
     : TM(std::move(<a href="http://MMI.TM" rel="noreferrer" target="_blank">MMI.TM</a>)),<br>
       Context(<a href="http://MMI.TM" target="_blank">MMI.TM</a>.getTargetTriple(), MMI.TM.getMCAsmInfo(),<br>
               MMI.TM.getMCRegisterInfo(), MMI.TM.getMCSubtargetInfo(), nullptr,<br>
-              &MMI.TM.Options.MCOptions, false),<br>
+              nullptr, false),<br>
       MachineFunctions(std::move(MMI.MachineFunctions)) {<br>
   Context.setObjectFileInfo(MMI.TM.getObjFileLowering());<br>
   ObjFileMMI = MMI.ObjFileMMI;<br>
@@ -72,7 +72,7 @@ MachineModuleInfo::MachineModuleInfo(MachineModuleInfo &&MMI)<br>
 MachineModuleInfo::MachineModuleInfo(const LLVMTargetMachine *TM)<br>
     : TM(*TM), Context(TM->getTargetTriple(), TM->getMCAsmInfo(),<br>
                        TM->getMCRegisterInfo(), TM->getMCSubtargetInfo(),<br>
-                       nullptr, &TM->Options.MCOptions, false) {<br>
+                       nullptr, nullptr, false) {<br>
   Context.setObjectFileInfo(TM->getObjFileLowering());<br>
   initialize();<br>
 }<br>
@@ -81,7 +81,7 @@ MachineModuleInfo::MachineModuleInfo(const LLVMTargetMachine *TM,<br>
                                      MCContext *ExtContext)<br>
     : TM(*TM), Context(TM->getTargetTriple(), TM->getMCAsmInfo(),<br>
                        TM->getMCRegisterInfo(), TM->getMCSubtargetInfo(),<br>
-                       nullptr, &TM->Options.MCOptions, false),<br>
+                       nullptr, nullptr, false),<br>
       ExternalContext(ExtContext) {<br>
   Context.setObjectFileInfo(TM->getObjFileLowering());<br>
   initialize();<br>
<br>
diff  --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp<br>
index 4ac901daa5c83..ed912280ac826 100644<br>
--- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp<br>
+++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp<br>
@@ -19,7 +19,6 @@<br>
 #include "llvm/IR/LegacyPassManager.h"<br>
 #include "llvm/IR/Mangler.h"<br>
 #include "llvm/IR/Module.h"<br>
-#include "llvm/MC/MCContext.h"<br>
 #include "llvm/Object/Archive.h"<br>
 #include "llvm/Object/ObjectFile.h"<br>
 #include "llvm/Support/DynamicLibrary.h"<br>
<br>
diff  --git a/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp b/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp<br>
index fad7428e1f906..f342470052581 100644<br>
--- a/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp<br>
+++ b/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp<br>
@@ -12,7 +12,6 @@<br>
 #include "llvm/ExecutionEngine/ObjectCache.h"<br>
 #include "llvm/IR/LegacyPassManager.h"<br>
 #include "llvm/IR/Module.h"<br>
-#include "llvm/MC/MCContext.h"<br>
 #include "llvm/Object/ObjectFile.h"<br>
 #include "llvm/Support/Error.h"<br>
 #include "llvm/Support/ErrorHandling.h"<br>
<br>
diff  --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp<br>
index bc42eebf3fec9..820d1dbad8f20 100644<br>
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp<br>
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp<br>
@@ -95,16 +95,18 @@ void RTDyldMemoryManager::registerEHFramesInProcess(uint8_t *Addr,<br>
   // and projects/libunwind/src/UnwindLevel1-gcc-ext.c.<br>
   const char *P = (const char *)Addr;<br>
   const char *End = P + Size;<br>
-  while (P != End)<br>
+  do  {<br>
     P = processFDE(P, false);<br>
+  } while(P != End);<br>
 }<br>
<br>
 void RTDyldMemoryManager::deregisterEHFramesInProcess(uint8_t *Addr,<br>
                                                       size_t Size) {<br>
   const char *P = (const char *)Addr;<br>
   const char *End = P + Size;<br>
-  while (P != End)<br>
+  do  {<br>
     P = processFDE(P, true);<br>
+  } while(P != End);<br>
 }<br>
<br>
 #else<br>
<br>
diff  --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp<br>
index 52bf48b6d242b..887969fcd8410 100644<br>
--- a/llvm/lib/MC/MCContext.cpp<br>
+++ b/llvm/lib/MC/MCContext.cpp<br>
@@ -877,12 +877,6 @@ void MCContext::RemapDebugPaths() {<br>
 // Dwarf Management<br>
 //===----------------------------------------------------------------------===//<br>
<br>
-EmitDwarfUnwindType MCContext::emitDwarfUnwindInfo() const {<br>
-  if (!TargetOptions)<br>
-    return EmitDwarfUnwindType::Default;<br>
-  return TargetOptions->EmitDwarfUnwind;<br>
-}<br>
-<br>
 void MCContext::setGenDwarfRootFile(StringRef InputFileName, StringRef Buffer) {<br>
   // MCDwarf needs the root file as well as the compilation directory.<br>
   // If we find a '.file 0' directive that will supersede these values.<br>
<br>
diff  --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp<br>
index d151b8b3f89a6..6152b3e5210e2 100644<br>
--- a/llvm/lib/MC/MCDwarf.cpp<br>
+++ b/llvm/lib/MC/MCDwarf.cpp<br>
@@ -1842,6 +1842,8 @@ template <> struct DenseMapInfo<CIEKey> {<br>
<br>
 void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,<br>
                                bool IsEH) {<br>
+  Streamer.generateCompactUnwindEncodings(MAB);<br>
+<br>
   MCContext &Context = Streamer.getContext();<br>
   const MCObjectFileInfo *MOFI = Context.getObjectFileInfo();<br>
   const MCAsmInfo *AsmInfo = Context.getAsmInfo();<br>
@@ -1851,7 +1853,6 @@ void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,<br>
   // Emit the compact unwind info if available.<br>
   bool NeedsEHFrameSection = !MOFI->getSupportsCompactUnwindWithoutEHFrame();<br>
   if (IsEH && MOFI->getCompactUnwindSection()) {<br>
-    Streamer.generateCompactUnwindEncodings(MAB);<br>
     bool SectionEmitted = false;<br>
     for (const MCDwarfFrameInfo &Frame : FrameArray) {<br>
       if (Frame.CompactUnwindEncoding == 0) continue;<br>
<br>
diff  --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp<br>
index bb39e5aaad7f4..0d08976d98942 100644<br>
--- a/llvm/lib/MC/MCObjectFileInfo.cpp<br>
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp<br>
@@ -64,18 +64,8 @@ void MCObjectFileInfo::initMachOMCObjectFileInfo(const Triple &T) {<br>
       (T.getArch() == Triple::aarch64 || T.getArch() == Triple::aarch64_32))<br>
     SupportsCompactUnwindWithoutEHFrame = true;<br>
<br>
-  switch (Ctx->emitDwarfUnwindInfo()) {<br>
-  case EmitDwarfUnwindType::Always:<br>
-    OmitDwarfIfHaveCompactUnwind = false;<br>
-    break;<br>
-  case EmitDwarfUnwindType::NoCompactUnwind:<br>
+  if (T.isWatchABI())<br>
     OmitDwarfIfHaveCompactUnwind = true;<br>
-    break;<br>
-  case EmitDwarfUnwindType::Default:<br>
-    OmitDwarfIfHaveCompactUnwind =<br>
-        T.isWatchABI() || SupportsCompactUnwindWithoutEHFrame;<br>
-    break;<br>
-  }<br>
<br>
   FDECFIEncoding = dwarf::DW_EH_PE_pcrel;<br>
<br>
<br>
diff  --git a/llvm/lib/MC/MCTargetOptions.cpp b/llvm/lib/MC/MCTargetOptions.cpp<br>
index c2946da3ee66f..bb48182c6622b 100644<br>
--- a/llvm/lib/MC/MCTargetOptions.cpp<br>
+++ b/llvm/lib/MC/MCTargetOptions.cpp<br>
@@ -17,7 +17,6 @@ MCTargetOptions::MCTargetOptions()<br>
       MCSaveTempLabels(false), MCIncrementalLinkerCompatible(false),<br>
       ShowMCEncoding(false), ShowMCInst(false), AsmVerbose(false),<br>
       PreserveAsmComments(true), Dwarf64(false),<br>
-      EmitDwarfUnwind(EmitDwarfUnwindType::Default),<br>
       MCUseDwarfDirectory(DefaultDwarfDirectory) {}<br>
<br>
 StringRef MCTargetOptions::getABIName() const {<br>
<br>
diff  --git a/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp b/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp<br>
index a310dc894021f..762c8d43063c7 100644<br>
--- a/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp<br>
+++ b/llvm/lib/MC/MCTargetOptionsCommandFlags.cpp<br>
@@ -1,4 +1,5 @@<br>
-//===-- MCTargetOptionsCommandFlags.cpp -----------------------*- C++ //-*-===//<br>
+//===-- MCTargetOptionsCommandFlags.cpp --------------------------*- C++<br>
+//-*-===//<br>
 //<br>
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.<br>
 // See <a href="https://llvm.org/LICENSE.txt" rel="noreferrer" target="_blank">https://llvm.org/LICENSE.txt</a> for license information.<br>
@@ -38,7 +39,6 @@ MCOPT_EXP(bool, RelaxAll)<br>
 MCOPT(bool, IncrementalLinkerCompatible)<br>
 MCOPT(int, DwarfVersion)<br>
 MCOPT(bool, Dwarf64)<br>
-MCOPT(EmitDwarfUnwindType, EmitDwarfUnwind)<br>
 MCOPT(bool, ShowMCInst)<br>
 MCOPT(bool, FatalWarnings)<br>
 MCOPT(bool, NoWarn)<br>
@@ -73,19 +73,6 @@ llvm::mc::RegisterMCTargetOptionsFlags::RegisterMCTargetOptionsFlags() {<br>
       cl::desc("Generate debugging info in the 64-bit DWARF format"));<br>
   MCBINDOPT(Dwarf64);<br>
<br>
-  static cl::opt<EmitDwarfUnwindType> EmitDwarfUnwind(<br>
-      "emit-dwarf-unwind", cl::desc("Whether to emit DWARF EH frame entries."),<br>
-      cl::init(EmitDwarfUnwindType::Default),<br>
-      cl::values(clEnumValN(EmitDwarfUnwindType::Always, "always",<br>
-                            "Always emit EH frame entries"),<br>
-                 clEnumValN(EmitDwarfUnwindType::NoCompactUnwind,<br>
-                            "no-compact-unwind",<br>
-                            "Only emit EH frame entries when compact unwind is "<br>
-                            "not available"),<br>
-                 clEnumValN(EmitDwarfUnwindType::Default, "default",<br>
-                            "Use target platform default")));<br>
-  MCBINDOPT(EmitDwarfUnwind);<br>
-<br>
   static cl::opt<bool> ShowMCInst(<br>
       "asm-show-inst",<br>
       cl::desc("Emit internal instruction representation to assembly file"));<br>
@@ -129,7 +116,5 @@ MCTargetOptions llvm::mc::InitMCTargetOptionsFromFlags() {<br>
   Options.MCNoWarn = getNoWarn();<br>
   Options.MCNoDeprecatedWarn = getNoDeprecatedWarn();<br>
   Options.MCNoTypeCheck = getNoTypeCheck();<br>
-  Options.EmitDwarfUnwind = getEmitDwarfUnwind();<br>
-<br>
   return Options;<br>
 }<br>
<br>
diff  --git a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp<br>
index 2d92b8d5b574b..f09c3b36ff3a8 100644<br>
--- a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp<br>
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp<br>
@@ -1377,7 +1377,7 @@ class DarwinX86AsmBackend : public X86AsmBackend {<br>
       default:<br>
         // Any other CFI directives indicate a frame that we aren't prepared<br>
         // to represent via compact unwind, so just bail out.<br>
-        return CU::UNWIND_MODE_DWARF;<br>
+        return 0;<br>
       case MCCFIInstruction::OpDefCfaRegister: {<br>
         // Defines a frame pointer. E.g.<br>
         //<br>
@@ -1391,7 +1391,7 @@ class DarwinX86AsmBackend : public X86AsmBackend {<br>
         // generate a compact unwinding representation, so bail out.<br>
         if (*MRI.getLLVMRegNum(Inst.getRegister(), true) !=<br>
             (Is64Bit ? X86::RBP : X86::EBP))<br>
-          return CU::UNWIND_MODE_DWARF;<br>
+          return 0;<br>
<br>
         // Reset the counts.<br>
         memset(SavedRegs, 0, sizeof(SavedRegs));<br>
<br>
diff  --git a/llvm/test/MC/MachO/emit-dwarf-unwind.s b/llvm/test/MC/MachO/emit-dwarf-unwind.s<br>
deleted file mode 100644<br>
index 89dc56b8aa87f..0000000000000<br>
--- a/llvm/test/MC/MachO/emit-dwarf-unwind.s<br>
+++ /dev/null<br>
@@ -1,33 +0,0 @@<br>
-// RUN: rm -rf %t; mkdir %t<br>
-// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj -o %t/x86_64.o<br>
-// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64.o | FileCheck %s --check-prefix TWO-FDES<br>
-// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj -o %t/arm64.o<br>
-// RUN: llvm-objdump --macho --dwarf=frames %t/arm64.o | FileCheck %s --check-prefix ONE-FDE<br>
-// 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<br>
-// RUN: llvm-objdump --macho --dwarf=frames %t/x86_64-no-dwarf.o | FileCheck %s --check-prefix ONE-FDE<br>
-// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind always -o %t/arm64-dwarf.o<br>
-// RUN: llvm-objdump --macho --dwarf=frames %t/arm64-dwarf.o | FileCheck %s --check-prefix TWO-FDES<br>
-<br>
-// TWO-FDES: FDE<br>
-// TWO-FDES: FDE<br>
-<br>
-// ONE-FDE-NOT: FDE<br>
-// ONE-FDE:     FDE<br>
-// ONE-FDE-NOT: FDE<br>
-<br>
-_main:<br>
-  .cfi_startproc<br>
-  .cfi_def_cfa_offset 16<br>
-  ret<br>
-  .cfi_endproc<br>
-<br>
-_foo:<br>
-  .cfi_startproc<br>
-  .cfi_def_cfa_offset 16<br>
-  /// This encodes DW_CFA_GNU_args_size which cannot be expressed using compact<br>
-  /// unwind, so we must use DWARf unwind for this function.<br>
-  .cfi_escape 0x2e, 0x10<br>
-  ret<br>
-  .cfi_endproc<br>
-<br>
-.subsections_via_symbols<br>
<br>
diff  --git a/llvm/test/MC/X86/compact-unwind-mode-dwarf.s b/llvm/test/MC/X86/compact-unwind-mode-dwarf.s<br>
deleted file mode 100644<br>
index ca051b07b59ef..0000000000000<br>
--- a/llvm/test/MC/X86/compact-unwind-mode-dwarf.s<br>
+++ /dev/null<br>
@@ -1,50 +0,0 @@<br>
-// RUN: llvm-mc -triple x86_64-apple-macos10.6 -filetype=obj %s -o %t.o<br>
-// RUN: llvm-objdump --macho --unwind-info --dwarf=frames %t.o | FileCheck %s<br>
-<br>
-/// For functions whose unwind info cannot be encoded with compact unwind, make<br>
-/// sure that we encode them using DWARF unwind, and make sure we emit a compact<br>
-/// unwind entry that indicates that a DWARF encoding is being used.<br>
-<br>
-_f:<br>
-  .cfi_startproc<br>
-  ## This encodes DW_CFA_GNU_args_size which cannot be expressed using compact<br>
-  ## unwind, so we must use DWARF unwind instead.<br>
-  .cfi_escape 0x2e, 0x10<br>
-  ret<br>
-  .cfi_endproc<br>
-<br>
-_g:<br>
-  .cfi_startproc<br>
-  ## This encodes DW_CFA_GNU_args_size which cannot be expressed using compact<br>
-  ## unwind, so we must use DWARF unwind instead.<br>
-  .cfi_escape 0x2e, 0x10<br>
-  ret<br>
-  .cfi_endproc<br>
-<br>
-// CHECK: Contents of __compact_unwind section:<br>
-// CHECK:   Entry at offset 0x0:<br>
-// CHECK:     start:                0x[[#%x,F:]] _f<br>
-// CHECK:     length:               0x1<br>
-// CHECK:     compact encoding:     0x04000000<br>
-// CHECK:   Entry at offset 0x20:<br>
-// CHECK:     start:                0x[[#%x,G:]] _g<br>
-// CHECK:     length:               0x1<br>
-// CHECK:     compact encoding:     0x04000000<br>
-<br>
-// CHECK: .eh_frame contents:<br>
-// CHECK: 00000000 00000014 00000000 CIE<br>
-// CHECK:   Format:                DWARF32<br>
-// CHECK:   Version:               1<br>
-// CHECK:   Augmentation:          "zR"<br>
-// CHECK:   Code alignment factor: 1<br>
-// CHECK:   Data alignment factor: -8<br>
-// CHECK:   Return address column: 16<br>
-// CHECK:   Augmentation data:     10<br>
-<br>
-// CHECK: FDE cie=00000000 pc=[[#%.8x,F]]...<br>
-// CHECK:   Format:       DWARF32<br>
-// CHECK:   DW_CFA_GNU_args_size: +16<br>
-<br>
-// CHECK: FDE cie=00000000 pc=[[#%.8x,G]]...<br>
-// CHECK:   Format:       DWARF32<br>
-// CHECK:   DW_CFA_GNU_args_size: +16<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>