else
HasDwarfPubSections = DwarfPubSections == Enable;
+ // For now only turn on CU ranges if we've explicitly asked for it
+ // or we have -ffunction-sections enabled.
+ HasCURanges = DwarfCURanges || TargetMachine::getFunctionSections();
+
DwarfVersion = DwarfVersionNumber
? DwarfVersionNumber
: getDwarfVersionFromModule(MMI->getModule());
// FIXME: We should use ranges if we have multiple compile units or
// allow reordering of code ala .subsections_via_symbols in mach-o.
DwarfCompileUnit *U = SkCU ? SkCU : static_cast<DwarfCompileUnit *>(TheU);
- if ((DwarfCURanges || TargetMachine::getFunctionSections()) &&
- TheU->getRanges().size())
+ if (useCURanges() && TheU->getRanges().size())
addSectionLabel(Asm, U, U->getUnitDie(), dwarf::DW_AT_ranges,
Asm->GetTempSymbol("cu_ranges", U->getUniqueID()),
DwarfDebugRangeSectionSym);
}
// Now emit a range for the CU itself.
- if (DwarfCURanges) {
+ if (useCURanges()) {
Asm->OutStreamer.EmitLabel(
Asm->GetTempSymbol("cu_ranges", TheCU->getUniqueID()));
const SmallVectorImpl<RangeSpan> &Ranges = TheCU->getRanges();
// Whether to emit the pubnames/pubtypes sections.
bool HasDwarfPubSections;
+ // Whether or not to use AT_ranges for compilation units.
+ bool HasCURanges;
+
// Version of dwarf we're emitting.
unsigned DwarfVersion;
/// split dwarf proposal support.
bool useSplitDwarf() { return HasSplitDwarf; }
+ /// \brief Returns whether or not to use AT_ranges for compilation units.
+ bool useCURanges() { return HasCURanges; }
+
/// Returns the Dwarf Version.
unsigned getDwarfVersion() const { return DwarfVersion; }
; RUN: llc -split-dwarf=Enable -O0 %s -ffunction-sections -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck --check-prefix=FUNCTION-SECTIONS %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=FUNCTION-SECTIONS-RELOCS %s
; RUN: llc -split-dwarf=Enable -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
; RUN: llvm-dwarfdump -debug-dump=all %t | FileCheck --check-prefix=NO-FUNCTION-SECTIONS %s
; With function sections enabled make sure that we have a DW_AT_ranges attribute.
; FUNCTION-SECTIONS: DW_AT_ranges
+; Check that we have a relocation against the .debug_ranges section.
+; FUNCTION-SECTIONS-RELOCS: R_X86_64_32 .debug_ranges 0x0
+
; Without function sections enabled make sure that we have no DW_AT_ranges attribute.
; NO-FUNCTION-SECTIONS-NOT: DW_AT_ranges