raw_pwrite_stream on a non-fixed-size buffer?

I wanted to bring this up again. I still try to get access to the assembler of a jit-compiled function/module using llvm 3.8 and later. In 3.8 the interface to addPassesToEmitFile has changed and my old method doesn't work any more.

In principle one gets the asm with

targetMachine->addPassesToEmitFile( PM , *OS , llvm::TargetMachine::CGFT_AssemblyFile )

where *OS is a raw_pwrite_stream.

The problem is that I only find use cases of raw_pwrite_stream where the derived class raw_svector_ostream is initialized on a SmallString, like

SmallString<128> Str;
raw_svector_ostream OS(Str);

However, the assembler of the modules could be arbitrary large (not fitting in any finite sized SmallString)

What can I do?


SmallString template parameter is the initial buffer size, but it resizes automatically as needed.

Thanks! It works.