Fix and enable EH for x86-64 Darwin. Adds
authorDale Johannesen <dalej@apple.com>
Tue, 15 Jan 2008 23:24:56 +0000 (23:24 +0000)
committerDale Johannesen <dalej@apple.com>
Tue, 15 Jan 2008 23:24:56 +0000 (23:24 +0000)
ShortenEHDataFor64Bits as a not-very-accurate
abstraction to cover all the changes in DwarfWriter.
Some cosmetic changes to Darwin assembly code for
gcc testsuite compatibility.

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

include/llvm/Target/TargetAsmInfo.h
lib/CodeGen/DwarfWriter.cpp
lib/Target/PowerPC/PPCTargetAsmInfo.cpp
lib/Target/X86/X86AsmPrinter.cpp
lib/Target/X86/X86TargetAsmInfo.cpp

index 8192b46f8dfe0eecc1048ef70021294bb907888f..f40fdb5a414f7d48dd8215f75922131fc2385153 100644 (file)
@@ -313,6 +313,10 @@ namespace llvm {
     /// handle a weak_definition of constant 0 for an omitted EH frame.
     bool SupportsWeakOmittedEHFrame;  // Defaults to true.
 
+    /// ShortenEHDataON64Bit - True if target exception table format requires
+    /// 32-bit data in certain places even when targeting 64-bits.
+    bool ShortenEHDataOn64Bit;    // Defaults to false.
+
     /// DwarfSectionOffsetDirective - Special section offset directive.
     const char* DwarfSectionOffsetDirective; // Defaults to NULL
     
@@ -592,6 +596,9 @@ namespace llvm {
     bool getSupportsWeakOmittedEHFrame() const {
       return SupportsWeakOmittedEHFrame;
     }
+    bool getShortenEHDataOn64Bit() const {
+      return ShortenEHDataOn64Bit;
+    }
     const char *getDwarfSectionOffsetDirective() const {
       return DwarfSectionOffsetDirective;
     }    
index 1f7618a533a2582b8d57d0176a64384a30088a25..8b315be7a55de45ab1aa627220e89fede30dc441 100644 (file)
@@ -2835,11 +2835,13 @@ private:
 
       Asm->EOL("Personality (pcrel sdata4 indirect)");
       
-      PrintRelDirective();
+      PrintRelDirective(TAI->getShortenEHDataOn64Bit());
       O << TAI->getPersonalityPrefix();
       Asm->EmitExternalGlobal((const GlobalVariable *)(Personality));
       O << TAI->getPersonalitySuffix();
-      O << "-" << TAI->getPCSymbol();
+      if (!TAI->getShortenEHDataOn64Bit()) {
+        O << "-" << TAI->getPCSymbol();
+      }
       Asm->EOL("Personality");
 
       Asm->EmitULEB128Bytes(DW_EH_PE_pcrel);
@@ -2917,7 +2919,7 @@ private:
       // If there is a personality and landing pads then point to the language
       // specific data area in the exception table.
       if (EHFrameInfo.PersonalityIndex) {
-        Asm->EmitULEB128Bytes(4);
+        Asm->EmitULEB128Bytes(TAI->getShortenEHDataOn64Bit() ? 8 : 4);
         Asm->EOL("Augmentation size");
         
         if (EHFrameInfo.hasLandingPads) {
@@ -3284,24 +3286,26 @@ private:
       }
 
       EmitSectionOffset(BeginTag, "eh_func_begin", BeginNumber, SubprogramCount,
-                        false, true);
+                        TAI->getShortenEHDataOn64Bit(), true);
       Asm->EOL("Region start");
 
       if (!S.EndLabel) {
-        EmitDifference("eh_func_end", SubprogramCount, BeginTag, BeginNumber);
+        EmitDifference("eh_func_end", SubprogramCount, BeginTag, BeginNumber,
+                       TAI->getShortenEHDataOn64Bit());
       } else {
-        EmitDifference("label", S.EndLabel, BeginTag, BeginNumber);
+        EmitDifference("label", S.EndLabel, BeginTag, BeginNumber, 
+                       TAI->getShortenEHDataOn64Bit());
       }
       Asm->EOL("Region length");
 
       if (!S.PadLabel) {
-        if (TD->getPointerSize() == sizeof(int32_t))
+        if (TD->getPointerSize() == sizeof(int32_t) || TAI->getShortenEHDataOn64Bit())
           Asm->EmitInt32(0);
         else
           Asm->EmitInt64(0);
       } else {
         EmitSectionOffset("label", "eh_func_begin", S.PadLabel, SubprogramCount,
-                          false, true);
+                          TAI->getShortenEHDataOn64Bit(), true);
       }
       Asm->EOL("Landing pad");
 
index e593482c65ac4a0803d851e5eca851ce7866624e..8728def217c7c564051d7d4537fa43a4f0ec0c30 100644 (file)
@@ -50,6 +50,7 @@ DarwinTargetAsmInfo::DarwinTargetAsmInfo(const PPCTargetMachine &TM)
     StaticCtorsSection = ".mod_init_func";
     StaticDtorsSection = ".mod_term_func";
   }
