summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorEli Bendersky <eliben@google.com>2012-12-07 22:06:56 +0000
committerEli Bendersky <eliben@google.com>2012-12-07 22:06:56 +0000
commit84b2a795705d994d2a333d49a00ff7132627cbe3 (patch)
treecad6f5200d41b6005a1fb12e449d8ba8c7f485e0 /llvm/lib
parenta0e4706fe6561e39a7a2fb4929553fa364feae25 (diff)
downloadbcm5719-llvm-84b2a795705d994d2a333d49a00ff7132627cbe3.tar.gz
bcm5719-llvm-84b2a795705d994d2a333d49a00ff7132627cbe3.zip
Make the contents of encoded sections SmallVector<char, N> instead of
SmallString. This makes it possible to use the length-erased SmallVectorImpl in the interface without imposing buffer size. Thus, the size of MCInstFragment is back down since a preallocated 8-byte contents buffer is enough. It would be generally a good idea to rid all the fragments of SmallString as contents, because a vector just makes more sense. llvm-svn: 169644
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp16
-rw-r--r--llvm/lib/MC/MCAssembler.cpp2
2 files changed, 9 insertions, 9 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index b0623d35a9e..bfe17094628 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -203,7 +203,7 @@ class ELFObjectWriter : public MCObjectWriter {
void String8(MCDataFragment &F, uint8_t Value) {
char buf[1];
buf[0] = Value;
- F.getContents() += StringRef(buf, 1);
+ F.getContents().append(&buf[0], &buf[1]);
}
void String16(MCDataFragment &F, uint16_t Value) {
@@ -212,7 +212,7 @@ class ELFObjectWriter : public MCObjectWriter {
StringLE16(buf, Value);
else
StringBE16(buf, Value);
- F.getContents() += StringRef(buf, 2);
+ F.getContents().append(&buf[0], &buf[2]);
}
void String32(MCDataFragment &F, uint32_t Value) {
@@ -221,7 +221,7 @@ class ELFObjectWriter : public MCObjectWriter {
StringLE32(buf, Value);
else
StringBE32(buf, Value);
- F.getContents() += StringRef(buf, 4);
+ F.getContents().append(&buf[0], &buf[4]);
}
void String64(MCDataFragment &F, uint64_t Value) {
@@ -230,7 +230,7 @@ class ELFObjectWriter : public MCObjectWriter {
StringLE64(buf, Value);
else
StringBE64(buf, Value);
- F.getContents() += StringRef(buf, 8);
+ F.getContents().append(&buf[0], &buf[8]);
}
void WriteHeader(uint64_t SectionDataSize,
@@ -1186,7 +1186,7 @@ void ELFObjectWriter::CreateMetadataSections(MCAssembler &Asm,
// The first entry of a string table holds a null character so skip
// section 0.
uint64_t Index = 1;
- F->getContents() += '\x00';
+ F->getContents().push_back('\x00');
for (unsigned int I = 0, E = Sections.size(); I != E; ++I) {
const MCSectionELF &Section = *Sections[I];
@@ -1204,8 +1204,8 @@ void ELFObjectWriter::CreateMetadataSections(MCAssembler &Asm,
SectionStringTableIndex[&Section] = Index;
Index += Name.size() + 1;
- F->getContents() += Name;
- F->getContents() += '\x00';
+ F->getContents().append(Name.begin(), Name.end());
+ F->getContents().push_back('\x00');
}
}
@@ -1380,7 +1380,7 @@ void ELFObjectWriter::WriteDataSectionData(MCAssembler &Asm,
++i) {
const MCFragment &F = *i;
assert(F.getKind() == MCFragment::FT_Data);
- WriteBytes(cast<MCDataFragment>(F).getContents().str());
+ WriteBytes(cast<MCDataFragment>(F).getContents());
}
} else {
Asm.writeSectionData(&SD, Layout);
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index b2136e553e2..989d8be0af5 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -391,7 +391,7 @@ void MCAsmLayout::LayoutFragment(MCFragment *F) {
/// a MCEncodedFragment.
static void writeFragmentContents(const MCFragment &F, MCObjectWriter *OW) {
MCEncodedFragment &EF = cast<MCEncodedFragment>(F);
- OW->WriteBytes(EF.getContents().str());
+ OW->WriteBytes(EF.getContents());
}
/// \brief Write the fragment \p F to the output file.
OpenPOWER on IntegriCloud