Patchwork More cleanups for CFG dumping

login
register
mail settings
Submitter Steven Bosscher
Date July 23, 2012, 1:09 p.m.
Message ID <CABu31nNzb+R=ZLiJggz1rTz2u-F97X6mMgO=+W5zfyx2H5E3Xw@mail.gmail.com>
Download mbox | patch
Permalink /patch/172677/
State New
Headers show

Comments

Steven Bosscher - July 23, 2012, 1:09 p.m.
On Fri, Jul 20, 2012 at 11:28 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Fri, Jul 20, 2012 at 11:02 AM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
>> On Thu, Jul 19, 2012 at 11:09 AM, Richard Guenther
>> <richard.guenther@gmail.com> 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< -----------
-------------- 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

Patch

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);
 }