[llvm-commits] [llvm] r46029 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/CodeGen/DwarfWriter.cpp lib/Target/PowerPC/PPCTargetAsmInfo.cpp lib/Target/X86/X86AsmPrinter.cpp lib/Target/X86/X86TargetAsmInfo.cpp

Dale Johannesen dalej at apple.com
Tue Jan 15 15:24:56 PST 2008


Author: johannes
Date: Tue Jan 15 17:24:56 2008
New Revision: 46029

URL: http://llvm.org/viewvc/llvm-project?rev=46029&view=rev
Log:
Fix and enable EH for x86-64 Darwin.  Adds
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.


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

Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=46029&r1=46028&r2=46029&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Tue Jan 15 17:24:56 2008
@@ -313,6 +313,10 @@
     /// 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 @@
     bool getSupportsWeakOmittedEHFrame() const {
       return SupportsWeakOmittedEHFrame;
     }
+    bool getShortenEHDataOn64Bit() const {
+      return ShortenEHDataOn64Bit;
+    }
     const char *getDwarfSectionOffsetDirective() const {
       return DwarfSectionOffsetDirective;
     }    

Modified: llvm/trunk/lib/CodeGen/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfWriter.cpp?rev=46029&r1=46028&r2=46029&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/DwarfWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/DwarfWriter.cpp Tue Jan 15 17:24:56 2008
@@ -2835,11 +2835,13 @@
 
       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 @@
       // 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 @@
       }
 
       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");
 

Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp?rev=46029&r1=46028&r2=46029&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp Tue Jan 15 17:24:56 2008
@@ -50,6 +50,7 @@
     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 ";

Modified: llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp?rev=46029&r1=46028&r2=46029&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp Tue Jan 15 17:24:56 2008
@@ -358,7 +358,8 @@
 
     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();
 

Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp?rev=46029&r1=46028&r2=46029&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Tue Jan 15 17:24:56 2008
@@ -59,6 +59,7 @@
       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 @@
       StaticCtorsSection = ".mod_init_func";
       StaticDtorsSection = ".mod_term_func";
     }
-    PersonalityPrefix = "L";
-    PersonalitySuffix = "$non_lazy_ptr";
+    if (Subtarget->is64Bit()) {
+      PersonalityPrefix = "";
+      PersonalitySuffix = "+4 at GOTPCREL";
+    } else {
+      PersonalityPrefix = "L";
+      PersonalitySuffix = "$non_lazy_ptr";
+    }
     NeedsIndirectEncoding = true;
     InlineAsmStart = "# InlineAsm Start";
     InlineAsmEnd = "# InlineAsm End";
@@ -102,11 +108,12 @@
     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";





More information about the llvm-commits mailing list