[LLVMdev] std::cout << *MyModule does not work anymore
Daniel Dunbar
daniel at zuster.org
Mon Aug 24 18:55:00 PDT 2009
On Mon, Aug 24, 2009 at 5:40 PM, Óscar Fuentes<ofv at wanadoo.es> wrote:
> It seems that support for dumping text representation of LLVM objects to
> standard channels and C++ output streams was removed. My guess is that
> now we must use errs() instead of std::cerr, llvm::raw_fd_ostream
> instead of std::ofstream, etc.
Correct. std::ostream has been purged from LLVM; the only exception is
the raw_os_ostream class, which can be used to adapt an std::ostream
for use with raw_ostream. This should be enough for clients which want
to keep using std::ostream.
> The changes are not trivial, as for instance llvm::raw_fd_ostream
> without flags fails if the file exists, but std::ofstream does not. The
> changes include using new names for flags that already exist on the
> standard namespace (F_Force instead of O_TRUNC, etc).
I believe that Dan plans to fix the "force by default" issue, at least.
> Is all this an unintended change or an intentional one, and if the
> later, could you direct me to something that explains what we gain on
> exchange of this restriction?
Intentional. std::ostream has long been deprecated in LLVM, each
release has increased the degree of deprecation. The coding standards
document has various bits of information on this
http://llvm.org/docs/CodingStandards.html.
Among other things, you gain performance. raw_ostream is considerably
faster than std::ostream. This is the performance difference on the my
synthetic raw_ostream benchmark:
- raw_fd_ostream (outs()) -
--
name avg min med max SD total
user 1.0002 0.9990 0.9992 1.0024 0.0015 3.0006
sys 0.0089 0.0074 0.0079 0.0114 0.0018 0.0268
wall 1.0368 1.0137 1.0185 1.0782 0.0294 3.1104
--
- std::ostream (cout) -
--
name avg min med max SD total
user 6.8846 6.8807 6.8853 6.8878 0.0029 20.6537
sys 0.0384 0.0377 0.0352 0.0423 0.0029 0.1152
wall 6.9852 6.9685 6.9756 7.0115 0.0188 20.9555
--
- Daniel
More information about the llvm-dev
mailing list