On Fri, Aug 30, 2013 at 11:28 PM, Sharad Singhai <sing...@google.com> wrote:
>> Found the issue. The stream was incorrectly being closed when it was
>> stderr/stdout. So only the dump output before the first dump_finish
>> call was being emitted to stderr. I fixed this the same way the
>> alt_dump_file was being handled just below - don't close if it is
>> stderr/stdout. Confirmed that this fixes the problem.
>>
>> (So the real ratio between the volume of -fdump-...=stderr and
>> -fopt-info is much higher than what I reported in an earlier email)
>>
>> Is the following patch ok, pending regression tests?
>>
>> 2013-08-30  Teresa Johnson  <tejohn...@google.com>
>>
>>         * dumpfile.c (dump_finish): Don't close stderr/stdout.
>>
>> Index: dumpfile.c
>> ===================================================================
>> --- dumpfile.c  (revision 202059)
>> +++ dumpfile.c  (working copy)
>> @@ -450,7 +450,8 @@ dump_finish (int phase)
>>    if (phase < 0)
>>      return;
>>    dfi = get_dump_file_info (phase);
>> -  if (dfi->pstream)
>> +  if (dfi->pstream && strcmp("stderr", dfi->pfilename) != 0
>> +      && strcmp("stdout", dfi->pfilename) != 0)
>>      fclose (dfi->pstream);
>>
>>    if (dfi->alt_stream && strcmp("stderr", dfi->alt_filename) != 0
>
> Yes, this is clearly a bug which I missed. Thanks for fixing it. Is it
> feasible to add a test case for it?
>
> Thanks,
> Sharad


Good idea. I modified an existing test to dump to stderr instead of a
dump file. Since it has 2 functions with messages from each, I
confirmed that it exposed the bug.

Here is the full patch. Bootstrapped and tested on
x86_64-unknown-linux-gnu. Ok for trunk?

Thanks,
Teresa

2013-09-03  Teresa Johnson  <tejohn...@google.com>

        * dumpfile.c (dump_finish): Don't close stderr/stdout.

        * testsuite/gcc.dg/unroll_1.c: Test dumping to stderr.

Index: dumpfile.c
===================================================================
--- dumpfile.c  (revision 202121)
+++ dumpfile.c  (working copy)
@@ -450,7 +450,9 @@ dump_finish (int phase)
   if (phase < 0)
     return;
   dfi = get_dump_file_info (phase);
-  if (dfi->pstream)
+  if (dfi->pstream && (!dfi->pfilename
+                       || (strcmp("stderr", dfi->pfilename) != 0
+                           && strcmp("stdout", dfi->pfilename) != 0)))
     fclose (dfi->pstream);

   if (dfi->alt_stream && strcmp("stderr", dfi->alt_filename) != 0
Index: testsuite/gcc.dg/unroll_1.c
===================================================================
--- testsuite/gcc.dg/unroll_1.c (revision 202121)
+++ testsuite/gcc.dg/unroll_1.c (working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-rtl-loop2_unroll -fno-peel-loops
-fdisable-tree-cunroll -fdisable-tree-cunrolli
-fenable-rtl-loop2_unroll" } */
+/* { dg-options "-O2 -fdump-rtl-loop2_unroll=stderr -fno-peel-loops
-fdisable-tree-cunroll -fdisable-tree-cunrolli
-fenable-rtl-loop2_unroll" } */

 unsigned a[100], b[100];
 inline void bar()
@@ -11,7 +11,7 @@ int foo(void)
 {
   int i;
   bar();
-  for (i = 0; i < 2; i++)
+  for (i = 0; i < 2; i++) /* { dg-message "note: loop turned into
non-loop; it never loops" } */
   {
      a[i]= b[i] + 1;
   }
@@ -21,12 +21,10 @@ int foo(void)
 int foo2(void)
 {
   int i;
-  for (i = 0; i < 2; i++)
+  for (i = 0; i < 2; i++) /* { dg-message "note: loop turned into
non-loop; it never loops" } */
   {
      a[i]= b[i] + 1;
   }
   return 1;
 }
-
-/* { dg-final { scan-rtl-dump-times "loop turned into non-loop; it
never loops" 2 "loop2_unroll" } } */
-/* { dg-final { cleanup-rtl-dump "loop2_unroll" } } */
+/* { dg-prune-output ".*" } */


-- 
Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413

Reply via email to