[llvm] a5e905b - [MC] Remove MCAsmLayout::getFragmentAddress
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 11:02:19 PDT 2024
Author: Fangrui Song
Date: 2024-07-01T11:02:15-07:00
New Revision: a5e905b73d4aec4365a63040338cb02118ae80e5
URL: https://github.com/llvm/llvm-project/commit/a5e905b73d4aec4365a63040338cb02118ae80e5
DIFF: https://github.com/llvm/llvm-project/commit/a5e905b73d4aec4365a63040338cb02118ae80e5.diff
LOG: [MC] Remove MCAsmLayout::getFragmentAddress
Added:
Modified:
llvm/include/llvm/MC/MCAsmLayout.h
llvm/include/llvm/MC/MCMachObjectWriter.h
llvm/lib/MC/MCAssembler.cpp
llvm/lib/MC/MachObjectWriter.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
llvm/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCAsmLayout.h b/llvm/include/llvm/MC/MCAsmLayout.h
index 24b621e6f145e..0630af6e84a2b 100644
--- a/llvm/include/llvm/MC/MCAsmLayout.h
+++ b/llvm/include/llvm/MC/MCAsmLayout.h
@@ -50,9 +50,6 @@ class MCAsmLayout {
/// \name Fragment Layout Data
/// @{
- /// Get the offset of the given fragment inside its containing section.
- uint64_t getFragmentOffset(const MCFragment *F) const;
-
/// @}
/// \name Utility Functions
/// @{
diff --git a/llvm/include/llvm/MC/MCMachObjectWriter.h b/llvm/include/llvm/MC/MCMachObjectWriter.h
index 23161130de8ea..f6f61ebd8f8bf 100644
--- a/llvm/include/llvm/MC/MCMachObjectWriter.h
+++ b/llvm/include/llvm/MC/MCMachObjectWriter.h
@@ -156,8 +156,8 @@ class MachObjectWriter : public MCObjectWriter {
}
uint64_t getSymbolAddress(const MCSymbol &S, const MCAsmLayout &Layout) const;
- uint64_t getFragmentAddress(const MCFragment *Fragment,
- const MCAsmLayout &Layout) const;
+ uint64_t getFragmentAddress(const MCAssembler &Asm,
+ const MCFragment *Fragment) const;
uint64_t getPaddingSize(const MCSection *SD, const MCAsmLayout &Layout) const;
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 91c1d7ba3ca4c..9625c6461c1f5 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -494,10 +494,6 @@ uint64_t MCAssembler::getFragmentOffset(const MCFragment &F) const {
return F.Offset;
}
-uint64_t MCAsmLayout::getFragmentOffset(const MCFragment *F) const {
- return Assembler.getFragmentOffset(*F);
-}
-
// Simple getSymbolOffset helper for the non-variable case.
static bool getLabelOffset(const MCAssembler &Asm, const MCSymbol &S,
bool ReportError, uint64_t &Val) {
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index 157473a733434..3f688055d3293 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -81,10 +81,11 @@ bool MachObjectWriter::isFixupKindPCRel(const MCAssembler &Asm, unsigned Kind) {
return FKI.Flags & MCFixupKindInfo::FKF_IsPCRel;
}
-uint64_t MachObjectWriter::getFragmentAddress(const MCFragment *Fragment,
- const MCAsmLayout &Layout) const {
+uint64_t
+MachObjectWriter::getFragmentAddress(const MCAssembler &Asm,
+ const MCFragment *Fragment) const {
return getSectionAddress(Fragment->getParent()) +
- Layout.getFragmentOffset(Fragment);
+ Asm.getFragmentOffset(*Fragment);
}
uint64_t MachObjectWriter::getSymbolAddress(const MCSymbol &S,
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
index 1801d1060e297..d5177aa7a6ad1 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
@@ -361,8 +361,8 @@ void AArch64MachObjectWriter::recordRelocation(
Value += Writer->getSymbolAddress(*Symbol, *Asm.getLayout());
if (IsPCRel)
- Value -= Writer->getFragmentAddress(Fragment, *Asm.getLayout()) +
- Fixup.getOffset() + (1ULL << Log2Size);
+ Value -= Writer->getFragmentAddress(Asm, Fragment) + Fixup.getOffset() +
+ (1ULL << Log2Size);
} else {
llvm_unreachable(
"This constant variable should have been expanded during evaluation");
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
index 4a02e10d91316..4b146aea9a8ac 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
@@ -571,7 +571,7 @@ bool RISCVAsmBackend::evaluateTargetFixup(
return false;
Value = Layout.getSymbolOffset(SA) + AUIPCTarget.getConstant();
- Value -= Layout.getFragmentOffset(AUIPCDF) + AUIPCFixup->getOffset();
+ Value -= Asm.getFragmentOffset(*AUIPCDF) + AUIPCFixup->getOffset();
if (shouldForceRelocation(Asm, *AUIPCFixup, AUIPCTarget, STI)) {
WasForced = true;
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
index 0dbf367c5fa1b..d28195f070efa 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
@@ -103,8 +103,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(
// See <reloc.h>.
uint32_t FixupOffset = Asm.getFragmentOffset(*Fragment) + Fixup.getOffset();
uint32_t FixupAddress =
- Writer->getFragmentAddress(Fragment, *Asm.getLayout()) +
- Fixup.getOffset();
+ Writer->getFragmentAddress(Asm, Fragment) + Fixup.getOffset();
int64_t Value = 0;
unsigned Index = 0;
unsigned IsExtern = 0;
@@ -474,8 +473,7 @@ void X86MachObjectWriter::recordTLVPRelocation(MachObjectWriter *Writer,
if (auto *SymB = Target.getSymB()) {
// If this is a subtraction then we're pcrel.
uint32_t FixupAddress =
- Writer->getFragmentAddress(Fragment, *Asm.getLayout()) +
- Fixup.getOffset();
+ Writer->getFragmentAddress(Asm, Fragment) + Fixup.getOffset();
IsPCRel = 1;
FixedValue = FixupAddress -
Writer->getSymbolAddress(SymB->getSymbol(), *Asm.getLayout()) +
More information about the llvm-commits
mailing list