On Fri, Jul 20, 2012 at 11:28 AM, Richard Guenther
<[email protected]> wrote:
> On Fri, Jul 20, 2012 at 11:02 AM, Steven Bosscher <[email protected]>
> wrote:
>> On Thu, Jul 19, 2012 at 11:09 AM, Richard Guenther
>> <[email protected]> wrote:
>>> Hmm, pp_flush looks like a lot more expensive compared to pp_newline
>>> for example in
>>>
>>> @@ -74,7 +74,7 @@ maybe_init_pretty_print (FILE *file)
>>> static void
>>> newline_and_indent (pretty_printer *buffer, int spc)
>>> {
>>> - pp_newline (buffer);
>>> + pp_flush (buffer);
>>> INDENT (spc);
>>> }
>>>
>>> And I'm pretty sure that newline_and_indent callers that after it directly
>>> dump to the stream should be fixed instead. In fact, constant flushing
>>> will just make things slow (yes, it's only dumping ...).
>>
>> Right, it's only dumping. I'm surprised one would care about its
>> performance. And the patch actually helps in the debugger also: if for
>> some reason a piece of invalid gimple is encountered then at least the
>> part that was OK is still dumped. But oh well :-)
>>
>> I will need this additional patch to avoid test suite failures:
>>
>> Index: pretty-print.c
>> ===================================================================
>> --- pretty-print.c (revision 189705)
>> +++ pretty-print.c (working copy)
>> @@ -759,6 +759,7 @@ void
>> pp_base_newline (pretty_printer *pp)
>> {
>> obstack_1grow (pp->buffer->obstack, '\n');
>> + pp_needs_newline (pp) = false;
>> pp->buffer->line_length = 0;
>> }
>>
>> I suppose that's OK?
>
> Yes.
I also need this one:
-------------- 8< -----------
Index: gimple-pretty-print.c
--- gimple-pretty-print.c (revision 189778)
+++ gimple-pretty-print.c (working copy)
@@ -2265,6 +2265,7 @@ gimple_dump_bb_buff (pretty_printer *buf
}
dump_implicit_edges (buffer, bb, indent, flags);
+ pp_flush (buffer);
}
-------------- 8< -----------
or you get nonsense dumps like:
...
;; basic block 4, loop depth 0
;; pred: 2
<bb 4>:
if (node_3(D) != node_20)
;; succ: 6
;; 5
;; basic block 5, loop depth 0
;; pred: 6
;; 4
<bb 5>:
goto <bb 6>;
else
goto <bb 5>;
...
Will commit as obvious.
Ciao!
Steven