[llvm-commits] [llvm] r77425 - in /llvm/trunk: include/llvm/Support/FormattedStream.h lib/Support/FormattedStream.cpp
Daniel Dunbar
daniel at zuster.org
Tue Jul 28 20:04:23 PDT 2009
Author: ddunbar
Date: Tue Jul 28 22:04:22 2009
New Revision: 77425
URL: http://llvm.org/viewvc/llvm-project?rev=77425&view=rev
Log:
Revert r77397, it causes significant regressions in llc performance.
Modified:
llvm/trunk/include/llvm/Support/FormattedStream.h
llvm/trunk/lib/Support/FormattedStream.cpp
Modified: llvm/trunk/include/llvm/Support/FormattedStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FormattedStream.h?rev=77425&r1=77424&r2=77425&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/FormattedStream.h (original)
+++ llvm/trunk/include/llvm/Support/FormattedStream.h Tue Jul 28 22:04:22 2009
@@ -49,13 +49,13 @@
///
bool DeleteStream;
- /// ColumnFlushed - The current output column of the data that's
- /// been flushed. The column scheme is zero-based.
+ /// Column - The current output column of the stream. The column
+ /// scheme is zero-based.
///
- unsigned ColumnFlushed;
+ unsigned Column;
virtual void write_impl(const char *Ptr, size_t Size) {
- ComputeColumn(ColumnFlushed);
+ ComputeColumn(Ptr, Size);
TheStream->write(Ptr, Size);
}
@@ -67,10 +67,10 @@
return TheStream->tell() - TheStream->GetNumBytesInBuffer();
}
- /// ComputeColumn - Examine the current buffer and figure out
- /// which column we're in.
+ /// ComputeColumn - Examine the current output and figure out
+ /// which column we end up in after output.
///
- void ComputeColumn(unsigned &Column);
+ void ComputeColumn(const char *Ptr, size_t Size);
public:
/// formatted_raw_ostream - Open the specified file for
@@ -84,11 +84,11 @@
/// underneath it.
///
formatted_raw_ostream(raw_ostream &Stream, bool Delete = false)
- : raw_ostream(), TheStream(0), DeleteStream(false), ColumnFlushed(0) {
+ : raw_ostream(), TheStream(0), DeleteStream(false), Column(0) {
setStream(Stream, Delete);
}
explicit formatted_raw_ostream()
- : raw_ostream(), TheStream(0), DeleteStream(false), ColumnFlushed(0) {}
+ : raw_ostream(), TheStream(0), DeleteStream(false), Column(0) {}
~formatted_raw_ostream() {
if (DeleteStream)
Modified: llvm/trunk/lib/Support/FormattedStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FormattedStream.cpp?rev=77425&r1=77424&r2=77425&view=diff
==============================================================================
--- llvm/trunk/lib/Support/FormattedStream.cpp (original)
+++ llvm/trunk/lib/Support/FormattedStream.cpp Tue Jul 28 22:04:22 2009
@@ -19,11 +19,11 @@
/// ComputeColumn - Examine the current output and figure out which
/// column we end up in after output.
///
-void formatted_raw_ostream::ComputeColumn(unsigned &Column) {
+void formatted_raw_ostream::ComputeColumn(const char *Ptr, size_t Size) {
// Keep track of the current column by scanning the string for
// special characters
- for (const char *Ptr = begin(); Ptr != end(); ++Ptr) {
+ for (const char *epos = Ptr + Size; Ptr != epos; ++Ptr) {
++Column;
if (*Ptr == '\n' || *Ptr == '\r')
Column = 0;
@@ -38,13 +38,8 @@
/// \param MinPad - The minimum space to give after the most recent
/// I/O, even if the current column + minpad > newcol.
///
-void formatted_raw_ostream::PadToColumn(unsigned NewCol, unsigned MinPad) {
- // Start out from the last flush position.
- unsigned Column = ColumnFlushed;
-
- // Now figure out what's in the buffer and add it to the column
- // count.
- ComputeColumn(Column);
+void formatted_raw_ostream::PadToColumn(unsigned NewCol, unsigned MinPad) {
+ flush();
// Output spaces until we reach the desired column.
unsigned num = NewCol - Column;
More information about the llvm-commits
mailing list