eliminate the magic AbsoluteDebugSectionOffsets MAI hook,

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
This commit is contained in:
Chris Lattner 2010-04-04 23:22:29 +00:00
parent be15beb54a
commit 3d22513611
11 changed files with 17 additions and 16 deletions

View File

@ -223,10 +223,6 @@ namespace llvm {
//===--- Dwarf Emission Directives -----------------------------------===// //===--- 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. /// HasLEB128 - True if target asm supports leb128 directives.
bool HasLEB128; // Defaults to false. bool HasLEB128; // Defaults to false.
@ -385,9 +381,6 @@ namespace llvm {
MCSymbolAttr getProtectedVisibilityAttr() const { MCSymbolAttr getProtectedVisibilityAttr() const {
return ProtectedVisibilityAttr; return ProtectedVisibilityAttr;
} }
bool isAbsoluteDebugSectionOffsets() const {
return AbsoluteDebugSectionOffsets;
}
bool hasLEB128() const { bool hasLEB128() const {
return HasLEB128; return HasLEB128;
} }

View File

@ -39,6 +39,14 @@ namespace llvm {
virtual void PrintSwitchToSection(const MCAsmInfo &MAI, virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
raw_ostream &OS) const = 0; 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 { class MCSectionCOFF : public MCSection {

View File

@ -172,6 +172,11 @@ public:
virtual void PrintSwitchToSection(const MCAsmInfo &MAI, virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
raw_ostream &OS) const; 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 /// PrintTargetSpecificSectionFlags - Targets that define their own
/// MCSectionELF subclasses with target specific section flags should /// MCSectionELF subclasses with target specific section flags should

View File

@ -20,6 +20,7 @@
#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
#include "llvm/Target/TargetData.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 // If Label has already been emitted, verify that it is in the same section as
// section label for sanity. // section label for sanity.
assert((!Label->isInSection() || &Label->getSection() == &Section) && 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 // 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. // just emit an absolute reference to save a relocation.
if (MAI->isAbsoluteDebugSectionOffsets()) { if (Section.isBaseAddressKnownZero()) {
Asm->OutStreamer.EmitSymbolValue(Label, 4, 0/*AddrSpace*/); Asm->OutStreamer.EmitSymbolValue(Label, 4, 0/*AddrSpace*/);
return; return;
} }
// Otherwise, emit it as a label difference from the start of the section.
Asm->EmitLabelDifference(Label, SectionLabel, 4); Asm->EmitLabelDifference(Label, SectionLabel, 4);
} }

View File

@ -60,7 +60,6 @@ MCAsmInfo::MCAsmInfo() {
LinkOnceDirective = 0; LinkOnceDirective = 0;
HiddenVisibilityAttr = MCSA_Hidden; HiddenVisibilityAttr = MCSA_Hidden;
ProtectedVisibilityAttr = MCSA_Protected; ProtectedVisibilityAttr = MCSA_Protected;
AbsoluteDebugSectionOffsets = false;
HasLEB128 = false; HasLEB128 = false;
HasDotLocAndDotFile = false; HasDotLocAndDotFile = false;
SupportsDebugInformation = false; SupportsDebugInformation = false;

View File

@ -31,7 +31,6 @@ MCAsmInfoCOFF::MCAsmInfoCOFF() {
// Set up DWARF directives // Set up DWARF directives
HasLEB128 = true; // Target asm supports leb128 directives (little-endian) HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
AbsoluteDebugSectionOffsets = true;
SupportsDebugInformation = true; SupportsDebugInformation = true;
DwarfSectionOffsetDirective = "\t.secrel32\t"; DwarfSectionOffsetDirective = "\t.secrel32\t";
HasMicrosoftFastStdCallMangling = true; HasMicrosoftFastStdCallMangling = true;

View File

@ -58,7 +58,6 @@ ARMELFMCAsmInfo::ARMELFMCAsmInfo() {
CommentString = "@"; CommentString = "@";
HasLEB128 = true; HasLEB128 = true;
AbsoluteDebugSectionOffsets = true;
PrivateGlobalPrefix = ".L"; PrivateGlobalPrefix = ".L";
WeakRefDirective = "\t.weak\t"; WeakRefDirective = "\t.weak\t";
HasLCOMMDirective = true; HasLCOMMDirective = true;

View File

@ -38,7 +38,6 @@ PPCLinuxMCAsmInfo::PPCLinuxMCAsmInfo(bool is64Bit) {
UsesELFSectionDirectiveForBSS = true; UsesELFSectionDirectiveForBSS = true;
// Debug Information // Debug Information
AbsoluteDebugSectionOffsets = true;
SupportsDebugInformation = true; SupportsDebugInformation = true;
PCSymbol = "."; PCSymbol = ".";

View File

@ -22,7 +22,6 @@ SparcELFMCAsmInfo::SparcELFMCAsmInfo(const Target &T, const StringRef &TT) {
ZeroDirective = "\t.skip\t"; ZeroDirective = "\t.skip\t";
CommentString = "!"; CommentString = "!";
HasLEB128 = true; HasLEB128 = true;
AbsoluteDebugSectionOffsets = true;
SupportsDebugInformation = true; SupportsDebugInformation = true;
SunStyleELFSectionSwitchSyntax = true; SunStyleELFSectionSwitchSyntax = true;

View File

@ -84,7 +84,6 @@ X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) {
HasLEB128 = true; // Target asm supports leb128 directives (little-endian) HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
// Debug Information // Debug Information
AbsoluteDebugSectionOffsets = true;
SupportsDebugInformation = true; SupportsDebugInformation = true;
// Exceptions handling // Exceptions handling

View File

@ -25,6 +25,5 @@ XCoreMCAsmInfo::XCoreMCAsmInfo(const Target &T, const StringRef &TT) {
// Debug // Debug
HasLEB128 = true; HasLEB128 = true;
AbsoluteDebugSectionOffsets = true;
} }