[llvm-commits] [llvm] r77847 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h include/llvm/Target/TargetLoweringObjectFile.h lib/CodeGen/AsmPrinter/DwarfException.cpp lib/Target/PowerPC/PPCTargetAsmInfo.cpp lib/Target/TargetAsmInfo.cpp lib/Target/TargetLoweringObjectFile.cpp lib/Target/X86/X86TargetAsmInfo.cpp

Chris Lattner sabre at nondot.org
Sat Aug 1 18:34:33 PDT 2009


Author: lattner
Date: Sat Aug  1 20:34:32 2009
New Revision: 77847

URL: http://llvm.org/viewvc/llvm-project?rev=77847&view=rev
Log:
move getDwarfExceptionSection from TAI to TLOF and rename it to 
getLSDASection() to be more specific.  This makes it pretty obvious
that the ELF LSDA section is being specified wrong in PIC mode.  We're
probably getting a lot of startup-time relocations to a readonly page,
which is expensive and bad.

Someone who cares about ELF C++ should investigate this.

Modified:
    llvm/trunk/include/llvm/Target/TargetAsmInfo.h
    llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp
    llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp
    llvm/trunk/lib/Target/TargetAsmInfo.cpp
    llvm/trunk/lib/Target/TargetLoweringObjectFile.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=77847&r1=77846&r2=77847&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Sat Aug  1 20:34:32 2009
@@ -371,10 +371,6 @@
     ///
     const char *DwarfEHFrameSection; // Defaults to ".eh_frame".
     
-    /// DwarfExceptionSection - Section directive for Exception table.
-    ///
-    const char *DwarfExceptionSection; // Defaults to ".gcc_except_table".
-
     //===--- CBE Asm Translation Table -----------------------------------===//
 
     const char *const *AsmTransCBE; // Defaults to empty
@@ -637,9 +633,6 @@
     const char *getDwarfEHFrameSection() const {
       return DwarfEHFrameSection;
     }
-    const char *getDwarfExceptionSection() const {
-      return DwarfExceptionSection;
-    }
     const char *const *getAsmCBE() const {
       return AsmTransCBE;
     }

Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=77847&r1=77846&r2=77847&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Sat Aug  1 20:34:32 2009
@@ -58,6 +58,10 @@
   /// list.
   const MCSection *StaticDtorSection;
   
+  /// LSDASection - If exception handling is supported by the target, this is
+  /// the section the Language Specific Data Area information is emitted to.
+  const MCSection *LSDASection;
+  
 public:
   // FIXME: NONPUB.
   const MCSection *getOrCreateSection(const char *Name,
@@ -77,10 +81,10 @@
   
   const MCSection *getTextSection() const { return TextSection; }
   const MCSection *getDataSection() const { return DataSection; }
-
   const MCSection *getStaticCtorSection() const { return StaticCtorSection; }
   const MCSection *getStaticDtorSection() const { return StaticDtorSection; }
-
+  const MCSection *getLSDASection() const { return LSDASection; }
+  
   /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
   /// decide not to emit the UsedDirective for some symbols in llvm.used.
   /// FIXME: REMOVE this (rdar://7071300)

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=77847&r1=77846&r2=77847&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Sat Aug  1 20:34:32 2009
@@ -20,10 +20,11 @@
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetAsmInfo.h"
-#include "llvm/Target/TargetRegisterInfo.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Target/TargetFrameInfo.h"
+#include "llvm/Target/TargetLoweringObjectFile.h"
 #include "llvm/Target/TargetOptions.h"
+#include "llvm/Target/TargetRegisterInfo.h"
 #include "llvm/ADT/StringExtras.h"
 using namespace llvm;
 
@@ -539,10 +540,8 @@
   unsigned SizeAlign = (4 - TotalSize) & 3;
 
   // Begin the exception table.
-  //MCSection *LSDASection = TAI->getLSDASection();
-  //Asm->SwitchToSection(LSDASection);
-  
-  Asm->SwitchToDataSection(TAI->getDwarfExceptionSection());
+  const MCSection *LSDASection = Asm->getObjFileLowering().getLSDASection();
+  Asm->SwitchToSection(LSDASection);
   Asm->EmitAlignment(2, 0, 0, false);
   O << "GCC_except_table" << SubprogramCount << ":\n";
 

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

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp Sat Aug  1 20:34:32 2009
@@ -28,7 +28,6 @@
   
   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;
 }
@@ -73,7 +72,6 @@
     SupportsExceptionHandling = true;
   AbsoluteEHSectionOffsets = false;
   DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\", at progbits";
-  DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\", at progbits";
 }
 
 

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

==============================================================================
--- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Sat Aug  1 20:34:32 2009
@@ -108,7 +108,6 @@
   DwarfRangesSection = ".debug_ranges";
   DwarfMacroInfoSection = ".debug_macinfo";
   DwarfEHFrameSection = ".eh_frame";
-  DwarfExceptionSection = ".gcc_except_table";
   AsmTransCBE = 0;
 }
 

Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=77847&r1=77846&r2=77847&view=diff

==============================================================================
--- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Sat Aug  1 20:34:32 2009
@@ -36,6 +36,7 @@
   ReadOnlySection = 0;
   StaticCtorSection = 0;
   StaticDtorSection = 0;
+  LSDASection = 0;
 }
 
 TargetLoweringObjectFile::~TargetLoweringObjectFile() {
@@ -302,6 +303,14 @@
     getOrCreateSection(".ctors", false, SectionKind::getDataRel());
   StaticDtorSection =
     getOrCreateSection(".dtors", false, SectionKind::getDataRel());
+  
+  
+  // FIXME: We're emitting LSDA info into a readonly section on ELF, even though
+  // it contains relocatable pointers.  In PIC mode, this is probably a big
+  // runtime hit for C++ apps.  Either the contents of the LSDA need to be
+  // adjusted or this should be a data section.
+  LSDASection =
+    getOrCreateSection(".gcc_except_table", false, SectionKind::getReadOnly());
 }
 
 
@@ -537,6 +546,8 @@
       getOrCreateSection(".mod_term_func", true, SectionKind::getDataRel());
   }
   
+  LSDASection = getOrCreateSection("__DATA,__gcc_except_tab", false,
+                                   SectionKind::getDataRel());
 }
 
 const MCSection *TargetLoweringObjectFileMachO::

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

==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Sat Aug  1 20:34:32 2009
@@ -84,7 +84,6 @@
   AbsoluteEHSectionOffsets = false;
   DwarfEHFrameSection =
   ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
-  DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
 }
 
 unsigned X86DarwinTargetAsmInfo::PreferredEHDataFormat() const {
@@ -133,7 +132,6 @@
   SupportsExceptionHandling = true;
   AbsoluteEHSectionOffsets = false;
   DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\", at progbits";
-  DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\", at progbits";
 
   // On Linux we must declare when we can use a non-executable stack.
   if (TM.getSubtarget<X86Subtarget>().isLinux())





More information about the llvm-commits mailing list