OSDN Git Service

eliminate the magic AbsoluteDebugSectionOffsets MAI hook,
authorChris Lattner <sabre@nondot.org>
Sun, 4 Apr 2010 23:22:29 +0000 (23:22 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 4 Apr 2010 23:22:29 +0000 (23:22 +0000)
which is really a property of the section being referenced.
Add a predicate to MCSection to replace it.

Yay for reduction in magic.

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

include/llvm/MC/MCAsmInfo.h
include/llvm/MC/MCSection.h
include/llvm/MC/MCSectionELF.h
lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
lib/MC/MCAsmInfo.cpp
lib/MC/MCAsmInfoCOFF.cpp
lib/Target/ARM/ARMMCAsmInfo.cpp
lib/Target/PowerPC/PPCMCAsmInfo.cpp
lib/Target/Sparc/SparcMCAsmInfo.cpp
lib/Target/X86/X86MCAsmInfo.cpp
lib/Target/XCore/XCoreMCAsmInfo.cpp

index d190ea4..33def86 100644 (file)
@@ -223,10 +223,6 @@ namespace llvm {
 
     //===--- Dwarf Emission Directives -----------------------------------===//
 
-    /// AbsoluteDebugSectionOffsets - True if we should emit abolute section
-    /// offsets for debug information.
-    bool AbsoluteDebugSectionOffsets;        // Defaults to false.
-
     /// HasLEB128 - True if target asm supports leb128 directives.
     bool HasLEB128;                          // Defaults to false.
 
@@ -385,9 +381,6 @@ namespace llvm {
     MCSymbolAttr getProtectedVisibilityAttr() const {
       return ProtectedVisibilityAttr;
     }
-    bool isAbsoluteDebugSectionOffsets() const {
-      return AbsoluteDebugSectionOffsets;
-    }
     bool hasLEB128() const {
       return HasLEB128;
     }
index 4a1c46c..e9c19fc 100644 (file)
@@ -39,6 +39,14 @@ namespace llvm {
     
     virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
                                       raw_ostream &OS) const = 0;
+
+    /// isBaseAddressKnownZero - Return true if we know that this section will
+    /// get a base address of zero.  In cases where we know that this is true we
+    /// can emit section offsets as direct references to avoid a subtraction
+    /// from the base of the section, saving a relocation.
+    virtual bool isBaseAddressKnownZero() const {
+      return false;
+    }
   };
 
   class MCSectionCOFF : public MCSection {
index cdd2f73..e550cd2 100644 (file)
@@ -172,6 +172,11 @@ public:
   virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
                                     raw_ostream &OS) const;
   
+  /// isBaseAddressKnownZero - We know that non-allocatable sections (like
+  /// debug info) have a base of zero.
+  virtual bool isBaseAddressKnownZero() const {
+    return (getFlags() & SHF_ALLOC) == 0;
+  }
   
   /// PrintTargetSpecificSectionFlags - Targets that define their own
   /// MCSectionELF subclasses with target specific section flags should
index 7de6109..84d47ec 100644 (file)
@@ -20,6 +20,7 @@
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCExpr.h"
+#include "llvm/MC/MCSection.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSymbol.h"
 #include "llvm/Target/TargetData.h"
@@ -61,15 +62,16 @@ void DwarfPrinter::EmitSectionOffset(const MCSymbol *Label,
   // If Label has already been emitted, verify that it is in the same section as
   // section label for sanity.
   assert((!Label->isInSection() || &Label->getSection() == &Section) &&
-         "Section offset using wrong section base for label"); (void)Section;
+         "Section offset using wrong section base for label");
   
   // If the section in question will end up with an address of 0 anyway, we can
   // just emit an absolute reference to save a relocation.
-  if (MAI->isAbsoluteDebugSectionOffsets()) {
+  if (Section.isBaseAddressKnownZero()) {
     Asm->OutStreamer.EmitSymbolValue(Label, 4, 0/*AddrSpace*/);
     return;
   }
 
+  // Otherwise, emit it as a label difference from the start of the section.
   Asm->EmitLabelDifference(Label, SectionLabel, 4);
 }
 
index 0306dec..f0da694 100644 (file)
@@ -60,7 +60,6 @@ MCAsmInfo::MCAsmInfo() {
   LinkOnceDirective = 0;
   HiddenVisibilityAttr = MCSA_Hidden;
   ProtectedVisibilityAttr = MCSA_Protected;
-  AbsoluteDebugSectionOffsets = false;
   HasLEB128 = false;
   HasDotLocAndDotFile = false;
   SupportsDebugInformation = false;
index e9bc8fa..7fc7d7a 100644 (file)
@@ -31,7 +31,6 @@ MCAsmInfoCOFF::MCAsmInfoCOFF() {
 
   // Set up DWARF directives
   HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
-  AbsoluteDebugSectionOffsets = true;
   SupportsDebugInformation = true;
   DwarfSectionOffsetDirective = "\t.secrel32\t";
   HasMicrosoftFastStdCallMangling = true;
index 20197e4..53edfca 100644 (file)
@@ -58,7 +58,6 @@ ARMELFMCAsmInfo::ARMELFMCAsmInfo() {
   CommentString = "@";
 
   HasLEB128 = true;
-  AbsoluteDebugSectionOffsets = true;
   PrivateGlobalPrefix = ".L";
   WeakRefDirective = "\t.weak\t";
   HasLCOMMDirective = true;
index 0be1fa4..3644c79 100644 (file)
@@ -38,7 +38,6 @@ PPCLinuxMCAsmInfo::PPCLinuxMCAsmInfo(bool is64Bit) {
   UsesELFSectionDirectiveForBSS = true;  
 
   // Debug Information
-  AbsoluteDebugSectionOffsets = true;
   SupportsDebugInformation = true;
 
   PCSymbol = ".";
index 53a9bde..535c6f7 100644 (file)
@@ -22,7 +22,6 @@ SparcELFMCAsmInfo::SparcELFMCAsmInfo(const Target &T, const StringRef &TT) {
   ZeroDirective = "\t.skip\t";
   CommentString = "!";
   HasLEB128 = true;
-  AbsoluteDebugSectionOffsets = true;
   SupportsDebugInformation = true;
   
   SunStyleELFSectionSwitchSyntax = true;
index 1afabc9..d257ee3 100644 (file)
@@ -84,7 +84,6 @@ X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) {
   HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
 
   // Debug Information
-  AbsoluteDebugSectionOffsets = true;
   SupportsDebugInformation = true;
 
   // Exceptions handling
index bf78575..5f6feae 100644 (file)
@@ -25,6 +25,5 @@ XCoreMCAsmInfo::XCoreMCAsmInfo(const Target &T, const StringRef &TT) {
 
   // Debug
   HasLEB128 = true;
-  AbsoluteDebugSectionOffsets = true;
 }