public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] dump type attributes in dump_function_to_file
@ 2020-11-20 18:12 Martin Sebor
  2020-11-20 23:14 ` Jeff Law
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Sebor @ 2020-11-20 18:12 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 421 bytes --]

dump_function_to_file prints DECL_ATTRIBUTES but not TYPE_ATTRIBUTES
when both can be important and helpful for debugging, especially with
attributes that are added implicitly (such attribute access and
the proposed internal attribute *dealloc).  The function also prints
function arguments (and their types) but not its return type, again,
leaving out a useful detail.  The attached tweak adds both to
the dump.

Martin

[-- Attachment #2: gcc-dump-type-attr.diff --]
[-- Type: text/x-patch, Size: 2278 bytes --]

gcc/ChangeLog:

	* gcc/tree-cfg.c (dump_function_to_file): Print type attributes
	and return type.

gcc/testsuite/ChangeLog:
	* gcc.dg/attr-access-4.c: New test.

diff --git a/gcc/testsuite/gcc.dg/attr-access-4.c b/gcc/testsuite/gcc.dg/attr-access-4.c
new file mode 100644
index 00000000000..e78b3602ade
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/attr-access-4.c
@@ -0,0 +1,16 @@
+/* { dg-do compile }
+   { dg-options "-fdump-tree-gimple" } */
+
+__attribute__ ((aligned (32)))
+__attribute__ ((access (write_only, 2, 1)))
+void f (int n, void *p)
+{
+  __builtin_memset (p, 0, n);
+}
+
+/* Verify the DECL_ATTRIBUTE "aligned" is mentioned:
+   { dg-final { scan-tree-dump "__attribute__\\(\\(aligned" "gimple" } }
+   and the TYPE_ATTRIBUTE "access" is also mentioned:
+   { dg-final { scan-tree-dump "__attribute__\\(\\(access" "gimple" } }
+   and the function signature including its return type is mentioned:
+   { dg-final { scan-tree-dump "void f *\\(int n, void *\\* *p\\)" "gimple" } } */
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 5139f111fec..138f8ef17e0 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -7966,14 +7966,19 @@ dump_function_to_file (tree fndecl, FILE *file, dump_flags_t flags)
 		  && decl_is_tm_clone (fndecl));
   struct function *fun = DECL_STRUCT_FUNCTION (fndecl);
 
-  if (DECL_ATTRIBUTES (fndecl) != NULL_TREE)
+  tree fntype = TREE_TYPE (fndecl);
+  tree attrs[] = { DECL_ATTRIBUTES (fndecl), TYPE_ATTRIBUTES (fntype) };
+
+  for (int i = 0; i != 2; ++i)
     {
+      if (!attrs[i])
+	continue;
+
       fprintf (file, "__attribute__((");
 
       bool first = true;
       tree chain;
-      for (chain = DECL_ATTRIBUTES (fndecl); chain;
-	   first = false, chain = TREE_CHAIN (chain))
+      for (chain = attrs[i]; chain; first = false, chain = TREE_CHAIN (chain))
 	{
 	  if (!first)
 	    fprintf (file, ", ");
@@ -8026,7 +8031,11 @@ dump_function_to_file (tree fndecl, FILE *file, dump_flags_t flags)
 	}
     }
   else
-    fprintf (file, "%s %s(", function_name (fun), tmclone ? "[tm-clone] " : "");
+    {
+      print_generic_expr (file, TREE_TYPE (fntype), dump_flags);
+      fprintf (file, " %s %s(", function_name (fun),
+	       tmclone ? "[tm-clone] " : "");
+    }
 
   arg = DECL_ARGUMENTS (fndecl);
   while (arg)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] dump type attributes in dump_function_to_file
  2020-11-20 18:12 [PATCH] dump type attributes in dump_function_to_file Martin Sebor
@ 2020-11-20 23:14 ` Jeff Law
  2020-11-24  4:31   ` Jeff Law
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Law @ 2020-11-20 23:14 UTC (permalink / raw)
  To: Martin Sebor, gcc-patches



On 11/20/20 11:12 AM, Martin Sebor via Gcc-patches wrote:
> dump_function_to_file prints DECL_ATTRIBUTES but not TYPE_ATTRIBUTES
> when both can be important and helpful for debugging, especially with
> attributes that are added implicitly (such attribute access and
> the proposed internal attribute *dealloc).  The function also prints
> function arguments (and their types) but not its return type, again,
> leaving out a useful detail.  The attached tweak adds both to
> the dump.
>
> Martin
>
> gcc-dump-type-attr.diff
>
> gcc/ChangeLog:
>
> 	* gcc/tree-cfg.c (dump_function_to_file): Print type attributes
> 	and return type.
>
> gcc/testsuite/ChangeLog:
> 	* gcc.dg/attr-access-4.c: New test.
OK
jeff


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] dump type attributes in dump_function_to_file
  2020-11-20 23:14 ` Jeff Law
