public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom de Vries <Tom_deVries@mentor.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: "gcc-patches@gnu.org" <gcc-patches@gnu.org>
Subject: [PATCH, PR67709 ] Don't call call_cgraph_insertion_hooks in simd_clone_create
Date: Mon, 08 Feb 2016 12:47:00 -0000	[thread overview]
Message-ID: <56B88E34.2050400@mentor.com> (raw)

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

Hi,

Consider libgomp.fortran/declare-simd-3.f90:
...
subroutine bar
   use declare_simd_2_mod
   real :: b(128)
   integer :: i

   !$omp simd
   do i = 1, 128
     b(i) = i * 2.0
   end do
   !$omp simd
   do i = 1, 128
     b(i) = foo (7.0_8, 5 * i, b(i))
   end do
   do i = 1, 128
     if (b(i).ne.(7.0 + 10.0 * i * i)) call abort
   end do
end subroutine bar
...

when compiling declare-simd-3.f90 with '-O0 -fopenmp -flto 
-fno-use-linker-plugin', we run into an ICE with backtrace:
...
ICE backtrace:
...
src/libgomp/testsuite/libgomp.fortran/declare-simd-3.f90: At top level:
src/libgomp/testsuite/libgomp.fortran/declare-simd-3.f90:7:0: internal 
compiler error: in estimate_function_body_sizes, at 
ipa-inline-analysis.c:2486
    use declare_simd_2_mod

0xc9319d estimate_function_body_sizes
	src/gcc/ipa-inline-analysis.c:2486
0xc950dd compute_inline_parameters(cgraph_node*, bool)
	src/gcc/ipa-inline-analysis.c:2953
0xc9813b inline_analyze_function(cgraph_node*)
	src/gcc/ipa-inline-analysis.c:4078
0xc98205 inline_summary_t::insert(cgraph_node*, inline_summary*)
	src/gcc/ipa-inline-analysis.c:4105
0x9a6213 symbol_table::call_cgraph_insertion_hooks(cgraph_node*)
	src/gcc/cgraph.c:371
0xdefa0e simd_clone_create
	src/gcc/omp-low.c:18738
0xdf5012 expand_simd_clones
	src/gcc/omp-low.c:19799
0xdf519b ipa_omp_simd_clone
	src/gcc/omp-low.c:19839
0xdf520a execute
	src/gcc/omp-low.c:19867
Please submit a full bug report,
...

During pass_omp_simd_clone, we call simd_clone_create for foo, and 
execute the  !old_node->definition part:
...
       tree old_decl = old_node->decl;
       tree new_decl = copy_node (old_node->decl);
       DECL_NAME (new_decl)
         = clone_function_name (old_decl, "simdclone");
       SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl));
       SET_DECL_RTL (new_decl, NULL);
       DECL_STATIC_CONSTRUCTOR (new_decl) = 0;
       DECL_STATIC_DESTRUCTOR (new_decl) = 0;
       new_node = old_node->create_version_clone (new_decl, vNULL, NULL);
       if (old_node->in_other_partition)
         new_node->in_other_partition = 1;
       symtab->call_cgraph_insertion_hooks (new_node);
...

The 'symtab->call_cgraph_insertion_hooks (new_node)' calls 
'inline_summary_t::insert', a hook inserted during pass_ipa_inline.

During execution of the hook we stumble over the fact that the new node 
has no 'struct function' in estimate_function_body_sizes:
...
   struct function *my_function = DECL_STRUCT_FUNCTION (node->decl);
   ...
   gcc_assert (my_function && my_function->cfg);
...

The patch fixes the ICE by removing the call to 
'symtab->call_cgraph_insertion_hooks'.

[ The pass before pass_omp_simd_clone is pass_dispatcher_calls. It has a 
function create_target_clone, similar to simd_clone_create, with a 
node.defition and !node.defition part. The !node.defition part does not 
call 'symtab->call_cgraph_insertion_hooks (new_node)'. ]

Bootstrapped and reg-tested on x86_64.

OK for stage1 trunk?

Thanks,
- Tom

[-- Attachment #2: 0004-Don-t-call-call_cgraph_insertion_hooks-in-simd_clone_create.patch --]
[-- Type: text/x-patch, Size: 1472 bytes --]

Don't call call_cgraph_insertion_hooks in simd_clone_create

2016-02-08  Tom de Vries  <tom@codesourcery.com>

	PR lto/67709
	* omp-low.c (simd_clone_create): Remove call to
	symtab->call_cgraph_insertion_hooks.

	* testsuite/libgomp.fortran/declare-simd-4.f90: New test.

---
 gcc/omp-low.c                                        | 1 -
 libgomp/testsuite/libgomp.fortran/declare-simd-4.f90 | 7 +++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index d41688b..fcbb3e0 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -18735,7 +18735,6 @@ simd_clone_create (struct cgraph_node *old_node)
       new_node = old_node->create_version_clone (new_decl, vNULL, NULL);
       if (old_node->in_other_partition)
 	new_node->in_other_partition = 1;
-      symtab->call_cgraph_insertion_hooks (new_node);
     }
   if (new_node == NULL)
     return new_node;
diff --git a/libgomp/testsuite/libgomp.fortran/declare-simd-4.f90 b/libgomp/testsuite/libgomp.fortran/declare-simd-4.f90
new file mode 100644
index 0000000..bfdf9cf
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/declare-simd-4.f90
@@ -0,0 +1,7 @@
+! { dg-do run { target { vect_simd_clones && lto } } }
+! { dg-options "-fno-inline -flto -fno-use-linker-plugin" }
+! { dg-additional-sources declare-simd-3.f90 }
+! { dg-additional-options "-msse2" { target sse2_runtime } }
+! { dg-additional-options "-mavx" { target avx_runtime } }
+
+include 'declare-simd-2.f90'

             reply	other threads:[~2016-02-08 12:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-08 12:47 Tom de Vries [this message]
2016-02-08 12:55 ` Jakub Jelinek
2016-02-15  9:38   ` [PING][PATCH, " Tom de Vries
2016-02-16  2:22     ` Jan Hubicka
2016-02-16  9:57       ` Tom de Vries
2016-02-16 10:04         ` Jakub Jelinek
2016-02-16 11:10           ` Tom de Vries
2016-02-16 11:12             ` Jakub Jelinek
2016-02-16 16:53               ` Tom de Vries
2016-02-16 16:55                 ` Jakub Jelinek
2016-02-16 20:52                   ` Tom de Vries
2016-02-10 16:55 [PATCH, " Dominique d'Humières
2016-02-10 17:14 ` Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56B88E34.2050400@mentor.com \
    --to=tom_devries@mentor.com \
    --cc=gcc-patches@gnu.org \
    --cc=jakub@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).