diff mbox

[PR59627,c++] Handle DECL_OMP_DECLARE_REDUCTION in discriminator_for_local_entity

Message ID 56B86C09.5030903@mentor.com
State New
Headers show

Commit Message

Tom de Vries Feb. 8, 2016, 10:20 a.m. UTC
Hi,

When running libgomp testsuite with -flto, we run into an ICE in the 
udr-*.C tests.

A minimal testcase is in listed in PR59627:
...
struct A { int i; };

void foo()
{
   A a;
   #pragma omp declare reduction (+: A: omp_out.i += omp_in.i)
   #pragma omp parallel reduction (+: a)
   ;
}
...

The ICE with backtrace looks as follows:
...
src/libgomp/testsuite/libgomp.c++/udr-1.C:56:13: internal compiler 
error: in discriminator_for_local_entity, at cp/mangle.c:1762
0x9ad52a discriminator_for_local_entity
         src/gcc/cp/mangle.c:1762
0x9ad8a5 write_local_name
         src/gcc/cp/mangle.c:1850
0x9a7975 write_name
         src/gcc/cp/mangle.c:882
0x9a71c0 write_encoding
         src/gcc/cp/mangle.c:744
0x9a6c61 write_mangled_name
         src/gcc/cp/mangle.c:709
0x9b6d09 mangle_decl_string
         src/gcc/cp/mangle.c:3509
0x9b6d4f get_mangled_id
         src/gcc/cp/mangle.c:3531
0x9b71d7 mangle_decl(tree_node*)
         src/gcc/cp/mangle.c:3598
0x14da287 decl_assembler_name(tree_node*)
         src/gcc/tree.c:670
0x14edf74 assign_assembler_name_if_neeeded(tree_node*)
         src/gcc/tree.c:5917
0x14ee0cc free_lang_data_in_cgraph
         src/gcc/tree.c:5972
0x14ee280 free_lang_data
         src/gcc/tree.c:6014
0x14ee320 execute
         src/gcc/tree.c:6063
Please submit a full bug report
...

The problem seems to be that we're trying to get a discriminator (the 
lexical ordinal of a var among entities with the same name in the same 
function) for a DECL_OMP_DECLARE_REDUCTION_P function, which is not 
handled in discriminator_for_local_entity.

For the test-case above the declared reduction is shown as:
...
   void omp declare reduction operator+~1A (struct A &);
...

AFAIU, those DECL_OMP_DECLARE_REDUCTION_P decls are unique in a 
function, so I'd say we can simply return '0'.

Bootstrapped and reg-tested on x86_64.

OK for trunk, stage1?

Thanks,
- Tom
diff mbox

Patch

Handle DECL_OMP_DECLARE_REDUCTION in discriminator_for_local_entity

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

	PR c++/59627
	* mangle.c (discriminator_for_local_entity): Handle
	DECL_OMP_DECLARE_REDUCTION_P function.

	* testsuite/libgomp.c++/udr-20.C: New test.

---
 gcc/cp/mangle.c                        | 3 +++
 libgomp/testsuite/libgomp.c++/udr-20.C | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 410c7f4..e83fc0c 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -1758,6 +1758,9 @@  discriminator_for_local_entity (tree entity)
 
       return local_class_index (entity);
     }
+  else if (TREE_CODE (entity) == FUNCTION_DECL
+	   && DECL_OMP_DECLARE_REDUCTION_P (entity))
+    return 0;
   else
     gcc_unreachable ();
 }
diff --git a/libgomp/testsuite/libgomp.c++/udr-20.C b/libgomp/testsuite/libgomp.c++/udr-20.C
new file mode 100644
index 0000000..2aaf618
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/udr-20.C
@@ -0,0 +1,4 @@ 
+// { dg-do run { target lto } }
+// { dg-additional-options "-flto" }
+
+#include "udr-1.C"