move getDwarfExceptionSection from TAI to TLOF and rename it to
authorChris Lattner <sabre@nondot.org>
Sun, 2 Aug 2009 01:34:32 +0000 (01:34 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 2 Aug 2009 01:34:32 +0000 (01:34 +0000)
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.

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

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

index 0eff044c45e39258204558534069f467bf76b212..5574ad5bc6b34062491a7bb5dde4b42bd4ce3a19 100644 (file)
@@ -371,10 +371,6 @@ namespace llvm {
     ///
     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 @@ namespace llvm {
     const char *getDwarfEHFrameSection() const {
       return DwarfEHFrameSection;
     }
-    const char *getDwarfExceptionSection() const {
-      return DwarfExceptionSection;
-    }
     const char *const *getAsmCBE() const {
       return AsmTransCBE;
     }
index ec6b697585500894fbbf9cda9b53dcf59ae4a3b7..377b9eeae41e226446ef4143bfdd4ae905a8cda8 100644 (file)
@@ -58,6 +58,10 @@ protected:
   /// 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 @@ public:
   
   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)
index 8eb97af0f942a568121598ddc9321c3040cb7bc5..b051f7138ef70849577d11548455e8a593a0544b 100644 (file)
 #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 @@ void DwarfException::EmitExceptionTable() {
   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";
 
index 3c8ab94da5a112e4726e1e937ef724c6168ec3ae..2e66cb80646849e326e9b93b0f47e528b8620959 100644 (file)
@@ -28,7 +28,6 @@ PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM) :
   
   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 @@ PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
     SupportsExceptionHandling = true;
   AbsoluteEHSectionOffsets = false;
   DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
-  DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
 }
 
 
index 80bb90e0651039f95ed227bec4fda453428393fe..e961f2ad74f3791b4abd338e4ccdd370fa86f729 100644 (file)
@@ -108,7 +108,6 @@ TargetAsmInfo::TargetAsmInfo(const TargetMachine &tm) : TM(tm) {
   DwarfRangesSection = ".debug_ranges";
   DwarfMacroInfoSection = ".debug_macinfo";
   DwarfEHFrameSection = ".eh_frame";
-  DwarfExceptionSection = ".gcc_except_table";
   AsmTransCBE = 0;
 }
 
index a86946da9f107513becec13f144fc595970931ef..d04e5c0cd609a5c1b7df984a69e4df412a4240e2 100644 (file)
@@ -36,6 +36,7 @@ TargetLoweringObjectFile::TargetLoweringObjectFile() : Ctx(0) {
   ReadOnlySection = 0;
   StaticCtorSection = 0;
   StaticDtorSection = 0;
+  LSDASection = 0;
 }
 
 TargetLoweringObjectFile::~TargetLoweringObjectFile() {
@@ -302,6 +303,14 @@ void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx,
     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 @@ void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx,
       getOrCreateSection(".mod_term_func", true, SectionKind::getDataRel());
   }
   
+  LSDASection = getOrCreateSection("__DATA,__gcc_except_tab", false,
+                                   SectionKind::getDataRel());
 }
 
 const MCSection *TargetLoweringObjectFileMachO::
index c30f3378b7b100bec447a36073c7a8139916b852..4c9030845a0bbb8e1fa2635641b2ab5b76a9d84e 100644 (file)
@@ -84,7 +84,6 @@ X86DarwinTargetAsmInfo::X86DarwinTargetAsmInfo(const X86TargetMachine &TM):
   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 @@ X86ELFTargetAsmInfo::X86ELFTargetAsmInfo(const X86TargetMachine &TM) :
   SupportsExceptionHandling = true;
   AbsoluteEHSectionOffsets = false;
   DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
-  DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
 
   // On Linux we must declare when we can use a non-executable stack.
   if (TM.getSubtarget<X86Subtarget>().isLinux())