Previously I had asked how to write then read back IR to/from a file. The write code looked like: LLVMContext ctx; SMDiagnostic diag; Module *m = ParseIRFile( "my_file", diag, ctx ); However, the code I'm trying to retrofit LLVM IR into passes me just a std::ostream&. How can I read IR from a std::ostream? I figured out how to use raw_os_ostream to adapt a std::ostream to a raw_ostream for writing a module, but there's no obvious way to adapt the code for reading, e.g., no MemoryBuffer that adapts a std::ostream (unless I missed it). - Paul
Sorry for the (almost) repeat question, but I realized that, in my original question, I mistyped "ostream" when I meant "istream". Previously I had asked how to write then read back IR to/from a file. The write code looked like: LLVMContext ctx; SMDiagnostic diag; Module *m = ParseIRFile( "my_file", diag, ctx ); However, the code I'm trying to retrofit LLVM IR into passes me just a std::istream&. How can I read IR from a std::istream? I figured out how to use raw_os_ostream to adapt a std::ostream to a raw_ostream for writing a module, but there's no obvious way to adapt the code for reading, e.g., no MemoryBuffer that adapts a std::istream (unless I missed it). - Paul
You may be able to get by just reading everything from the stream into a buffer. -- Sean Silva On Sun, Oct 21, 2012 at 10:30 PM, Paul J. Lucas <paul at lucasmail.org> wrote:> Previously I had asked how to write then read back IR to/from a file. The write code looked like: > > LLVMContext ctx; > SMDiagnostic diag; > Module *m = ParseIRFile( "my_file", diag, ctx ); > > However, the code I'm trying to retrofit LLVM IR into passes me just a std::ostream&. How can I read IR from a std::ostream? > > I figured out how to use raw_os_ostream to adapt a std::ostream to a raw_ostream for writing a module, but there's no obvious way to adapt the code for reading, e.g., no MemoryBuffer that adapts a std::ostream (unless I missed it). > > - Paul > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Maybe Matching Threads
- [LLVMdev] Use printing methods of third-party libraries that use std::ostream
- [LLVMdev] Use printing methods of third-party libraries that use std::ostream
- [LLVMdev] Converting raw_ostream to std::ostream
- [LLVMdev] std::cout << *MyModule does not work anymore
- [LLVMdev] raw_os_ostream: symbol not found