aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCObjectStreamer.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2011-04-18 05:38:58 +0000
committerEli Friedman <eli.friedman@gmail.com>2011-04-18 05:38:58 +0000
commit2dc287a1471bf7e181d7f7bac6a10dbb84e636f4 (patch)
tree7a964a6f564ca4cc3f43860b76d6185961347123 /llvm/lib/MC/MCObjectStreamer.cpp
parent0e40208d7bb3ff2cac8bad38a578bfe52e7d3ff8 (diff)
downloadllvm-2dc287a1471bf7e181d7f7bac6a10dbb84e636f4.zip
llvm-2dc287a1471bf7e181d7f7bac6a10dbb84e636f4.tar.gz
llvm-2dc287a1471bf7e181d7f7bac6a10dbb84e636f4.tar.bz2
More malloc elimination: it's a bad idea to use raw_svector_ostream on a
small heap-allocated SmallString because it unconditionally forces a malloc. llvm-svn: 129688
Diffstat (limited to 'llvm/lib/MC/MCObjectStreamer.cpp')
-rw-r--r--llvm/lib/MC/MCObjectStreamer.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index ef22eaa..9fe6823 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -191,8 +191,10 @@ 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());
+ IF->getCode().append(Code.begin(), Code.end());
}
static const MCExpr *BuildSymbolDiff(MCContext &Context,