simplify EmitSectionOffset a little bit, improve comments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100360 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp b/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
index a224db8..8958985 100644
--- a/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
@@ -39,17 +39,23 @@
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 {
- Asm->OutStreamer.EmitSymbolValue(Label, 4, 0/*AddrSpace*/);
+ 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