@ 2020-11-24  4:31   ` Jeff Law
  2020-11-24 15:53     ` Martin Sebor
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Law @ 2020-11-24  4:31 UTC (permalink / raw)
  To: Martin Sebor, gcc-patches



On 11/20/20 4:14 PM, Jeff Law wrote:
>
> On 11/20/20 11:12 AM, Martin Sebor via Gcc-patches wrote:
>> dump_function_to_file prints DECL_ATTRIBUTES but not TYPE_ATTRIBUTES
>> when both can be important and helpful for debugging, especially with
>> attributes that are added implicitly (such attribute access and
>> the proposed internal attribute *dealloc).  The function also prints
>> function arguments (and their types) but not its return type, again,
>> leaving out a useful detail.  The attached tweak adds both to
>> the dump.
>>
>> Martin
>>
>> gcc-dump-type-attr.diff
>>
>> gcc/ChangeLog:
>>
>> 	* gcc/tree-cfg.c (dump_function_to_file): Print type attributes
>> 	and return type.
>>
>> gcc/testsuite/ChangeLog:
>> 	* gcc.dg/attr-access-4.c: New test.
So was this actually regression tested?  Even tests that change dump
files need to be regression tested because some of the tests scan those
dump files.

I'm seeing this on several targets:

Tests that now fail, but worked before (6 tests):

xstormy16-sim: gcc.dg/tree-ssa/pr23401.c scan-tree-dump-times gimple "int" 5
xstormy16-sim: gcc.dg/tree-ssa/pr23401.c scan-tree-dump-times gimple "int" 5
xstormy16-sim: gcc.dg/tree-ssa/pr27810.c scan-tree-dump-times gimple "int" 3
xstormy16-sim: gcc.dg/tree-ssa/pr27810.c scan-tree-dump-times gimple "int" 3
xstormy16-sim: gcc.dg/tree-ssa/slsr-8.c scan-tree-dump-times optimized " w?\\* " 9
xstormy16-sim: gcc.dg/tree-ssa/slsr-8.c scan-tree-dump-times optimized " w?\\* " 9



From my quick reading, these tests are likely failing across the board.

