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

Dale Johannesen dalej at apple.com
Wed Jan 9 18:03:30 PST 2008


Author: johannes
Date: Wed Jan  9 20:03:30 2008
New Revision: 45811

URL: http://llvm.org/viewvc/llvm-project?rev=45811&view=rev
Log:
Emit unused EH frames for weak definitions on Darwin,
because assembler/linker can't cope with weak absolutes.
PR 1880.


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/TargetAsmInfo.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=45811&r1=45810&r2=45811&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Wed Jan  9 20:03:30 2008
@@ -309,6 +309,10 @@
     ///
     const char *GlobalEHDirective;          // Defaults to NULL.
 
+    /// SupportsWeakEmptyEHFrame - True if target assembler and linker will
+    /// handle a weak_definition of constant 0 for an omitted EH frame.
+    bool SupportsWeakOmittedEHFrame;  // Defaults to true.
+
     /// DwarfSectionOffsetDirective - Special section offset directive.
     const char* DwarfSectionOffsetDirective; // Defaults to NULL
     
@@ -585,6 +589,9 @@
     const char *getGlobalEHDirective() const {
       return GlobalEHDirective;
     }
+    bool getSupportsWeakOmittedEHFrame() const {
+      return SupportsWeakOmittedEHFrame;
+    }
     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=45811&r1=45810&r2=45811&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/DwarfWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/DwarfWriter.cpp Wed Jan  9 20:03:30 2008
@@ -2877,18 +2877,25 @@
         O << GlobalEHDirective << EHFrameInfo.FnName << "\n";
     }
 
-    // If there are no calls then you can't unwind.
-    if (!EHFrameInfo.hasCalls) { 
+    // If corresponding function is weak definition, this should be too.
+    if ((EHFrameInfo.linkage == Function::WeakLinkage || 
+         EHFrameInfo.linkage == Function::LinkOnceLinkage) &&
+        TAI->getWeakDefDirective())
+      O << TAI->getWeakDefDirective() << EHFrameInfo.FnName << "\n";
+
+    // If there are no calls then you can't unwind.  This may mean we can
+    // omit the EH Frame, but some environments do not handle weak absolute
+    // symbols.
+    if (!EHFrameInfo.hasCalls &&
+        ((EHFrameInfo.linkage != Function::WeakLinkage && 
+          EHFrameInfo.linkage != Function::LinkOnceLinkage) ||
+         !TAI->getWeakDefDirective() ||
+         TAI->getSupportsWeakOmittedEHFrame()))
+    { 
       O << EHFrameInfo.FnName << " = 0\n";
     } else {
       O << EHFrameInfo.FnName << ":\n";
 
-      // If corresponding function is weak definition, this should be too.
-      if ((EHFrameInfo.linkage == Function::WeakLinkage || 
-           EHFrameInfo.linkage == Function::LinkOnceLinkage) &&
-          TAI->getWeakDefDirective())
-        O << TAI->getWeakDefDirective() << EHFrameInfo.FnName << "\n";
-
       // EH frame header.
       EmitDifference("eh_frame_end", EHFrameInfo.Number,
                      "eh_frame_begin", EHFrameInfo.Number, true);

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

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp Wed Jan  9 20:03:30 2008
@@ -51,8 +51,8 @@
     StaticDtorsSection = ".mod_term_func";
   }
   UsedDirective = "\t.no_dead_strip\t";
-  WeakDefDirective = "\t.weak_definition\t";
-  WeakRefDirective = "\t.weak_reference\t";
+  WeakDefDirective = "\t.weak_definition ";
+  WeakRefDirective = "\t.weak_reference ";
   HiddenDirective = "\t.private_extern\t";
   SupportsExceptionHandling = true;
   NeedsIndirectEncoding = true;
@@ -62,12 +62,13 @@
   DwarfEHFrameSection =
   ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
   DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
+  GlobalEHDirective = "\t.globl\t";
+  SupportsWeakOmittedEHFrame = false;
 
   DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
   DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
   DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
   DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
-  GlobalEHDirective = "\t.globl\t";
   DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
   DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
   DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";

Modified: llvm/trunk/lib/Target/TargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetAsmInfo.cpp?rev=45811&r1=45810&r2=45811&view=diff

==============================================================================
--- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Wed Jan  9 20:03:30 2008
@@ -86,6 +86,7 @@
   SupportsExceptionHandling(false),
   DwarfRequiresFrameSection(true),
   GlobalEHDirective(0),
+  SupportsWeakOmittedEHFrame(true),
   DwarfSectionOffsetDirective(0),
   DwarfAbbrevSection(".debug_abbrev"),
   DwarfInfoSection(".debug_info"),

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

==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Wed Jan  9 20:03:30 2008
@@ -76,8 +76,8 @@
     SetDirective = "\t.set";
     PCSymbol = ".";
     UsedDirective = "\t.no_dead_strip\t";
-    WeakDefDirective = "\t.weak_definition\t";
-    WeakRefDirective = "\t.weak_reference\t";
+    WeakDefDirective = "\t.weak_definition ";
+    WeakRefDirective = "\t.weak_reference ";
     HiddenDirective = "\t.private_extern\t";
     
     // In non-PIC modes, emit a special label before jump tables so that the
@@ -93,7 +93,6 @@
     DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
     DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
     DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
-    GlobalEHDirective = "\t.globl\t";
     DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
     DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
     DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
@@ -105,6 +104,8 @@
     // Exceptions handling
     if (!Subtarget->is64Bit())
       SupportsExceptionHandling = true;
+    GlobalEHDirective = "\t.globl\t";
+    SupportsWeakOmittedEHFrame = false;
     AbsoluteEHSectionOffsets = false;
     DwarfEHFrameSection =
     ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";





More information about the llvm-commits mailing list