summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-05-26 02:17:21 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-05-26 02:17:21 +0000
commit64acc7fcc79d789daf0559f5d254aa7dbfa3708e (patch)
tree24fafa7069df5cd4fe80201e3d794b4fb60890d3 /llvm/lib
parent5a1e80bc437db7f4fe9e62abd9c459c7000cade6 (diff)
downloadbcm5719-llvm-64acc7fcc79d789daf0559f5d254aa7dbfa3708e.tar.gz
bcm5719-llvm-64acc7fcc79d789daf0559f5d254aa7dbfa3708e.zip
Remove most uses of MCSectionData from MCAssembler.
llvm-svn: 238172
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp6
-rw-r--r--llvm/lib/MC/MCAssembler.cpp23
-rw-r--r--llvm/lib/MC/MCELFStreamer.cpp2
-rw-r--r--llvm/lib/MC/MCMachOStreamer.cpp2
-rw-r--r--llvm/lib/MC/MachObjectWriter.cpp23
-rw-r--r--llvm/lib/MC/WinCOFFObjectWriter.cpp2
-rw-r--r--llvm/lib/Target/R600/MCTargetDesc/AMDGPUAsmBackend.cpp2
7 files changed, 27 insertions, 33 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 872d3bb2a05..18070864317 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1150,7 +1150,7 @@ void ELFObjectWriter::writeSectionData(const MCAssembler &Asm,
// for writing to arbitrary buffers) for little benefit.
if (!Asm.getContext().getAsmInfo()->compressDebugSections() ||
!SectionName.startswith(".debug_") || SectionName == ".debug_frame") {
- Asm.writeSectionData(&SD, Layout);
+ Asm.writeSectionData(&Section, Layout);
return;
}
@@ -1164,12 +1164,12 @@ void ELFObjectWriter::writeSectionData(const MCAssembler &Asm,
StringRef(UncompressedData.data(), UncompressedData.size()),
CompressedContents);
if (Success != zlib::StatusOK) {
- Asm.writeSectionData(&SD, Layout);
+ Asm.writeSectionData(&Section, Layout);
return;
}
if (!prependCompressionHeader(UncompressedData.size(), CompressedContents)) {
- Asm.writeSectionData(&SD, Layout);
+ Asm.writeSectionData(&Section, Layout);
return;
}
Asm.getContext().renameELFSection(&Section,
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index c56775ac560..187fd1fd547 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -768,16 +768,15 @@ static void writeFragment(const MCAssembler &Asm, const MCAsmLayout &Layout,
"The stream should advance by fragment size");
}
-void MCAssembler::writeSectionData(const MCSectionData *SD,
+void MCAssembler::writeSectionData(const MCSection *Sec,
const MCAsmLayout &Layout) const {
// Ignore virtual sections.
- const MCSection &Sec = SD->getSection();
- if (Sec.isVirtualSection()) {
- assert(Layout.getSectionFileSize(&Sec) == 0 && "Invalid size for section!");
+ if (Sec->isVirtualSection()) {
+ assert(Layout.getSectionFileSize(Sec) == 0 && "Invalid size for section!");
// Check that contents are only things legal inside a virtual section.
- for (MCSectionData::const_iterator it = SD->begin(),
- ie = SD->end(); it != ie; ++it) {
+ for (MCSectionData::const_iterator it = Sec->begin(), ie = Sec->end();
+ it != ie; ++it) {
switch (it->getKind()) {
default: llvm_unreachable("Invalid fragment in virtual section!");
case MCFragment::FT_Data: {
@@ -789,7 +788,7 @@ void MCAssembler::writeSectionData(const MCSectionData *SD,
"Cannot have fixups in virtual section!");
for (unsigned i = 0, e = DF.getContents().size(); i != e; ++i)
if (DF.getContents()[i]) {
- if (auto *ELFSec = dyn_cast<const MCSectionELF>(&SD->getSection()))
+ if (auto *ELFSec = dyn_cast<const MCSectionELF>(Sec))
report_fatal_error("non-zero initializer found in section '" +
ELFSec->getSectionName() + "'");
else
@@ -818,12 +817,12 @@ void MCAssembler::writeSectionData(const MCSectionData *SD,
uint64_t Start = getWriter().getStream().tell();
(void)Start;
- for (MCSectionData::const_iterator it = SD->begin(), ie = SD->end();
+ for (MCSectionData::const_iterator it = Sec->begin(), ie = Sec->end();
it != ie; ++it)
writeFragment(*this, Layout, *it);
assert(getWriter().getStream().tell() - Start ==
- Layout.getSectionAddressSize(&SD->getSection()));
+ Layout.getSectionAddressSize(Sec));
}
std::pair<uint64_t, bool> MCAssembler::handleFixup(const MCAsmLayout &Layout,
@@ -1033,7 +1032,7 @@ bool MCAssembler::relaxDwarfCallFrameFragment(MCAsmLayout &Layout,
return OldSize != Data.size();
}
-bool MCAssembler::layoutSectionOnce(MCAsmLayout &Layout, MCSectionData &SD) {
+bool MCAssembler::layoutSectionOnce(MCAsmLayout &Layout, MCSection &Sec) {
// Holds the first fragment which needed relaxing during this layout. It will
// remain NULL if none were relaxed.
// When a fragment is relaxed, all the fragments following it should get
@@ -1041,7 +1040,7 @@ bool MCAssembler::layoutSectionOnce(MCAsmLayout &Layout, MCSectionData &SD) {
MCFragment *FirstRelaxedFragment = nullptr;
// Attempt to relax all the fragments in the section.
- for (MCSectionData::iterator I = SD.begin(), IE = SD.end(); I != IE; ++I) {
+ for (MCSectionData::iterator I = Sec.begin(), IE = Sec.end(); I != IE; ++I) {
// Check if this is a fragment that needs relaxation.
bool RelaxedFrag = false;
switch(I->getKind()) {
@@ -1081,7 +1080,7 @@ bool MCAssembler::layoutOnce(MCAsmLayout &Layout) {
bool WasRelaxed = false;
for (iterator it = begin(), ie = end(); it != ie; ++it) {
MCSection &Sec = *it;
- while (layoutSectionOnce(Layout, Sec.getSectionData()))
+ while (layoutSectionOnce(Layout, Sec))
WasRelaxed = true;
}
diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp
index cad5d93e459..b6778c4ab83 100644
--- a/llvm/lib/MC/MCELFStreamer.cpp
+++ b/llvm/lib/MC/MCELFStreamer.cpp
@@ -204,7 +204,7 @@ bool MCELFStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
// important for matching the string table that 'as' generates.
IndirectSymbolData ISD;
ISD.Symbol = Symbol;
- ISD.SectionData = getCurrentSectionData();
+ ISD.Section = &getCurrentSectionData()->getSection();
getAssembler().getIndirectSymbols().push_back(ISD);
return true;
}
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index 8fb9711178a..204dccf02f6 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -287,7 +287,7 @@ bool MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
// important for matching the string table that 'as' generates.
IndirectSymbolData ISD;
ISD.Symbol = Symbol;
- ISD.SectionData = getCurrentSectionData();
+ ISD.Section = &getCurrentSectionData()->getSection();
getAssembler().getIndirectSymbols().push_back(ISD);
return true;
}
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index 7a4200136d2..44685209285 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -478,8 +478,7 @@ void MachObjectWriter::BindIndirectSymbols(MCAssembler &Asm) {
// or stub section.
for (MCAssembler::indirect_symbol_iterator it = Asm.indirect_symbol_begin(),
ie = Asm.indirect_symbol_end(); it != ie; ++it) {
- const MCSectionMachO &Section =
- cast<MCSectionMachO>(it->SectionData->getSection());
+ const MCSectionMachO &Section = cast<MCSectionMachO>(*it->Section);
if (Section.getType() != MachO::S_NON_LAZY_SYMBOL_POINTERS &&
Section.getType() != MachO::S_LAZY_SYMBOL_POINTERS &&
@@ -494,15 +493,13 @@ void MachObjectWriter::BindIndirectSymbols(MCAssembler &Asm) {
unsigned IndirectIndex = 0;
for (MCAssembler::indirect_symbol_iterator it = Asm.indirect_symbol_begin(),
ie = Asm.indirect_symbol_end(); it != ie; ++it, ++IndirectIndex) {
- const MCSectionMachO &Section =
- cast<MCSectionMachO>(it->SectionData->getSection());
+ const MCSectionMachO &Section = cast<MCSectionMachO>(*it->Section);
if (Section.getType() != MachO::S_NON_LAZY_SYMBOL_POINTERS)
continue;
// Initialize the section indirect symbol base, if necessary.
- IndirectSymBase.insert(
- std::make_pair(&it->SectionData->getSection(), IndirectIndex));
+ IndirectSymBase.insert(std::make_pair(it->Section, IndirectIndex));
Asm.getOrCreateSymbolData(*it->Symbol);
}
@@ -511,16 +508,14 @@ void MachObjectWriter::BindIndirectSymbols(MCAssembler &Asm) {
IndirectIndex = 0;
for (MCAssembler::indirect_symbol_iterator it = Asm.indirect_symbol_begin(),
ie = Asm.indirect_symbol_end(); it != ie; ++it, ++IndirectIndex) {
- const MCSectionMachO &Section =
- cast<MCSectionMachO>(it->SectionData->getSection());
+ const MCSectionMachO &Section = cast<MCSectionMachO>(*it->Section);
if (Section.getType() != MachO::S_LAZY_SYMBOL_POINTERS &&
Section.getType() != MachO::S_SYMBOL_STUBS)
continue;
// Initialize the section indirect symbol base, if necessary.
- IndirectSymBase.insert(
- std::make_pair(&it->SectionData->getSection(), IndirectIndex));
+ IndirectSymBase.insert(std::make_pair(it->Section, IndirectIndex));
// Set the symbol type to undefined lazy, but only on construction.
//
@@ -913,10 +908,10 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm,
// Write the actual section data.
for (MCAssembler::const_iterator it = Asm.begin(),
ie = Asm.end(); it != ie; ++it) {
- const MCSectionData &SD = it->getSectionData();
- Asm.writeSectionData(&SD, Layout);
+ MCSection &Sec = *it;
+ Asm.writeSectionData(&Sec, Layout);
- uint64_t Pad = getPaddingSize(&*it, Layout);
+ uint64_t Pad = getPaddingSize(&Sec, Layout);
WriteZeros(Pad);
}
@@ -972,7 +967,7 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm,
// Indirect symbols in the non-lazy symbol pointer section have some
// special handling.
const MCSectionMachO &Section =
- static_cast<const MCSectionMachO&>(it->SectionData->getSection());
+ static_cast<const MCSectionMachO &>(*it->Section);
if (Section.getType() == MachO::S_NON_LAZY_SYMBOL_POINTERS) {
// If this symbol is defined and internal, mark it as such.
if (it->Symbol->isDefined() &&
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp
index b53dfa5da57..723290560b5 100644
--- a/llvm/lib/MC/WinCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp
@@ -1034,7 +1034,7 @@ void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm,
WriteZeros(SectionDataPadding);
- Asm.writeSectionData(&j->getSectionData(), Layout);
+ Asm.writeSectionData(&*j, Layout);
}
if ((*i)->Relocations.size() > 0) {
diff --git a/llvm/lib/Target/R600/MCTargetDesc/AMDGPUAsmBackend.cpp b/llvm/lib/Target/R600/MCTargetDesc/AMDGPUAsmBackend.cpp
index 9704457d1aa..2605ca52dfd 100644
--- a/llvm/lib/Target/R600/MCTargetDesc/AMDGPUAsmBackend.cpp
+++ b/llvm/lib/Target/R600/MCTargetDesc/AMDGPUAsmBackend.cpp
@@ -67,7 +67,7 @@ public:
void AMDGPUMCObjectWriter::WriteObject(MCAssembler &Asm,
const MCAsmLayout &Layout) {
for (MCAssembler::iterator I = Asm.begin(), E = Asm.end(); I != E; ++I) {
- Asm.writeSectionData(&I->getSectionData(), Layout);
+ Asm.writeSectionData(&*I, Layout);
}
}
OpenPOWER on IntegriCloud