@@ -2655,10 +2655,23 @@ static void emitRangeList(DwarfDebug &DD, AsmPrinter *Asm,
2655
2655
[](auto ) {});
2656
2656
}
2657
2657
2658
- static void emitDebugRangesImpl (DwarfDebug &DD, AsmPrinter *Asm,
2659
- const DwarfFile &Holder, MCSymbol *TableEnd) {
2658
+ void DwarfDebug::emitDebugRangesImpl (const DwarfFile &Holder, MCSection *Section) {
2659
+ if (Holder.getRangeLists ().empty ())
2660
+ return ;
2661
+
2662
+ assert (useRangesSection ());
2663
+ assert (!CUMap.empty ());
2664
+ assert (llvm::any_of (CUMap, [](const decltype (CUMap)::value_type &Pair) {
2665
+ return !Pair.second ->getCUNode ()->isDebugDirectivesOnly ();
2666
+ }));
2667
+
2668
+ Asm->OutStreamer ->SwitchSection (Section);
2669
+
2670
+ MCSymbol *TableEnd =
2671
+ getDwarfVersion () < 5 ? nullptr : emitRnglistsTableHeader (Asm, Holder);
2672
+
2660
2673
for (const RangeSpanList &List : Holder.getRangeLists ())
2661
- emitRangeList (DD , Asm, List);
2674
+ emitRangeList (* this , Asm, List);
2662
2675
2663
2676
if (TableEnd)
2664
2677
Asm->OutStreamer ->EmitLabel (TableEnd);
@@ -2667,55 +2680,17 @@ static void emitDebugRangesImpl(DwarfDebug &DD, AsmPrinter *Asm,
2667
2680
// / Emit address ranges into the .debug_ranges section or into the DWARF v5
2668
2681
// / .debug_rnglists section.
2669
2682
void DwarfDebug::emitDebugRanges () {
2670
- if (CUMap.empty ())
2671
- return ;
2672
-
2673
2683
const auto &Holder = useSplitDwarf () ? SkeletonHolder : InfoHolder;
2674
2684
2675
- if (Holder.getRangeLists ().empty ())
2676
- return ;
2677
-
2678
- assert (useRangesSection ());
2679
- assert (llvm::none_of (CUMap, [](const decltype (CUMap)::value_type &Pair) {
2680
- return Pair.second ->getCUNode ()->isDebugDirectivesOnly ();
2681
- }));
2682
-
2683
- // Start the dwarf ranges section.
2684
- MCSymbol *TableEnd = nullptr ;
2685
- if (getDwarfVersion () >= 5 ) {
2686
- Asm->OutStreamer ->SwitchSection (
2687
- Asm->getObjFileLowering ().getDwarfRnglistsSection ());
2688
- TableEnd = emitRnglistsTableHeader (Asm, Holder);
2689
- } else
2690
- Asm->OutStreamer ->SwitchSection (
2691
- Asm->getObjFileLowering ().getDwarfRangesSection ());
2692
-
2693
- emitDebugRangesImpl (*this , Asm, Holder, TableEnd);
2685
+ emitDebugRangesImpl (Holder,
2686
+ getDwarfVersion () >= 5
2687
+ ? Asm->getObjFileLowering ().getDwarfRnglistsSection ()
2688
+ : Asm->getObjFileLowering ().getDwarfRangesSection ());
2694
2689
}
2695
2690
2696
2691
void DwarfDebug::emitDebugRangesDWO () {
2697
- assert (useSplitDwarf ());
2698
-
2699
- if (CUMap.empty ())
2700
- return ;
2701
-
2702
- const auto &Holder = InfoHolder;
2703
-
2704
- if (Holder.getRangeLists ().empty ())
2705
- return ;
2706
-
2707
- assert (getDwarfVersion () >= 5 );
2708
- assert (useRangesSection ());
2709
- assert (llvm::none_of (CUMap, [](const decltype (CUMap)::value_type &Pair) {
2710
- return Pair.second ->getCUNode ()->isDebugDirectivesOnly ();
2711
- }));
2712
-
2713
- // Start the dwarf ranges section.
2714
- Asm->OutStreamer ->SwitchSection (
2715
- Asm->getObjFileLowering ().getDwarfRnglistsDWOSection ());
2716
- MCSymbol *TableEnd = emitRnglistsTableHeader (Asm, Holder);
2717
-
2718
- emitDebugRangesImpl (*this , Asm, Holder, TableEnd);
2692
+ emitDebugRangesImpl (InfoHolder,
2693
+ Asm->getObjFileLowering ().getDwarfRnglistsDWOSection ());
2719
2694
}
2720
2695
2721
2696
void DwarfDebug::handleMacroNodes (DIMacroNodeArray Nodes, DwarfCompileUnit &U) {
0 commit comments