[llvm] 6b707a8 - [MC] Remove the MCAsmLayout parameter from MCObjectWriter::executePostLayoutBinding
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 10:47:51 PDT 2024
Author: Fangrui Song
Date: 2024-07-01T10:47:46-07:00
New Revision: 6b707a8cc143f094b02393f4faf89025c64520bb
URL: https://github.com/llvm/llvm-project/commit/6b707a8cc143f094b02393f4faf89025c64520bb
DIFF: https://github.com/llvm/llvm-project/commit/6b707a8cc143f094b02393f4faf89025c64520bb.diff
LOG: [MC] Remove the MCAsmLayout parameter from MCObjectWriter::executePostLayoutBinding
Added:
Modified:
llvm/include/llvm/MC/MCMachObjectWriter.h
llvm/include/llvm/MC/MCObjectWriter.h
llvm/lib/MC/ELFObjectWriter.cpp
llvm/lib/MC/GOFFObjectWriter.cpp
llvm/lib/MC/MCAssembler.cpp
llvm/lib/MC/MCDXContainerWriter.cpp
llvm/lib/MC/MachObjectWriter.cpp
llvm/lib/MC/SPIRVObjectWriter.cpp
llvm/lib/MC/WasmObjectWriter.cpp
llvm/lib/MC/WinCOFFObjectWriter.cpp
llvm/lib/MC/XCOFFObjectWriter.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCMachObjectWriter.h b/llvm/include/llvm/MC/MCMachObjectWriter.h
index 4eb7ad12c27c5..23161130de8ea 100644
--- a/llvm/include/llvm/MC/MCMachObjectWriter.h
+++ b/llvm/include/llvm/MC/MCMachObjectWriter.h
@@ -249,11 +249,9 @@ class MachObjectWriter : public MCObjectWriter {
std::vector<MachSymbolData> &ExternalSymbolData,
std::vector<MachSymbolData> &UndefinedSymbolData);
- void computeSectionAddresses(const MCAssembler &Asm,
- const MCAsmLayout &Layout);
+ void computeSectionAddresses(const MCAssembler &Asm);
- void executePostLayoutBinding(MCAssembler &Asm,
- const MCAsmLayout &Layout) override;
+ void executePostLayoutBinding(MCAssembler &Asm) override;
bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
const MCSymbol &SymA,
diff --git a/llvm/include/llvm/MC/MCObjectWriter.h b/llvm/include/llvm/MC/MCObjectWriter.h
index 2d667714e2f12..4184c4f65c2e1 100644
--- a/llvm/include/llvm/MC/MCObjectWriter.h
+++ b/llvm/include/llvm/MC/MCObjectWriter.h
@@ -54,8 +54,7 @@ class MCObjectWriter {
///
/// This routine is called by the assembler after layout and relaxation is
/// complete.
- virtual void executePostLayoutBinding(MCAssembler &Asm,
- const MCAsmLayout &Layout) = 0;
+ virtual void executePostLayoutBinding(MCAssembler &Asm) {}
/// Record a relocation entry.
///
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 8543b978eff2c..e7e729f09d2ec 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -259,8 +259,7 @@ class ELFObjectWriter : public MCObjectWriter {
uint64_t &FixedValue) override;
bool usesRela(const MCTargetOptions *TO, const MCSectionELF &Sec) const;
- void executePostLayoutBinding(MCAssembler &Asm,
- const MCAsmLayout &Layout) override;
+ void executePostLayoutBinding(MCAssembler &Asm) override;
void markGnuAbi() override { SeenGnuAbi = true; }
bool seenGnuAbi() const { return SeenGnuAbi; }
@@ -1274,8 +1273,7 @@ bool ELFObjectWriter::hasRelocationAddend() const {
return TargetObjectWriter->hasRelocationAddend();
}
-void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
- const MCAsmLayout &Layout) {
+void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm) {
// The presence of symbol versions causes undefined symbols and
// versions declared with @@@ to be renamed.
for (const MCAssembler::Symver &S : Asm.Symvers) {
diff --git a/llvm/lib/MC/GOFFObjectWriter.cpp b/llvm/lib/MC/GOFFObjectWriter.cpp
index d1b84496fd3be..9c43ef1af753d 100644
--- a/llvm/lib/MC/GOFFObjectWriter.cpp
+++ b/llvm/lib/MC/GOFFObjectWriter.cpp
@@ -239,8 +239,6 @@ class GOFFObjectWriter : public MCObjectWriter {
void recordRelocation(MCAssembler &Asm, const MCFragment *Fragment,
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue) override {}
- void executePostLayoutBinding(MCAssembler &Asm,
- const MCAsmLayout &Layout) override {}
uint64_t writeObject(MCAssembler &Asm) override;
};
} // end anonymous namespace
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 1e9c2f65ee057..91c1d7ba3ca4c 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -1022,7 +1022,7 @@ void MCAssembler::layout(MCAsmLayout &Layout) {
// Allow the object writer a chance to perform post-layout binding (for
// example, to set the index fields in the symbol data).
- getWriter().executePostLayoutBinding(*this, Layout);
+ getWriter().executePostLayoutBinding(*this);
// Evaluate and apply the fixups, generating relocation entries as necessary.
for (MCSection &Sec : *this) {
diff --git a/llvm/lib/MC/MCDXContainerWriter.cpp b/llvm/lib/MC/MCDXContainerWriter.cpp
index 337450fd8ae1b..002fe2fbd46f1 100644
--- a/llvm/lib/MC/MCDXContainerWriter.cpp
+++ b/llvm/lib/MC/MCDXContainerWriter.cpp
@@ -39,9 +39,6 @@ class DXContainerObjectWriter : public MCObjectWriter {
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue) override {}
- void executePostLayoutBinding(MCAssembler &Asm,
- const MCAsmLayout &Layout) override {}
-
uint64_t writeObject(MCAssembler &Asm) override;
};
} // namespace
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index eea14593071fe..157473a733434 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -668,24 +668,22 @@ void MachObjectWriter::computeSymbolTable(
}
}
-void MachObjectWriter::computeSectionAddresses(const MCAssembler &Asm,
- const MCAsmLayout &Layout) {
+void MachObjectWriter::computeSectionAddresses(const MCAssembler &Asm) {
uint64_t StartAddress = 0;
- for (const MCSection *Sec : Layout.getSectionOrder()) {
+ for (const MCSection *Sec : Asm.getLayout()->getSectionOrder()) {
StartAddress = alignTo(StartAddress, Sec->getAlign());
SectionAddress[Sec] = StartAddress;
- StartAddress += Layout.getSectionAddressSize(Sec);
+ StartAddress += Asm.getSectionAddressSize(*Sec);
// Explicitly pad the section to match the alignment requirements of the
// following one. This is for 'gas' compatibility, it shouldn't
/// strictly be necessary.
- StartAddress += getPaddingSize(Sec, Layout);
+ StartAddress += getPaddingSize(Sec, *Asm.getLayout());
}
}
-void MachObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
- const MCAsmLayout &Layout) {
- computeSectionAddresses(Asm, Layout);
+void MachObjectWriter::executePostLayoutBinding(MCAssembler &Asm) {
+ computeSectionAddresses(Asm);
// Create symbol data for any indirect symbols.
bindIndirectSymbols(Asm);
diff --git a/llvm/lib/MC/SPIRVObjectWriter.cpp b/llvm/lib/MC/SPIRVObjectWriter.cpp
index 35b555489f42d..91bde7ab62c1e 100644
--- a/llvm/lib/MC/SPIRVObjectWriter.cpp
+++ b/llvm/lib/MC/SPIRVObjectWriter.cpp
@@ -33,9 +33,6 @@ class SPIRVObjectWriter : public MCObjectWriter {
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue) override {}
- void executePostLayoutBinding(MCAssembler &Asm,
- const MCAsmLayout &Layout) override {}
-
uint64_t writeObject(MCAssembler &Asm) override;
void writeHeader(const MCAssembler &Asm);
};
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index c621a378f4d15..c123d802f946b 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -297,8 +297,7 @@ class WasmObjectWriter : public MCObjectWriter {
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue) override;
- void executePostLayoutBinding(MCAssembler &Asm,
- const MCAsmLayout &Layout) override;
+ void executePostLayoutBinding(MCAssembler &Asm) override;
void prepareImports(SmallVectorImpl<wasm::WasmImport> &Imports,
MCAssembler &Asm, const MCAsmLayout &Layout);
uint64_t writeObject(MCAssembler &Asm) override;
@@ -452,8 +451,7 @@ void WasmObjectWriter::writeHeader(const MCAssembler &Asm) {
W->write<uint32_t>(wasm::WasmVersion);
}
-void WasmObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
- const MCAsmLayout &Layout) {
+void WasmObjectWriter::executePostLayoutBinding(MCAssembler &Asm) {
// Some compilation units require the indirect function table to be present
// but don't explicitly reference it. This is the case for call_indirect
// without the reference-types feature, and also function bitcasts in all
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp
index a795b2769eeac..44bdf6356dd64 100644
--- a/llvm/lib/MC/WinCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp
@@ -161,7 +161,7 @@ class WinCOFFWriter {
DwoMode Mode);
void reset();
- void executePostLayoutBinding(MCAssembler &Asm, const MCAsmLayout &Layout);
+ void executePostLayoutBinding(MCAssembler &Asm);
void recordRelocation(MCAssembler &Asm, const MCFragment *Fragment,
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue);
@@ -223,8 +223,7 @@ class WinCOFFObjectWriter : public MCObjectWriter {
// MCObjectWriter interface implementation.
void reset() override;
- void executePostLayoutBinding(MCAssembler &Asm,
- const MCAsmLayout &Layout) override;
+ void executePostLayoutBinding(MCAssembler &Asm) override;
bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
const MCSymbol &SymA,
const MCFragment &FB, bool InSet,
@@ -834,8 +833,8 @@ void WinCOFFWriter::reset() {
WeakDefaults.clear();
}
-void WinCOFFWriter::executePostLayoutBinding(MCAssembler &Asm,
- const MCAsmLayout &Layout) {
+void WinCOFFWriter::executePostLayoutBinding(MCAssembler &Asm) {
+ auto &Layout = *Asm.getLayout();
// "Define" each section & symbol. This creates section & symbol
// entries in the staging area.
for (const auto &Section : Asm) {
@@ -1204,11 +1203,10 @@ bool WinCOFFObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
return &SymA.getSection() == FB.getParent();
}
-void WinCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
- const MCAsmLayout &Layout) {
- ObjWriter->executePostLayoutBinding(Asm, Layout);
+void WinCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm) {
+ ObjWriter->executePostLayoutBinding(Asm);
if (DwoWriter)
- DwoWriter->executePostLayoutBinding(Asm, Layout);
+ DwoWriter->executePostLayoutBinding(Asm);
}
void WinCOFFObjectWriter::recordRelocation(MCAssembler &Asm,
diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp
index 747968d270165..47d0407cb58cd 100644
--- a/llvm/lib/MC/XCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -351,7 +351,7 @@ class XCOFFObjectWriter : public MCObjectWriter {
void reset() override;
- void executePostLayoutBinding(MCAssembler &, const MCAsmLayout &) override;
+ void executePostLayoutBinding(MCAssembler &) override;
void recordRelocation(MCAssembler &, const MCFragment *, const MCFixup &,
MCValue, uint64_t &) override;
@@ -559,8 +559,7 @@ static MCSectionXCOFF *getContainingCsect(const MCSymbolXCOFF *XSym) {
return XSym->getRepresentedCsect();
}
-void XCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
- const MCAsmLayout &Layout) {
+void XCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm) {
for (const auto &S : Asm) {
const auto *MCSec = cast<const MCSectionXCOFF>(&S);
assert(!SectionMap.contains(MCSec) && "Cannot add a section twice.");
@@ -656,7 +655,7 @@ void XCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
Strings.add(Vers);
Strings.finalize();
- assignAddressesAndIndices(Asm, Layout);
+ assignAddressesAndIndices(Asm, *Asm.getLayout());
}
void XCOFFObjectWriter::recordRelocation(MCAssembler &Asm,
More information about the llvm-commits
mailing list