Skip to content

Commit 66cd8ec

Browse files
committed
MCCodeView: replace the MCAsmLayout parameter with MCAssembler
1 parent 4ba9956 commit 66cd8ec

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

llvm/include/llvm/MC/MCCodeView.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <vector>
2323

2424
namespace llvm {
25-
class MCAsmLayout;
25+
class MCAssembler;
2626
class MCCVDefRangeFragment;
2727
class MCCVInlineLineTableFragment;
2828
class MCDataFragment;
@@ -199,15 +199,15 @@ class CodeViewContext {
199199
const MCSymbol *FnEndSym);
200200

201201
/// Encodes the binary annotations once we have a layout.
202-
void encodeInlineLineTable(MCAsmLayout &Layout,
202+
void encodeInlineLineTable(const MCAssembler &Asm,
203203
MCCVInlineLineTableFragment &F);
204204

205205
MCFragment *
206206
emitDefRange(MCObjectStreamer &OS,
207207
ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
208208
StringRef FixedSizePortion);
209209

210-
void encodeDefRange(MCAsmLayout &Layout, MCCVDefRangeFragment &F);
210+
void encodeDefRange(const MCAssembler &Asm, MCCVDefRangeFragment &F);
211211

212212
/// Emits the string table substream.
213213
void emitStringTable(MCObjectStreamer &OS);

llvm/lib/MC/MCAssembler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,13 +1288,13 @@ bool MCAssembler::relaxDwarfCallFrameFragment(MCDwarfCallFrameFragment &DF) {
12881288

12891289
bool MCAssembler::relaxCVInlineLineTable(MCCVInlineLineTableFragment &F) {
12901290
unsigned OldSize = F.getContents().size();
1291-
getContext().getCVContext().encodeInlineLineTable(*Layout, F);
1291+
getContext().getCVContext().encodeInlineLineTable(*this, F);
12921292
return OldSize != F.getContents().size();
12931293
}
12941294

12951295
bool MCAssembler::relaxCVDefRange(MCCVDefRangeFragment &F) {
12961296
unsigned OldSize = F.getContents().size();
1297-
getContext().getCVContext().encodeDefRange(*Layout, F);
1297+
getContext().getCVContext().encodeDefRange(*this, F);
12981298
return OldSize != F.getContents().size();
12991299
}
13001300

llvm/lib/MC/MCCodeView.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "llvm/DebugInfo/CodeView/CodeView.h"
1717
#include "llvm/DebugInfo/CodeView/Line.h"
1818
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
19-
#include "llvm/MC/MCAsmLayout.h"
2019
#include "llvm/MC/MCAssembler.h"
2120
#include "llvm/MC/MCContext.h"
2221
#include "llvm/MC/MCObjectStreamer.h"
@@ -465,25 +464,24 @@ MCFragment *CodeViewContext::emitDefRange(
465464
return F;
466465
}
467466

468-
static unsigned computeLabelDiff(MCAsmLayout &Layout, const MCSymbol *Begin,
467+
static unsigned computeLabelDiff(const MCAssembler &Asm, const MCSymbol *Begin,
469468
const MCSymbol *End) {
470-
MCContext &Ctx = Layout.getAssembler().getContext();
469+
MCContext &Ctx = Asm.getContext();
471470
MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
472471
const MCExpr *BeginRef = MCSymbolRefExpr::create(Begin, Variant, Ctx),
473472
*EndRef = MCSymbolRefExpr::create(End, Variant, Ctx);
474473
const MCExpr *AddrDelta =
475474
MCBinaryExpr::create(MCBinaryExpr::Sub, EndRef, BeginRef, Ctx);
476475
int64_t Result;
477-
bool Success =
478-
AddrDelta->evaluateKnownAbsolute(Result, Layout.getAssembler());
476+
bool Success = AddrDelta->evaluateKnownAbsolute(Result, Asm);
479477
assert(Success && "failed to evaluate label difference as absolute");
480478
(void)Success;
481479
assert(Result >= 0 && "negative label difference requested");
482480
assert(Result < UINT_MAX && "label difference greater than 2GB");
483481
return unsigned(Result);
484482
}
485483

486-
void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout,
484+
void CodeViewContext::encodeInlineLineTable(const MCAssembler &Asm,
487485
MCCVInlineLineTableFragment &Frag) {
488486
size_t LocBegin;
489487
size_t LocEnd;
@@ -550,7 +548,7 @@ void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout,
550548
// We've hit a cv_loc not attributed to this inline call site. Use this
551549
// label to end the PC range.
552550
if (HaveOpenRange) {
553-
unsigned Length = computeLabelDiff(Layout, LastLabel, Loc.getLabel());
551+
unsigned Length = computeLabelDiff(Asm, LastLabel, Loc.getLabel());
554552
compressAnnotation(BinaryAnnotationsOpCode::ChangeCodeLength, Buffer);
555553
compressAnnotation(Length, Buffer);
556554
LastLabel = Loc.getLabel();
@@ -580,7 +578,7 @@ void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout,
580578

581579
int LineDelta = CurSourceLoc.Line - LastSourceLoc.Line;
582580
unsigned EncodedLineDelta = encodeSignedNumber(LineDelta);
583-
unsigned CodeDelta = computeLabelDiff(Layout, LastLabel, Loc.getLabel());
581+
unsigned CodeDelta = computeLabelDiff(Asm, LastLabel, Loc.getLabel());
584582
if (EncodedLineDelta < 0x8 && CodeDelta <= 0xf) {
585583
// The ChangeCodeOffsetAndLineOffset combination opcode is used when the
586584
// encoded line delta uses 3 or fewer set bits and the code offset fits
@@ -606,23 +604,23 @@ void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout,
606604
assert(HaveOpenRange);
607605

608606
unsigned EndSymLength =
609-
computeLabelDiff(Layout, LastLabel, Frag.getFnEndSym());
607+
computeLabelDiff(Asm, LastLabel, Frag.getFnEndSym());
610608
unsigned LocAfterLength = ~0U;
611609
ArrayRef<MCCVLoc> LocAfter = getLinesForExtent(LocEnd, LocEnd + 1);
612610
if (!LocAfter.empty()) {
613611
// Only try to compute this difference if we're in the same section.
614612
const MCCVLoc &Loc = LocAfter[0];
615613
if (&Loc.getLabel()->getSection() == &LastLabel->getSection())
616-
LocAfterLength = computeLabelDiff(Layout, LastLabel, Loc.getLabel());
614+
LocAfterLength = computeLabelDiff(Asm, LastLabel, Loc.getLabel());
617615
}
618616

619617
compressAnnotation(BinaryAnnotationsOpCode::ChangeCodeLength, Buffer);
620618
compressAnnotation(std::min(EndSymLength, LocAfterLength), Buffer);
621619
}
622620

623-
void CodeViewContext::encodeDefRange(MCAsmLayout &Layout,
621+
void CodeViewContext::encodeDefRange(const MCAssembler &Asm,
624622
MCCVDefRangeFragment &Frag) {
625-
MCContext &Ctx = Layout.getAssembler().getContext();
623+
MCContext &Ctx = Asm.getContext();
626624
SmallVectorImpl<char> &Contents = Frag.getContents();
627625
Contents.clear();
628626
SmallVectorImpl<MCFixup> &Fixups = Frag.getFixups();
@@ -634,8 +632,8 @@ void CodeViewContext::encodeDefRange(MCAsmLayout &Layout,
634632
const MCSymbol *LastLabel = nullptr;
635633
for (std::pair<const MCSymbol *, const MCSymbol *> Range : Frag.getRanges()) {
636634
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);
639637
GapAndRangeSizes.push_back({GapSize, RangeSize});
640638
LastLabel = Range.second;
641639
}

0 commit comments

Comments
 (0)