Revert r148686 (and r148694, a fix to it) due to a serious layering
authorChandler Carruth <chandlerc@gmail.com>
Tue, 24 Jan 2012 00:30:17 +0000 (00:30 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 24 Jan 2012 00:30:17 +0000 (00:30 +0000)
violation -- MC cannot depend on CodeGen.

Specifically, the MCTargetDesc component of each target is actually
a subcomponent of the MC library. As such, it cannot depend on the
target-independent code generator, because MC itself cannot depend on
the target-independent code generator. This change moved a flag from the
ARM MCTargetDesc file ARMMCAsmInfo.cpp to the CodeGen layer in
ARMException.cpp, leaving behind an 'extern' to refer back to it. That
layering order isn't viable givin the constraints outlined above.
Commandline flags are designed to be static specifically to avoid these
types of bugs.

Fixing this is likely going to require some non-trivial refactoring.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148759 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCAsmInfo.h
lib/CodeGen/AsmPrinter/ARMException.cpp
lib/Target/ARM/ARMAsmPrinter.cpp
lib/Target/ARM/MCTargetDesc/ARMMCAsmInfo.cpp
test/CodeGen/ARM/ehabi-unwind.ll

index ded30d824ec6e8987aef7134f1ff746fbdb9f7d8..5accabcd9f4efcaaf75be7d5b175db53d06c242a 100644 (file)
@@ -30,7 +30,6 @@ namespace llvm {
 
   namespace ExceptionHandling {
     enum ExceptionsType { None, DwarfCFI, SjLj, ARM, Win64 };
-    enum ARMEHABIMode { ARMEHABIDisabled, ARMEHABIUnwind, ARMEHABIFull };
   }
 
   namespace LCOMM {
index e5a7d05f4c598a72cde1aeaebb5281120c9f8c11..3f2387325360032896473cd2810a31f171aea311 100644 (file)
@@ -29,7 +29,6 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Target/TargetRegisterInfo.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/FormattedStream.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/Twine.h"
 using namespace llvm;
 
-cl::opt<ExceptionHandling::ARMEHABIMode>
-EnableARMEHABI("arm-enable-ehabi", cl::Hidden,
-    cl::desc("Generate ARM EHABI tables:"),
-    cl::values(clEnumValN(ExceptionHandling::ARMEHABIDisabled, "no",
-            "Do not generate ARM EHABI tables"),
-        clEnumValN(ExceptionHandling::ARMEHABIUnwind, "unwind",
-            "Emit unwinding instructions, but not descriptors"),
-        clEnumValN(ExceptionHandling::ARMEHABIFull, "full",
-            "Generate full ARM EHABI tables"),
-        clEnumValEnd));
-
-
 ARMException::ARMException(AsmPrinter *A)
   : DwarfException(A),
     shouldEmitTable(false), shouldEmitMoves(false), shouldEmitTableModule(false)
@@ -85,15 +72,13 @@ void ARMException::EndFunction() {
       Asm->OutStreamer.EmitPersonality(PerSym);
     }
 
-    if (EnableARMEHABI == ExceptionHandling::ARMEHABIFull) {
-      // Map all labels and get rid of any dead landing pads.
-      MMI->TidyLandingPads();
+    // Map all labels and get rid of any dead landing pads.
+    MMI->TidyLandingPads();
 
-      Asm->OutStreamer.EmitHandlerData();
+    Asm->OutStreamer.EmitHandlerData();
 
-      // Emit actual exception table
-      EmitExceptionTable();
-    }
+    // Emit actual exception table
+    EmitExceptionTable();
   }
 
   Asm->OutStreamer.EmitFnEnd();
index e0b08f1f48ed4841533ef021b86c1341bc6c85a8..288b7f14e4c4b6520a7c45ef5c1258ac60ed3488 100644 (file)
@@ -1192,7 +1192,7 @@ void ARMAsmPrinter::EmitUnwindingInstruction(const MachineInstr *MI) {
   }
 }
 
-extern cl::opt<ExceptionHandling::ARMEHABIMode> EnableARMEHABI;
+extern cl::opt<bool> EnableARMEHABI;
 
 // Simple pseudo-instructions have their lowering (with expansion to real
 // instructions) auto-generated.
@@ -1203,8 +1203,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
     OutStreamer.EmitCodeRegion();
 
   // Emit unwinding stuff for frame-related instructions
-  if (EnableARMEHABI != ExceptionHandling::ARMEHABIDisabled &&
-      MI->getFlag(MachineInstr::FrameSetup))
+  if (EnableARMEHABI && MI->getFlag(MachineInstr::FrameSetup))
     EmitUnwindingInstruction(MI);
 
   // Do any auto-generated pseudo lowerings.
index db21defb7c9d12b57b8580f7a44be4a1fa7a1c18..d1804a2e45b1e74790c4fabd14e5eb9fe2f02d7a 100644 (file)
 
 using namespace llvm;
 
-extern cl::opt<ExceptionHandling::ARMEHABIMode> EnableARMEHABI;
+cl::opt<bool>
+EnableARMEHABI("arm-enable-ehabi", cl::Hidden,
+  cl::desc("Generate ARM EHABI tables"),
+  cl::init(false));
 
 
 static const char *const arm_asm_table[] = {
@@ -79,6 +82,6 @@ ARMELFMCAsmInfo::ARMELFMCAsmInfo() {
   SupportsDebugInformation = true;
 
   // Exceptions handling
-  if (EnableARMEHABI != ExceptionHandling::ARMEHABIDisabled)
+  if (EnableARMEHABI)
     ExceptionsType = ExceptionHandling::ARM;
 }
index 51595677b70de0712bcf6a1d6cc770d1a539e3a6..1ffde00365a72d426a668a6949ed987a2df3b19b 100644 (file)
@@ -1,8 +1,7 @@
 ; Test that the EHABI unwind instruction generator does not encounter any
 ; unfamiliar instructions.
-; RUN: llc < %s -mtriple=thumbv7 -arm-enable-ehabi=full -disable-fp-elim
-; RUN: llc < %s -mtriple=thumbv7 -arm-enable-ehabi=full
-; RUN: llc < %s -mtriple=thumbv7 -arm-enable-ehabi=unwind
+; RUN: llc < %s -mtriple=thumbv7 -arm-enable-ehabi -disable-fp-elim
+; RUN: llc < %s -mtriple=thumbv7 -arm-enable-ehabi
 
 define void @_Z1fv() nounwind {
 entry: