aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCObjectStreamer.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2011-04-18 20:54:46 +0000
committerEli Friedman <eli.friedman@gmail.com>2011-04-18 20:54:46 +0000
commitb2545fbc2a85cd8feca55051626cfc76e30d7f3e (patch)
tree38fed98c1c32599ea082320c425f3d5c4db328df /llvm/lib/MC/MCObjectStreamer.cpp
parent17740e70d5584c3a36db94b587d152484bdd2a19 (diff)
downloadllvm-b2545fbc2a85cd8feca55051626cfc76e30d7f3e.zip
llvm-b2545fbc2a85cd8feca55051626cfc76e30d7f3e.tar.gz
llvm-b2545fbc2a85cd8feca55051626cfc76e30d7f3e.tar.bz2
malloc elimination: it's a bad idea to use raw_svector_ostream on a
small heap-allocated SmallString because it unconditionally forces a malloc. (Revised version of r129688, with the necessary flush() call.) llvm-svn: 129716
Diffstat (limited to 'llvm/lib/MC/MCObjectStreamer.cpp')
-rw-r--r--llvm/lib/MC/MCObjectStreamer.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index ef22eaa..bd7de57 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -191,8 +191,11 @@ void MCObjectStreamer::EmitInstruction(const MCInst &Inst) {
void MCObjectStreamer::EmitInstToFragment(const MCInst &Inst) {
MCInstFragment *IF = new MCInstFragment(Inst, getCurrentSectionData());
- raw_svector_ostream VecOS(IF->getCode());
+ SmallString<128> Code;
+ raw_svector_ostream VecOS(Code);
getAssembler().getEmitter().EncodeInstruction(Inst, VecOS, IF->getFixups());
+ VecOS.flush();
+ IF->getCode().append(Code.begin(), Code.end());
}
static const MCExpr *BuildSymbolDiff(MCContext &Context,