simplify EmitSectionOffset to always use .set if it is

available, the only thing this affects is that we produce
.set in one case we didn't before, which shouldn't harm
anything.  Make EmitSectionOffset call EmitDifference
instead of duplicating it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98005 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2010-03-08 23:23:25 +00:00
parent 82f05078b0
commit 57578766aa
8 changed files with 17 additions and 39 deletions

View File

@ -285,7 +285,7 @@ void DIELabel::print(raw_ostream &O) {
/// ///
void DIESectionOffset::EmitValue(DwarfPrinter *D, unsigned Form) const { void DIESectionOffset::EmitValue(DwarfPrinter *D, unsigned Form) const {
bool IsSmall = Form == dwarf::DW_FORM_data4; bool IsSmall = Form == dwarf::DW_FORM_data4;
D->EmitSectionOffset(Label, Section, IsSmall, IsEH, UseSet); D->EmitSectionOffset(Label, Section, IsSmall, IsEH);
D->getAsm()->O << '\n'; // FIXME: Necesssary? D->getAsm()->O << '\n'; // FIXME: Necesssary?
} }
@ -299,7 +299,7 @@ unsigned DIESectionOffset::SizeOf(const TargetData *TD, unsigned Form) const {
#ifndef NDEBUG #ifndef NDEBUG
void DIESectionOffset::print(raw_ostream &O) { void DIESectionOffset::print(raw_ostream &O) {
O << "Off: " << Label->getName() << "-" << Section->getName() O << "Off: " << Label->getName() << "-" << Section->getName()
<< "-" << IsEH << "-" << UseSet; << "-" << IsEH;
} }
#endif #endif

View File

@ -336,12 +336,11 @@ namespace llvm {
const MCSymbol *Label; const MCSymbol *Label;
const MCSymbol *Section; const MCSymbol *Section;
bool IsEH : 1; bool IsEH : 1;
bool UseSet : 1;
public: public:
DIESectionOffset(const MCSymbol *Lab, const MCSymbol *Sec, DIESectionOffset(const MCSymbol *Lab, const MCSymbol *Sec,
bool isEH = false, bool useSet = true) bool isEH = false)
: DIEValue(isSectionOffset), Label(Lab), Section(Sec), : DIEValue(isSectionOffset), Label(Lab), Section(Sec),
IsEH(isEH), UseSet(useSet) {} IsEH(isEH) {}
/// EmitValue - Emit section offset. /// EmitValue - Emit section offset.
/// ///

View File

@ -376,8 +376,8 @@ void DwarfDebug::addLabel(DIE *Die, unsigned Attribute, unsigned Form,
/// ///
void DwarfDebug::addSectionOffset(DIE *Die, unsigned Attribute, unsigned Form, void DwarfDebug::addSectionOffset(DIE *Die, unsigned Attribute, unsigned Form,
const MCSymbol *Label,const MCSymbol *Section, const MCSymbol *Label,const MCSymbol *Section,
bool isEH, bool useSet) { bool isEH) {
DIEValue *Value = new DIESectionOffset(Label, Section, isEH, useSet); DIEValue *Value = new DIESectionOffset(Label, Section, isEH);
DIEValues.push_back(Value); DIEValues.push_back(Value);
Die->addValue(Attribute, Form, Value); Die->addValue(Attribute, Form, Value);
} }

View File

@ -249,7 +249,7 @@ class DwarfDebug : public DwarfPrinter {
/// ///
void addSectionOffset(DIE *Die, unsigned Attribute, unsigned Form, void addSectionOffset(DIE *Die, unsigned Attribute, unsigned Form,
const MCSymbol *Label, const MCSymbol *Section, const MCSymbol *Label, const MCSymbol *Section,
bool isEH = false, bool useSet = true); bool isEH = false);
/// addDelta - Add a label delta attribute data and value. /// addDelta - Add a label delta attribute data and value.
/// ///

View File

@ -232,7 +232,7 @@ void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
EmitSectionOffset(getDWLabel("eh_frame_begin", EHFrameInfo.Number), EmitSectionOffset(getDWLabel("eh_frame_begin", EHFrameInfo.Number),
getDWLabel("eh_frame_common", getDWLabel("eh_frame_common",
EHFrameInfo.PersonalityIndex), EHFrameInfo.PersonalityIndex),
true, true, false); true, true);
EOL("FDE CIE offset"); EOL("FDE CIE offset");

View File

@ -278,39 +278,18 @@ void DwarfPrinter::EmitDifference(const MCSymbol *TagHi, const MCSymbol *TagLo,
void DwarfPrinter::EmitSectionOffset(const MCSymbol *Label, void DwarfPrinter::EmitSectionOffset(const MCSymbol *Label,
const MCSymbol *Section, const MCSymbol *Section,
bool IsSmall, bool isEH, bool IsSmall, bool isEH) {
bool useSet) {
bool printAbsolute = false; bool printAbsolute = false;
if (isEH) if (isEH)
printAbsolute = MAI->isAbsoluteEHSectionOffsets(); printAbsolute = MAI->isAbsoluteEHSectionOffsets();
else else
printAbsolute = MAI->isAbsoluteDebugSectionOffsets(); printAbsolute = MAI->isAbsoluteDebugSectionOffsets();
if (MAI->hasSetDirective() && useSet) { if (!printAbsolute)
// FIXME: switch to OutStreamer.EmitAssignment. return EmitDifference(Label, Section, IsSmall);
O << "\t.set\t";
PrintLabelName("set", SetCounter, Flavor); PrintRelDirective(IsSmall, true);
O << ","; PrintLabelName(Label);
PrintLabelName(Label);
if (!printAbsolute) {
O << "-";
PrintLabelName(Section);
}
O << "\n";
PrintRelDirective(IsSmall);
PrintLabelName("set", SetCounter, Flavor);
++SetCounter;
} else {
PrintRelDirective(IsSmall, true);
PrintLabelName(Label);
if (!printAbsolute) {
O << "-";
PrintLabelName(Section);
}
}
} }
/// EmitFrameMoves - Emit frame instructions to describe the layout of the /// EmitFrameMoves - Emit frame instructions to describe the layout of the

View File

@ -139,9 +139,9 @@ public:
/// EmitDifference - Emit the difference between two labels. /// EmitDifference - Emit the difference between two labels.
void EmitDifference(const MCSymbol *LabelHi, const MCSymbol *LabelLo, void EmitDifference(const MCSymbol *LabelHi, const MCSymbol *LabelLo,
bool IsSmall = false); bool IsSmall = false);
void EmitSectionOffset(const MCSymbol *Label, const MCSymbol *Section, void EmitSectionOffset(const MCSymbol *Label, const MCSymbol *Section,
bool IsSmall = false, bool isEH = false, bool IsSmall = false, bool isEH = false);
bool useSet = true);
/// EmitFrameMoves - Emit frame instructions to describe the layout of the /// EmitFrameMoves - Emit frame instructions to describe the layout of the
/// frame. /// frame.

View File

@ -1,6 +1,6 @@
; RUN: llc < %s -mtriple=i686-pc-linux-gnu -asm-verbose=false -o %t ; RUN: llc < %s -mtriple=i686-pc-linux-gnu -asm-verbose=false -o %t
; RUN: grep { = } %t | count 7 ; RUN: grep { = } %t | count 7
; RUN: grep set %t | count 16 ; RUN: grep set %t | count 18
; RUN: grep globl %t | count 6 ; RUN: grep globl %t | count 6
; RUN: grep weak %t | count 1 ; RUN: grep weak %t | count 1
; RUN: grep hidden %t | count 1 ; RUN: grep hidden %t | count 1