jeff


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] dump type attributes in dump_function_to_file
  2020-11-24  4:31   ` Jeff Law
@ 2020-11-24 15:53     ` Martin Sebor
  2020-11-24 17:01       ` Martin Sebor
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Sebor @ 2020-11-24 15:53 UTC (permalink / raw)
  To: Jeff Law, gcc-patches

On 11/23/20 9:31 PM, Jeff Law wrote:
> 
> 
> On 11/20/20 4:14 PM, Jeff Law wrote:
>>
>> On 11/20/20 11:12 AM, Martin Sebor via Gcc-patches wrote:
>>> dump_function_to_file prints DECL_ATTRIBUTES but not TYPE_ATTRIBUTES
>>> when both can be important and helpful for debugging, especially with
>>> attributes that are added implicitly (such attribute access and
>>> the proposed internal attribute *dealloc).  The function also prints
>>> function arguments (and their types) but not its return type, again,
>>> leaving out a useful detail.  The attached tweak adds both to
>>> the dump.
>>>
>>> Martin
>>>
>>> gcc-dump-type-attr.diff
>>>
>>> gcc/ChangeLog:
>>>
>>> 	* gcc/tree-cfg.c (dump_function_to_file): Print type attributes
>>> 	and return type.
>>>
>>> gcc/testsuite/ChangeLog:
>>> 	* gcc.dg/attr-access-4.c: New test.
> So was this actually regression tested?  Even tests that change dump
> files need to be regression tested because some of the tests scan those
> dump files.
> 
> I'm seeing this on several targets:
> 
> Tests that now fail, but worked before (6 tests):
> 
> xstormy16-sim: gcc.dg/tree-ssa/pr23401.c scan-tree-dump-times gimple "int" 5
> xstormy16-sim: gcc.dg/tree-ssa/pr23401.c scan-tree-dump-times gimple "int" 5
> xstormy16-sim: gcc.dg/tree-ssa/pr27810.c scan-tree-dump-times gimple "int" 3
> xstormy16-sim: gcc.dg/tree-ssa/pr27810.c scan-tree-dump-times gimple "int" 3
> xstormy16-sim: gcc.dg/tree-ssa/slsr-8.c scan-tree-dump-times optimized " w?\\* " 9
> xstormy16-sim: gcc.dg/tree-ssa/slsr-8.c scan-tree-dump-times optimized " w?\\* " 9
> 
> 
> 
>  From my quick reading, these tests are likely failing across the board.

It was tested with the results below.  I looked onto the jit
failures (test-combination.c.exe etc.) but overlooked those
in the tree-ssa directory because of all the perpetual guality
clutter.

!  FAIL: gcc.dg/atomic/pr65345-4.c (4: +4)ESC[0m
!  FAIL: gcc.dg/guality/loop-1.c (1: +1)ESC[0m
!  FAIL: gcc.dg/guality/pr36728-2.c (28: +28)ESC[0m
!  FAIL: gcc.dg/guality/pr36728-4.c (4: +4)ESC[0m
!  FAIL: gcc.dg/guality/pr41616-1.c (3: +3)ESC[0m
!  FAIL: gcc.dg/guality/pr54519-1.c (8: +8)ESC[0m
!  FAIL: gcc.dg/guality/pr54519-2.c (2: +2)ESC[0m
!  FAIL: gcc.dg/guality/pr54519-3.c (8: +8)ESC[0m
!  FAIL: gcc.dg/guality/pr54519-4.c (2: +2)ESC[0m
!  FAIL: gcc.dg/guality/pr54519-5.c (2: +2)ESC[0m
!  FAIL: gcc.dg/guality/pr54519-6.c (1: +1)ESC[0m
!  FAIL: gcc.dg/guality/pr56154-1.c (1: +1)ESC[0m
!  FAIL: gcc.dg/guality/pr59776.c (6: +6)ESC[0m
!  FAIL: gcc.dg/guality/pr90074.c (2: +2)ESC[0m
!  FAIL: gcc.dg/guality/pr90716.c (1: +1)ESC[0m
!  FAIL: gcc.dg/guality/sra-1.c (16: +16)ESC[0m
!  FAIL: gcc.dg/guality/vla-1.c (8: +8)ESC[0m
!  FAIL: gcc.dg/tree-ssa/pr23401.c (1: +1)ESC[0m
!  FAIL: gcc.dg/tree-ssa/pr27810.c (1: +1)ESC[0m
!  FAIL: gcc.dg/tree-ssa/slsr-8.c (1: +1)ESC[0m
!  FAIL: gdc.dg/intrinsics.d (3: +3)ESC[0m
!  FAIL: g++.dg/guality/pr55665.C (1: +1)ESC[0m
!  FAIL: gfortran.dg/gomp/declare-target-4.f90 (8: +8)ESC[0m
!  FAIL: test-combination.c.exe (1: +1)ESC[0m
!  FAIL: test-functions.c.exe (1: +1)ESC[0m
!  FAIL: test-pr66779.c.exe (1: +1)ESC[0m
!  FAIL: test-threads.c.exe (1: +1)ESC[0m
! XPASS: gcc.dg/analyzer/pr94851-1.c (1: +1)ESC[0m
! XPASS: gcc.dg/guality/example.c (3: +3)ESC[0m
! XPASS: gcc.dg/guality/guality.c (8: +8)ESC[0m
! XPASS: gcc.dg/guality/inline-params.c (5: +5)ESC[0m
! XPASS: gcc.dg/guality/pr41353-1.c (2: +2)ESC[0m
! XPASS: gcc.dg/guality/pr54970.c (16: +16)ESC[0m
! XPASS: gcc.dg/guality/pr59776.c (2: +2)ESC[0m

> 
> jeff
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] dump type attributes in dump_function_to_file
  2020-11-24 15:53     ` Martin Sebor
