summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-04 22:25:14 +0000
committerChris Lattner <sabre@nondot.org>2010-04-04 22:25:14 +0000
commit2e3ebedc881091fcf0c68aebb48649582689ee78 (patch)
treec33880c9c5bb646b56a6ee4cce59e586e20475c8
parent1d20473c9d920ce7d6aef438ea89544460c56f0f (diff)
downloadllvm-2e3ebedc881091fcf0c68aebb48649582689ee78.tar.gz
llvm-2e3ebedc881091fcf0c68aebb48649582689ee78.tar.bz2
llvm-2e3ebedc881091fcf0c68aebb48649582689ee78.tar.xz
simplify EmitSectionOffset a little bit, improve comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100360 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp14
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfPrinter.cpp18
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfPrinter.h11
3 files changed, 26 insertions, 17 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index b09644c473..32a632aa33 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2566,8 +2566,7 @@ void DwarfDebug::emitDebugInfo() {
Asm->OutStreamer.AddComment("DWARF version number");
Asm->EmitInt16(dwarf::DWARF_VERSION);
Asm->OutStreamer.AddComment("Offset Into Abbrev. Section");
- EmitSectionOffset(Asm->GetTempSymbol("abbrev_begin"),
- Asm->GetTempSymbol("section_abbrev"));
+ EmitSectionOffset(Asm->GetTempSymbol("abbrev_begin"), "section_abbrev");
Asm->OutStreamer.AddComment("Address Size (in bytes)");
Asm->EmitInt8(TD->getPointerSize());
@@ -2879,7 +2878,7 @@ emitFunctionDebugFrame(const FunctionDebugFrameInfo &DebugFrameInfo) {
Asm->OutStreamer.AddComment("FDE CIE offset");
EmitSectionOffset(Asm->GetTempSymbol("debug_frame_common"),
- Asm->GetTempSymbol("section_debug_frame"));
+ "section_debug_frame");
Asm->OutStreamer.AddComment("FDE initial location");
MCSymbol *FuncBeginSym =
@@ -2918,7 +2917,7 @@ void DwarfDebug::emitDebugPubNames() {
Asm->OutStreamer.AddComment("Offset of Compilation Unit Info");
EmitSectionOffset(Asm->GetTempSymbol("info_begin", ModuleCU->getID()),
- Asm->GetTempSymbol("section_info"));
+ "section_info");
Asm->OutStreamer.AddComment("Compilation Unit Length");
Asm->EmitLabelDifference(Asm->GetTempSymbol("info_end", ModuleCU->getID()),
@@ -2962,7 +2961,7 @@ void DwarfDebug::emitDebugPubTypes() {
Asm->OutStreamer.AddComment("Offset of Compilation ModuleCU Info");
EmitSectionOffset(Asm->GetTempSymbol("info_begin", ModuleCU->getID()),
- Asm->GetTempSymbol("section_info"));
+ "section_info");
Asm->OutStreamer.AddComment("Compilation ModuleCU Length");
Asm->EmitLabelDifference(Asm->GetTempSymbol("info_end", ModuleCU->getID()),
@@ -3108,11 +3107,10 @@ void DwarfDebug::emitDebugInlineInfo() {
Asm->OutStreamer.EmitIntValue(0, 1, 0); // nul terminator.
} else
EmitSectionOffset(getStringPoolEntry(getRealLinkageName(LName)),
- Asm->GetTempSymbol("section_str"));
+ "section_str");
Asm->OutStreamer.AddComment("Function name");
- EmitSectionOffset(getStringPoolEntry(Name),
- Asm->GetTempSymbol("section_str"));
+ EmitSectionOffset(getStringPoolEntry(Name), "section_str");
Asm->EmitULEB128(Labels.size(), "Inline count");
for (SmallVector<InlineInfoLabels, 4>::iterator LI = Labels.begin(),
diff --git a/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp b/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
index a224db8400..895898594e 100644
--- a/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
@@ -39,17 +39,23 @@ DwarfPrinter::DwarfPrinter(AsmPrinter *A)
void DwarfPrinter::EmitSectionOffset(const MCSymbol *Label,
- const MCSymbol *Section) {
- if (!MAI->isAbsoluteDebugSectionOffsets())
- return Asm->EmitLabelDifference(Label, Section, 4);
-
- // On COFF targets, we have to emit the weird .secrel32 directive.
+ const char *SectionLabel) {
+ // On COFF targets, we have to emit the special .secrel32 directive.
if (const char *SecOffDir = MAI->getDwarfSectionOffsetDirective()) {
// FIXME: MCize.
Asm->OutStreamer.EmitRawText(SecOffDir + Twine(Label->getName()));
- } else {
+ return;
+ }
+
+ // 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()) {
Asm->OutStreamer.EmitSymbolValue(Label, 4, 0/*AddrSpace*/);
+ return;
}
+
+ MCSymbol *SectionSym = Asm->GetTempSymbol(SectionLabel);
+ Asm->EmitLabelDifference(Label, SectionSym, 4);
}
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
diff --git a/lib/CodeGen/AsmPrinter/DwarfPrinter.h b/lib/CodeGen/AsmPrinter/DwarfPrinter.h
index b6e4a2bbc2..20bfbf9269 100644
--- a/lib/CodeGen/AsmPrinter/DwarfPrinter.h
+++ b/lib/CodeGen/AsmPrinter/DwarfPrinter.h
@@ -74,9 +74,14 @@ public:
const MCAsmInfo *getMCAsmInfo() const { return MAI; }
const TargetData *getTargetData() const { return TD; }
- /// EmitSectionOffset - Emit a 4-byte "Label-Section" value or use a special
- /// purpose directive to emit a section offset if the target has one.
- void EmitSectionOffset(const MCSymbol *Label, const MCSymbol *Section);
+ /// EmitSectionOffset - Emit the 4-byte offset of Label from the start of its
+ /// section. This can be done with a special directive if the target supports
+ /// it (e.g. cygwin) or by emitting it as an offset from a label at the start
+ /// of the section.
+ ///
+ /// SectionLabel is the name of a temporary label emitted at the start of the
+ /// section.
+ void EmitSectionOffset(const MCSymbol *Label, const char *SectionLabel);
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
/// frame.