[llvm-commits] [llvm] r129716 - /llvm/trunk/lib/MC/MCObjectStreamer.cpp
Eli Friedman
eli.friedman at gmail.com
Mon Apr 18 13:54:46 PDT 2011
Author: efriedma
Date: Mon Apr 18 15:54:46 2011
New Revision: 129716
URL: http://llvm.org/viewvc/llvm-project?rev=129716&view=rev
Log:
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.)
Modified:
llvm/trunk/lib/MC/MCObjectStreamer.cpp
Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=129716&r1=129715&r2=129716&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Mon Apr 18 15:54:46 2011
@@ -191,8 +191,11 @@
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,
More information about the llvm-commits
mailing list