57
57
#include " llvm/Support/raw_ostream.h"
58
58
#include < algorithm>
59
59
#include < cassert>
60
+ #include < cmath>
60
61
#include < limits>
61
62
#include < memory>
62
63
#include < utility>
@@ -442,7 +443,6 @@ class StackColoring {
442
443
void dump () const ;
443
444
void dumpIntervals () const ;
444
445
void dumpBB (MachineBasicBlock *MBB) const ;
445
- void dumpBV (const char *tag, const BitVector &BV) const ;
446
446
447
447
// / Removes all of the lifetime marker instructions from the function.
448
448
// / \returns true if any markers were removed.
@@ -526,12 +526,39 @@ void StackColoringLegacy::getAnalysisUsage(AnalysisUsage &AU) const {
526
526
}
527
527
528
528
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
529
- LLVM_DUMP_METHOD void StackColoring::dumpBV (const char *tag,
530
- const BitVector &BV) const {
531
- dbgs () << tag << " : { " ;
532
- for (unsigned I = 0 , E = BV.size (); I != E; ++I)
533
- dbgs () << BV.test (I) << " " ;
534
- dbgs () << " }\n " ;
529
+
530
+ LLVM_DUMP_METHOD void dumpBV (StringRef tag, const BitVector &BV) {
531
+ constexpr unsigned ColumnWidth = 150 ;
532
+ unsigned LineStartOffset = tag.size () + /* " : "*/ 3 ;
533
+ unsigned WidthAfterTag = ColumnWidth - LineStartOffset;
534
+ unsigned NumBitsPerColumn = WidthAfterTag / 2 ;
535
+ unsigned BitsCount = BV.size ();
536
+ for (unsigned Bits = 0 ; Bits < BitsCount; Bits += NumBitsPerColumn) {
537
+ unsigned Start = Bits;
538
+ unsigned End = std::min (Start + NumBitsPerColumn, BitsCount);
539
+
540
+ dbgs () << tag << " : " ;
541
+
542
+ for (unsigned I = Start; I < End; ++I)
543
+ dbgs () << BV.test (I) << " " ;
544
+ dbgs () << ' \n ' ;
545
+ dbgs () << tag << " : " ;
546
+ unsigned next = Start;
547
+ for (unsigned I = Start; I < End; ++I) {
548
+ if (I < next)
549
+ continue ;
550
+ if (BV.test (I)) {
551
+ int numDidgits = I != 0 ? (log10 (I) + 1 ) : 1 ;
552
+ // Make sure number have spacing while staying aligned to the line above
553
+ next = I + 1 + numDidgits / 2 ;
554
+ dbgs () << I << ' ' ;
555
+ if (numDidgits % 2 == 0 )
556
+ dbgs () << ' ' ;
557
+ } else
558
+ dbgs () << " " ;
559
+ }
560
+ dbgs () << ' \n ' ;
561
+ }
535
562
}
536
563
537
564
LLVM_DUMP_METHOD void StackColoring::dumpBB (MachineBasicBlock *MBB) const {
@@ -553,8 +580,15 @@ LLVM_DUMP_METHOD void StackColoring::dump() const {
553
580
554
581
LLVM_DUMP_METHOD void StackColoring::dumpIntervals () const {
555
582
for (unsigned I = 0 , E = Intervals.size (); I != E; ++I) {
556
- dbgs () << " Interval[" << I << " ]:\n " ;
583
+ dbgs () << " Interval[" << I << " ]:" ;
584
+ if (MFI->getObjectAllocation (I))
585
+ dbgs () << *MFI->getObjectAllocation (I);
586
+ dbgs () << " \n " ;
557
587
Intervals[I]->dump ();
588
+ dbgs () << " LiveStarts:" ;
589
+ for (SlotIndex SIdx : LiveStarts[I])
590
+ dbgs () << " " << SIdx;
591
+ dbgs () << " \n " ;
558
592
}
559
593
}
560
594
#endif
0 commit comments