Skip to content

Commit a5e905b

Browse files
committed
[MC] Remove MCAsmLayout::getFragmentAddress
1 parent bae2c54 commit a5e905b

File tree

7 files changed

+11
-19
lines changed

7 files changed

+11
-19
lines changed

llvm/include/llvm/MC/MCAsmLayout.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ class MCAsmLayout {
5050
/// \name Fragment Layout Data
5151
/// @{
5252

53-
/// Get the offset of the given fragment inside its containing section.
54-
uint64_t getFragmentOffset(const MCFragment *F) const;
55-
5653
/// @}
5754
/// \name Utility Functions
5855
/// @{

llvm/include/llvm/MC/MCMachObjectWriter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ class MachObjectWriter : public MCObjectWriter {
156156
}
157157
uint64_t getSymbolAddress(const MCSymbol &S, const MCAsmLayout &Layout) const;
158158

159-
uint64_t getFragmentAddress(const MCFragment *Fragment,
160-
const MCAsmLayout &Layout) const;
159+
uint64_t getFragmentAddress(const MCAssembler &Asm,
160+
const MCFragment *Fragment) const;
161161

162162
uint64_t getPaddingSize(const MCSection *SD, const MCAsmLayout &Layout) const;
163163

llvm/lib/MC/MCAssembler.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,6 @@ uint64_t MCAssembler::getFragmentOffset(const MCFragment &F) const {
494494
return F.Offset;
495495
}
496496

497-
uint64_t MCAsmLayout::getFragmentOffset(const MCFragment *F) const {
498-
return Assembler.getFragmentOffset(*F);
499-
}
500-
501497
// Simple getSymbolOffset helper for the non-variable case.
502498
static bool getLabelOffset(const MCAssembler &Asm, const MCSymbol &S,
503499
bool ReportError, uint64_t &Val) {

llvm/lib/MC/MachObjectWriter.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ bool MachObjectWriter::isFixupKindPCRel(const MCAssembler &Asm, unsigned Kind) {
8181
return FKI.Flags & MCFixupKindInfo::FKF_IsPCRel;
8282
}
8383

84-
uint64_t MachObjectWriter::getFragmentAddress(const MCFragment *Fragment,
85-
const MCAsmLayout &Layout) const {
84+
uint64_t
85+
MachObjectWriter::getFragmentAddress(const MCAssembler &Asm,
86+
const MCFragment *Fragment) const {
8687
return getSectionAddress(Fragment->getParent()) +
87-
Layout.getFragmentOffset(Fragment);
88+
Asm.getFragmentOffset(*Fragment);
8889
}
8990

9091
uint64_t MachObjectWriter::getSymbolAddress(const MCSymbol &S,

llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ void AArch64MachObjectWriter::recordRelocation(
361361
Value += Writer->getSymbolAddress(*Symbol, *Asm.getLayout());
362362

363363
if (IsPCRel)
364-
Value -= Writer->getFragmentAddress(Fragment, *Asm.getLayout()) +
365-
Fixup.getOffset() + (1ULL << Log2Size);
364+
Value -= Writer->getFragmentAddress(Asm, Fragment) + Fixup.getOffset() +
365+
(1ULL << Log2Size);
366366
} else {
367367
llvm_unreachable(
368368
"This constant variable should have been expanded during evaluation");

llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ bool RISCVAsmBackend::evaluateTargetFixup(
571571
return false;
572572

573573
Value = Layout.getSymbolOffset(SA) + AUIPCTarget.getConstant();
574-
Value -= Layout.getFragmentOffset(AUIPCDF) + AUIPCFixup->getOffset();
574+
Value -= Asm.getFragmentOffset(*AUIPCDF) + AUIPCFixup->getOffset();
575575

576576
if (shouldForceRelocation(Asm, *AUIPCFixup, AUIPCTarget, STI)) {
577577
WasForced = true;

llvm/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(
103103
// See <reloc.h>.
104104
uint32_t FixupOffset = Asm.getFragmentOffset(*Fragment) + Fixup.getOffset();
105105
uint32_t FixupAddress =
106-
Writer->getFragmentAddress(Fragment, *Asm.getLayout()) +
107-
Fixup.getOffset();
106+
Writer->getFragmentAddress(Asm, Fragment) + Fixup.getOffset();
108107
int64_t Value = 0;
109108
unsigned Index = 0;
110109
unsigned IsExtern = 0;
@@ -474,8 +473,7 @@ void X86MachObjectWriter::recordTLVPRelocation(MachObjectWriter *Writer,
474473
if (auto *SymB = Target.getSymB()) {
475474
// If this is a subtraction then we're pcrel.
476475
uint32_t FixupAddress =
477-
Writer->getFragmentAddress(Fragment, *Asm.getLayout()) +
478-
Fixup.getOffset();
476+
Writer->getFragmentAddress(Asm, Fragment) + Fixup.getOffset();
479477
IsPCRel = 1;
480478
FixedValue = FixupAddress -
481479
Writer->getSymbolAddress(SymB->getSymbol(), *Asm.getLayout()) +

0 commit comments

Comments
 (0)