[llvm-commits] [llvm] r77397 - in /llvm/trunk: include/llvm/Support/FormattedStream.h lib/Support/FormattedStream.cpp
Evan Cheng
evan.cheng at apple.com
Tue Jul 28 21:48:12 PDT 2009
Ok. David, I'm going to revert AsmWriterEmitter.cpp back to 74742 for
now. Please re-commit as you have fixed the efficiency problem.
Thanks,
Evan
On Jul 28, 2009, at 9:35 PM, Chris Lattner wrote:
>
> On Jul 28, 2009, at 9:32 PM, Evan Cheng wrote:
>
>> Have we recovered the previous lost compile time?
>
> No, this patch made it worse because of the N^2 algorithm.
>
> -Chris
>
>>
>>
>> Evan
>>
>> On Jul 28, 2009, at 8:04 PM, Daniel Dunbar wrote:
>>
>>> Hi David,
>>>
>>> On Tue, Jul 28, 2009 at 4:26 PM, David Greene<greened at obbligato.org>
>>> wrote:
>>>> Author: greened
>>>> Date: Tue Jul 28 18:26:34 2009
>>>> New Revision: 77397
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=77397&view=rev
>>>> Log:
>>>>
>>>> Improve performance of PadToColumn by eliminating flushes.
>>>
>>> Did you time this? I had to revert this patch, it was causing
>>> significant regressions on nightlytest, and in my local timings (llc
>>> -fast-isel -regalloc=local on instcombine.bc) it was almost twice as
>>> slow!
>>>
>>> ddunbar at giles:regr-2009-07-28_19-23$ for r in llc.r7739*; do echo
>>> "--
>>> $r --"; runN 10 ./$r -fast-isel -regalloc=local instcombine.bc -f -o
>>> /dev/null; done
>>> -- llc.r77396 --
>>> name avg min med max SD total
>>> user 1.7877 1.6809 1.7959 1.9022 0.0668 17.8772
>>> sys 0.2849 0.2735 0.2865 0.3035 0.0107 2.8489
>>> wall 2.0794 1.9574 2.0865 2.2134 0.0775 20.7939
>>> -- llc.r77397 --
>>> name avg min med max SD total
>>> user 3.3274 3.1411 3.3089 3.5753 0.1541 33.2742
>>> sys 0.0586 0.0596 0.0581 0.0617 0.0037 0.5862
>>> wall 3.3922 3.2062 3.3750 3.6403 0.1550 33.9220
>>>
>>> (runN is a timing tool of mine, like 'time' with more goodies)
>>>
>>> - Daniel
>>>
>>>> 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=77397&r1=77396&r2=77397&view=diff
>>>>
>>>> =
>>>> =
>>>> =
>>>> =
>>>> =
>>>> =
>>>> =
>>>> =
>>>> =
>>>> =
>>>> =
>>>> ===================================================================
>>>> --- llvm/trunk/include/llvm/Support/FormattedStream.h (original)
>>>> +++ llvm/trunk/include/llvm/Support/FormattedStream.h Tue Jul 28
>>>> 18:26:34 2009
>>>> @@ -49,13 +49,13 @@
>>>> ///
>>>> bool DeleteStream;
>>>>
>>>> - /// Column - The current output column of the stream. The
>>>> column
>>>> - /// scheme is zero-based.
>>>> + /// ColumnFlushed - The current output column of the data
>>>> that's
>>>> + /// been flushed. The column scheme is zero-based.
>>>> ///
>>>> - unsigned Column;
>>>> + unsigned ColumnFlushed;
>>>>
>>>> virtual void write_impl(const char *Ptr, size_t Size) {
>>>> - ComputeColumn(Ptr, Size);
>>>> + ComputeColumn(ColumnFlushed);
>>>> TheStream->write(Ptr, Size);
>>>> }
>>>>
>>>> @@ -67,10 +67,10 @@
>>>> return TheStream->tell() - TheStream->GetNumBytesInBuffer();
>>>> }
>>>>
>>>> - /// ComputeColumn - Examine the current output and figure out
>>>> - /// which column we end up in after output.
>>>> + /// ComputeColumn - Examine the current buffer and figure out
>>>> + /// which column we're in.
>>>> ///
>>>> - void ComputeColumn(const char *Ptr, size_t Size);
>>>> + void ComputeColumn(unsigned &Column);
>>>>
>>>> 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), Column
>>>> (0) {
>>>> + : raw_ostream(), TheStream(0), DeleteStream(false),
>>>> ColumnFlushed(0) {
>>>> setStream(Stream, Delete);
>>>> }
>>>> explicit formatted_raw_ostream()
>>>> - : raw_ostream(), TheStream(0), DeleteStream(false), Column
>>>> (0) {}
>>>> + : raw_ostream(), TheStream(0), DeleteStream(false),
>>>> ColumnFlushed(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=77397&r1=77396&r2=77397&view=diff
>>>>
>>>> =
>>>> =
>>>> =
>>>> =
>>>> =
>>>> =
>>>> =
>>>> =
>>>> =
>>>> =
>>>> =
>>>> ===================================================================
>>>> --- llvm/trunk/lib/Support/FormattedStream.cpp (original)
>>>> +++ llvm/trunk/lib/Support/FormattedStream.cpp Tue Jul 28 18:26:34
>>>> 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(const char *Ptr, size_t
>>>> Size) {
>>>> +void formatted_raw_ostream::ComputeColumn(unsigned &Column) {
>>>> // Keep track of the current column by scanning the string for
>>>> // special characters
>>>>
>>>> - for (const char *epos = Ptr + Size; Ptr != epos; ++Ptr) {
>>>> + for (const char *Ptr = begin(); Ptr != end(); ++Ptr) {
>>>> ++Column;
>>>> if (*Ptr == '\n' || *Ptr == '\r')
>>>> Column = 0;
>>>> @@ -38,8 +38,13 @@
>>>> /// \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) {
>>>> - flush();
>>>> +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);
>>>>
>>>> // Output spaces until we reach the desired column.
>>>> unsigned num = NewCol - Column;
>>>>
>>>>
>>>> _______________________________________________
>>>> llvm-commits mailing list
>>>> llvm-commits at cs.uiuc.edu
>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list