[llvm-commits] [llvm] r129688 - /llvm/trunk/lib/MC/MCObjectStreamer.cpp

Eli Friedman eli.friedman at gmail.com
Sun Apr 17 22:38:58 PDT 2011


Author: efriedma
Date: Mon Apr 18 00:38:58 2011
New Revision: 129688

URL: http://llvm.org/viewvc/llvm-project?rev=129688&view=rev
Log:
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.


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=129688&r1=129687&r2=129688&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Mon Apr 18 00:38:58 2011
@@ -191,8 +191,10 @@
 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,





More information about the llvm-commits mailing list