[LLVMdev] Change in I/O Streams

Bill Wendling isanbard at gmail.com
Mon Nov 27 00:38:09 PST 2006


Hi all,

There is going to be a sweeping change in how the I/O streams are  
used. We'll no longer be using std::cout, std::cerr, std::cin, etc.  
in each file. Instead, new LLVM streams will be used. The reason for  
this is because each "#include <iostream>" introduces an overhead in  
each compilation unit due to it needing to make sure that all of the  
std::c* streams are constructed first. This is a terrible waste of  
resources and one which we can do without.

The changes should be pretty transparent. There may be a few places  
which need a hack to support sstreams. This will be solved in the  
future.

Here's what the changes are:

Old Way				New Way
-------				-------
#include <iostream>		#include "llvm/Support/Streams.h"
				    or
				class llvm_ostream;  // forward declaration

std::cout			llvm_cout
std::cerr			llvm_cerr
std::cin			llvm_cin

DEBUG(std::cerr << "foo");	DOUT << "foo";

The changes are going to be gradual. I'll be checking them in over  
the next week. I'll send out more information about changes in the  
future.

-bw




More information about the llvm-dev mailing list