+  SwitchToSectionDirective = "\t.section ";
   UsedDirective = "\t.no_dead_strip\t";
   WeakDefDirective = "\t.weak_definition ";
   WeakRefDirective = "\t.weak_reference ";
index 8f48162696196418bcd12b443ef7d56df1562af9..b0e8165ad1c880b897728c862591185f8b129a2f 100644 (file)
@@ -358,7 +358,8 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
 
     O << "\n";
 
-    if (ExceptionHandling && TAI->doesSupportExceptionHandling() && MMI) {
+    if (ExceptionHandling && TAI->doesSupportExceptionHandling() && MMI &&
+        !Subtarget->is64Bit()) {
       // Add the (possibly multiple) personalities to the set of global values.
       const std::vector<Function *>& Personalities = MMI->getPersonalities();
 
index bc698ba0969a7f4fe237a4e21911660089804e7f..293836a06e8dcf1e2cf5f4faf10b065b30558be1 100644 (file)
@@ -59,6 +59,7 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
       SixteenByteConstantSection = "\t.literal16\n";
     ReadOnlySection = "\t.const\n";
     LCOMMDirective = "\t.lcomm\t";
+    SwitchToSectionDirective = "\t.section ";
     COMMDirectiveTakesAlignment = false;
     HasDotTypeDotSizeDirective = false;
     if (TM.getRelocationModel() == Reloc::Static) {
@@ -68,8 +69,13 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
       StaticCtorsSection = ".mod_init_func";
       StaticDtorsSection = ".mod_term_func";
     }
-    PersonalityPrefix = "L";
-    PersonalitySuffix = "$non_lazy_ptr";
+    if (Subtarget->is64Bit()) {
+      PersonalityPrefix = "";
+      PersonalitySuffix = "+4@GOTPCREL";
+    } else {
+      PersonalityPrefix = "L";
+      PersonalitySuffix = "$non_lazy_ptr";
+    }
     NeedsIndirectEncoding = true;
     InlineAsmStart = "# InlineAsm Start";
     InlineAsmEnd = "# InlineAsm End";
@@ -102,11 +108,12 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
     DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
 
     // Exceptions handling
-    if (!Subtarget->is64Bit())
-      SupportsExceptionHandling = true;
+    SupportsExceptionHandling = true;
     GlobalEHDirective = "\t.globl\t";
     SupportsWeakOmittedEHFrame = false;
     AbsoluteEHSectionOffsets = false;
+    if (Subtarget->is64Bit())
+      ShortenEHDataOn64Bit = true;
     DwarfEHFrameSection =
     ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
     DwarfExceptionSection = ".section __DATA,__gcc_except_tab";