16
16
#include " llvm/DebugInfo/CodeView/CodeView.h"
17
17
#include " llvm/DebugInfo/CodeView/Line.h"
18
18
#include " llvm/DebugInfo/CodeView/SymbolRecord.h"
19
- #include " llvm/MC/MCAsmLayout.h"
20
19
#include " llvm/MC/MCAssembler.h"
21
20
#include " llvm/MC/MCContext.h"
22
21
#include " llvm/MC/MCObjectStreamer.h"
@@ -465,25 +464,24 @@ MCFragment *CodeViewContext::emitDefRange(
465
464
return F;
466
465
}
467
466
468
- static unsigned computeLabelDiff (MCAsmLayout &Layout , const MCSymbol *Begin,
467
+ static unsigned computeLabelDiff (const MCAssembler &Asm , const MCSymbol *Begin,
469
468
const MCSymbol *End) {
470
- MCContext &Ctx = Layout. getAssembler () .getContext ();
469
+ MCContext &Ctx = Asm .getContext ();
471
470
MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
472
471
const MCExpr *BeginRef = MCSymbolRefExpr::create (Begin, Variant, Ctx),
473
472
*EndRef = MCSymbolRefExpr::create (End, Variant, Ctx);
474
473
const MCExpr *AddrDelta =
475
474
MCBinaryExpr::create (MCBinaryExpr::Sub, EndRef, BeginRef, Ctx);
476
475
int64_t Result;
477
- bool Success =
478
- AddrDelta->evaluateKnownAbsolute (Result, Layout.getAssembler ());
476
+ bool Success = AddrDelta->evaluateKnownAbsolute (Result, Asm);
479
477
assert (Success && " failed to evaluate label difference as absolute" );
480
478
(void )Success;
481
479
assert (Result >= 0 && " negative label difference requested" );
482
480
assert (Result < UINT_MAX && " label difference greater than 2GB" );
483
481
return unsigned (Result);
484
482
}
485
483
486
- void CodeViewContext::encodeInlineLineTable (MCAsmLayout &Layout ,
484
+ void CodeViewContext::encodeInlineLineTable (const MCAssembler &Asm ,
487
485
MCCVInlineLineTableFragment &Frag) {
488
486
size_t LocBegin;
489
487
size_t LocEnd;
@@ -550,7 +548,7 @@ void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout,
550
548
// We've hit a cv_loc not attributed to this inline call site. Use this
551
549
// label to end the PC range.
552
550
if (HaveOpenRange) {
553
- unsigned Length = computeLabelDiff (Layout , LastLabel, Loc.getLabel ());
551
+ unsigned Length = computeLabelDiff (Asm , LastLabel, Loc.getLabel ());
554
552
compressAnnotation (BinaryAnnotationsOpCode::ChangeCodeLength, Buffer);
555
553
compressAnnotation (Length, Buffer);
556
554
LastLabel = Loc.getLabel ();
@@ -580,7 +578,7 @@ void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout,
580
578
581
579
int LineDelta = CurSourceLoc.Line - LastSourceLoc.Line ;
582
580
unsigned EncodedLineDelta = encodeSignedNumber (LineDelta);
583
- unsigned CodeDelta = computeLabelDiff (Layout , LastLabel, Loc.getLabel ());
581
+ unsigned CodeDelta = computeLabelDiff (Asm , LastLabel, Loc.getLabel ());
584
582
if (EncodedLineDelta < 0x8 && CodeDelta <= 0xf ) {
585
583
// The ChangeCodeOffsetAndLineOffset combination opcode is used when the
586
584
// encoded line delta uses 3 or fewer set bits and the code offset fits
@@ -606,23 +604,23 @@ void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout,
606
604
assert (HaveOpenRange);
607
605
608
606
unsigned EndSymLength =
609
- computeLabelDiff (Layout , LastLabel, Frag.getFnEndSym ());
607
+ computeLabelDiff (Asm , LastLabel, Frag.getFnEndSym ());
610
608
unsigned LocAfterLength = ~0U ;
611
609
ArrayRef<MCCVLoc> LocAfter = getLinesForExtent (LocEnd, LocEnd + 1 );
612
610
if (!LocAfter.empty ()) {
613
611
// Only try to compute this difference if we're in the same section.
614
612
const MCCVLoc &Loc = LocAfter[0 ];
615
613
if (&Loc.getLabel ()->getSection () == &LastLabel->getSection ())
616
- LocAfterLength = computeLabelDiff (Layout , LastLabel, Loc.getLabel ());
614
+ LocAfterLength = computeLabelDiff (Asm , LastLabel, Loc.getLabel ());
617
615
}
618
616
619
617
compressAnnotation (BinaryAnnotationsOpCode::ChangeCodeLength, Buffer);
620
618
compressAnnotation (std::min (EndSymLength, LocAfterLength), Buffer);
621
619
}
622
620
623
- void CodeViewContext::encodeDefRange (MCAsmLayout &Layout ,
621
+ void CodeViewContext::encodeDefRange (const MCAssembler &Asm ,
624
622
MCCVDefRangeFragment &Frag) {
625
- MCContext &Ctx = Layout. getAssembler () .getContext ();
623
+ MCContext &Ctx = Asm .getContext ();
626
624
SmallVectorImpl<char > &Contents = Frag.getContents ();
627
625
Contents.clear ();
628
626
SmallVectorImpl<MCFixup> &Fixups = Frag.getFixups ();
@@ -634,8 +632,8 @@ void CodeViewContext::encodeDefRange(MCAsmLayout &Layout,
634
632
const MCSymbol *LastLabel = nullptr ;
635
633
for (std::pair<const MCSymbol *, const MCSymbol *> Range : Frag.getRanges ()) {
636
634
unsigned GapSize =
637
- LastLabel ? computeLabelDiff (Layout , LastLabel, Range.first ) : 0 ;
638
- unsigned RangeSize = computeLabelDiff (Layout , Range.first , Range.second );
635
+ LastLabel ? computeLabelDiff (Asm , LastLabel, Range.first ) : 0 ;
636
+ unsigned RangeSize = computeLabelDiff (Asm , Range.first , Range.second );
639
637
GapAndRangeSizes.push_back ({GapSize, RangeSize});
640
638
LastLabel = Range.second ;
641
639
}
0 commit comments