@ 2020-11-24 17:01       ` Martin Sebor
  0 siblings, 0 replies; 5+ messages in thread
From: Martin Sebor @ 2020-11-24 17:01 UTC (permalink / raw)
  To: Jeff Law, gcc-patches

On 11/24/20 8:53 AM, Martin Sebor wrote:
> On 11/23/20 9:31 PM, Jeff Law wrote:
>>
>>
>> On 11/20/20 4:14 PM, Jeff Law wrote:
>>>
>>> On 11/20/20 11:12 AM, Martin Sebor via Gcc-patches wrote:
>>>> dump_function_to_file prints DECL_ATTRIBUTES but not TYPE_ATTRIBUTES
>>>> when both can be important and helpful for debugging, especially with
>>>> attributes that are added implicitly (such attribute access and
>>>> the proposed internal attribute *dealloc).  The function also prints
>>>> function arguments (and their types) but not its return type, again,
>>>> leaving out a useful detail.  The attached tweak adds both to
>>>> the dump.
>>>>
>>>> Martin
>>>>
>>>> gcc-dump-type-attr.diff
>>>>
>>>> gcc/ChangeLog:
>>>>
>>>>     * gcc/tree-cfg.c (dump_function_to_file): Print type attributes
>>>>     and return type.
>>>>
>>>> gcc/testsuite/ChangeLog:
>>>>     * gcc.dg/attr-access-4.c: New test.
>> So was this actually regression tested?  Even tests that change dump
>> files need to be regression tested because some of the tests scan those
>> dump files.
>>
>> I'm seeing this on several targets:
>>
>> Tests that now fail, but worked before (6 tests):
>>
>> xstormy16-sim: gcc.dg/tree-ssa/pr23401.c scan-tree-dump-times gimple 
>> "int" 5
>> xstormy16-sim: gcc.dg/tree-ssa/pr23401.c scan-tree-dump-times gimple 
>> "int" 5
>> xstormy16-sim: gcc.dg/tree-ssa/pr27810.c scan-tree-dump-times gimple 
>> "int" 3
>> xstormy16-sim: gcc.dg/tree-ssa/pr27810.c scan-tree-dump-times gimple 
>> "int" 3
>> xstormy16-sim: gcc.dg/tree-ssa/slsr-8.c scan-tree-dump-times optimized 
>> " w?\\* " 9
>> xstormy16-sim: gcc.dg/tree-ssa/slsr-8.c scan-tree-dump-times optimized 
>> " w?\\* " 9
>>
>>
>>
>>  From my quick reading, these tests are likely failing across the board.
> 
> It was tested with the results below.  I looked onto the jit
> failures (test-combination.c.exe etc.) but overlooked those
> in the tree-ssa directory because of all the perpetual guality
> clutter.

I committed r11-5321 to fix up the gfortran.dg/gomp/declare-target-4.f90
regex pattern.  Thank you for cleaning up the others.

> 
> !  FAIL: gcc.dg/atomic/pr65345-4.c (4: +4)ESC[0m
> !  FAIL: gcc.dg/guality/loop-1.c (1: +1)ESC[0m
> !  FAIL: gcc.dg/guality/pr36728-2.c (28: +28)ESC[0m
> !  FAIL: gcc.dg/guality/pr36728-4.c (4: +4)ESC[0m
> !  FAIL: gcc.dg/guality/pr41616-1.c (3: +3)ESC[0m
> !  FAIL: gcc.dg/guality/pr54519-1.c (8: +8)ESC[0m
> !  FAIL: gcc.dg/guality/pr54519-2.c (2: +2)ESC[0m
> !  FAIL: gcc.dg/guality/pr54519-3.c (8: +8)ESC[0m
> !  FAIL: gcc.dg/guality/pr54519-4.c (2: +2)ESC[0m
> !  FAIL: gcc.dg/guality/pr54519-5.c (2: +2)ESC[0m
> !  FAIL: gcc.dg/guality/pr54519-6.c (1: +1)ESC[0m
> !  FAIL: gcc.dg/guality/pr56154-1.c (1: +1)ESC[0m
> !  FAIL: gcc.dg/guality/pr59776.c (6: +6)ESC[0m
> !  FAIL: gcc.dg/guality/pr90074.c (2: +2)ESC[0m
> !  FAIL: gcc.dg/guality/pr90716.c (1: +1)ESC[0m
> !  FAIL: gcc.dg/guality/sra-1.c (16: +16)ESC[0m
> !  FAIL: gcc.dg/guality/vla-1.c (8: +8)ESC[0m
> !  FAIL: gcc.dg/tree-ssa/pr23401.c (1: +1)ESC[0m
> !  FAIL: gcc.dg/tree-ssa/pr27810.c (1: +1)ESC[0m
> !  FAIL: gcc.dg/tree-ssa/slsr-8.c (1: +1)ESC[0m
> !  FAIL: gdc.dg/intrinsics.d (3: +3)ESC[0m
> !  FAIL: g++.dg/guality/pr55665.C (1: +1)ESC[0m
> !  FAIL: gfortran.dg/gomp/declare-target-4.f90 (8: +8)ESC[0m
> !  FAIL: test-combination.c.exe (1: +1)ESC[0m
> !  FAIL: test-functions.c.exe (1: +1)ESC[0m
> !  FAIL: test-pr66779.c.exe (1: +1)ESC[0m
> !  FAIL: test-threads.c.exe (1: +1)ESC[0m
> ! XPASS: gcc.dg/analyzer/pr94851-1.c (1: +1)ESC[0m
> ! XPASS: gcc.dg/guality/example.c (3: +3)ESC[0m
> ! XPASS: gcc.dg/guality/guality.c (8: +8)ESC[0m
> ! XPASS: gcc.dg/guality/inline-params.c (5: +5)ESC[0m
> ! XPASS: gcc.dg/guality/pr41353-1.c (2: +2)ESC[0m
> ! XPASS: gcc.dg/guality/pr54970.c (16: +16)ESC[0m
> ! XPASS: gcc.dg/guality/pr59776.c (2: +2)ESC[0m
> 
>>
>> jeff
>>
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-24 17:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20 18:12 [PATCH] dump type attributes in dump_function_to_file Martin Sebor
2020-11-20 23:14 ` Jeff Law
2020-11-24  4:31   ` Jeff Law
2020-11-24 15:53     ` Martin Sebor
2020-11-24 17:01       ` Martin Sebor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).