aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCCodeView.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-07-01 17:08:38 -0700
committerFangrui Song <i@maskray.me>2024-07-01 17:08:38 -0700
commit66cd8ec4c08252ebc73c82e4883a8da247ed146b (patch)
tree097069dddd5d9a49d69fe255d06b6f159b1c0686 /llvm/lib/MC/MCCodeView.cpp
parent4ba9956958b5646853a0abd81a96d935749eef8b (diff)
downloadllvm-66cd8ec4c08252ebc73c82e4883a8da247ed146b.zip
llvm-66cd8ec4c08252ebc73c82e4883a8da247ed146b.tar.gz
llvm-66cd8ec4c08252ebc73c82e4883a8da247ed146b.tar.bz2
MCCodeView: replace the MCAsmLayout parameter with MCAssembler
Diffstat (limited to 'llvm/lib/MC/MCCodeView.cpp')
-rw-r--r--llvm/lib/MC/MCCodeView.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/llvm/lib/MC/MCCodeView.cpp b/llvm/lib/MC/MCCodeView.cpp
index a47a07b..792a132 100644
--- a/llvm/lib/MC/MCCodeView.cpp
+++ b/llvm/lib/MC/MCCodeView.cpp
@@ -16,7 +16,6 @@
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/Line.h"
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
-#include "llvm/MC/MCAsmLayout.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCObjectStreamer.h"
@@ -465,17 +464,16 @@ MCFragment *CodeViewContext::emitDefRange(
return F;
}
-static unsigned computeLabelDiff(MCAsmLayout &Layout, const MCSymbol *Begin,
+static unsigned computeLabelDiff(const MCAssembler &Asm, const MCSymbol *Begin,
const MCSymbol *End) {
- MCContext &Ctx = Layout.getAssembler().getContext();
+ MCContext &Ctx = Asm.getContext();
MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
const MCExpr *BeginRef = MCSymbolRefExpr::create(Begin, Variant, Ctx),
*EndRef = MCSymbolRefExpr::create(End, Variant, Ctx);
const MCExpr *AddrDelta =
MCBinaryExpr::create(MCBinaryExpr::Sub, EndRef, BeginRef, Ctx);
int64_t Result;
- bool Success =
- AddrDelta->evaluateKnownAbsolute(Result, Layout.getAssembler());
+ bool Success = AddrDelta->evaluateKnownAbsolute(Result, Asm);
assert(Success && "failed to evaluate label difference as absolute");
(void)Success;
assert(Result >= 0 && "negative label difference requested");
@@ -483,7 +481,7 @@ static unsigned computeLabelDiff(MCAsmLayout &Layout, const MCSymbol *Begin,
return unsigned(Result);
}
-void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout,
+void CodeViewContext::encodeInlineLineTable(const MCAssembler &Asm,
MCCVInlineLineTableFragment &Frag) {
size_t LocBegin;
size_t LocEnd;
@@ -550,7 +548,7 @@ void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout,
// We've hit a cv_loc not attributed to this inline call site. Use this
// label to end the PC range.
if (HaveOpenRange) {
- unsigned Length = computeLabelDiff(Layout, LastLabel, Loc.getLabel());
+ unsigned Length = computeLabelDiff(Asm, LastLabel, Loc.getLabel());
compressAnnotation(BinaryAnnotationsOpCode::ChangeCodeLength, Buffer);
compressAnnotation(Length, Buffer);
LastLabel = Loc.getLabel();
@@ -580,7 +578,7 @@ void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout,
int LineDelta = CurSourceLoc.Line - LastSourceLoc.Line;
unsigned EncodedLineDelta = encodeSignedNumber(LineDelta);
- unsigned CodeDelta = computeLabelDiff(Layout, LastLabel, Loc.getLabel());
+ unsigned CodeDelta = computeLabelDiff(Asm, LastLabel, Loc.getLabel());
if (EncodedLineDelta < 0x8 && CodeDelta <= 0xf) {
// The ChangeCodeOffsetAndLineOffset combination opcode is used when the
// encoded line delta uses 3 or fewer set bits and the code offset fits
@@ -606,23 +604,23 @@ void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout,
assert(HaveOpenRange);
unsigned EndSymLength =
- computeLabelDiff(Layout, LastLabel, Frag.getFnEndSym());
+ computeLabelDiff(Asm, LastLabel, Frag.getFnEndSym());
unsigned LocAfterLength = ~0U;
ArrayRef<MCCVLoc> LocAfter = getLinesForExtent(LocEnd, LocEnd + 1);
if (!LocAfter.empty()) {
// Only try to compute this difference if we're in the same section.
const MCCVLoc &Loc = LocAfter[0];
if (&Loc.getLabel()->getSection() == &LastLabel->getSection())
- LocAfterLength = computeLabelDiff(Layout, LastLabel, Loc.getLabel());
+ LocAfterLength = computeLabelDiff(Asm, LastLabel, Loc.getLabel());
}
compressAnnotation(BinaryAnnotationsOpCode::ChangeCodeLength, Buffer);
compressAnnotation(std::min(EndSymLength, LocAfterLength), Buffer);
}
-void CodeViewContext::encodeDefRange(MCAsmLayout &Layout,
+void CodeViewContext::encodeDefRange(const MCAssembler &Asm,
MCCVDefRangeFragment &Frag) {
- MCContext &Ctx = Layout.getAssembler().getContext();
+ MCContext &Ctx = Asm.getContext();
SmallVectorImpl<char> &Contents = Frag.getContents();
Contents.clear();
SmallVectorImpl<MCFixup> &Fixups = Frag.getFixups();
@@ -634,8 +632,8 @@ void CodeViewContext::encodeDefRange(MCAsmLayout &Layout,
const MCSymbol *LastLabel = nullptr;
for (std::pair<const MCSymbol *, const MCSymbol *> Range : Frag.getRanges()) {
unsigned GapSize =
- LastLabel ? computeLabelDiff(Layout, LastLabel, Range.first) : 0;
- unsigned RangeSize = computeLabelDiff(Layout, Range.first, Range.second);
+ LastLabel ? computeLabelDiff(Asm, LastLabel, Range.first) : 0;
+ unsigned RangeSize = computeLabelDiff(Asm, Range.first, Range.second);
GapAndRangeSizes.push_back({GapSize, RangeSize});
LastLabel = Range.second;
}