Bug 35364

Summary: ICE on ia64 with vector declaration inside #pragma omp parallel
Product: gcc Reporter: Sebastian Steiger <steigers>
Component: targetAssignee: Jakub Jelinek <jakub>
Severity: normal CC: gcc-bugs, pinskia
Priority: P3 Keywords: openmp
Version: 4.3.0   
Target Milestone: 4.4.0   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2008-04-04 14:38:51
Attachments: Preprocessed file (.ii)
tree-eh.c optimize_double_finally patch

Description Sebastian Steiger 2008-02-25 10:35:06 UTC
The following code fails to compile on ia64 platform with standard options. The problem is gone when:
- removing the #pragma or 
- declaring a double instead of a vector or 
- not explicitly assigning a length to the vector
- inlining foo()

Problematic code:
#include <vector>
#include <omp.h>

class A  {		
	void foo();					

void A::foo() {
	#pragma omp parallel 
		std::vector<double> x(0);

Steps to reproduce
Compile using 
g++ -Wall -fopenmp -save-temps -o ice.o -c ice.h

Build Date & Platform
Linux 2.4.21-27.0.4.EL #1 SMP ia64 GNU/Linux

GCC version: SVN revision 131821 (2008-01-25) (I don't know about earlier or later versions)

GCC was configured with
Configured with: ../gcc/configure --prefix=(...) --enable-languages=c++,fortran --with-gmp=(...) --with-mpfr=(...) CC=gcc CXX=g++

The bug does not show up on amd64 using the same revision.
Comment 1 Sebastian Steiger 2008-02-25 10:35:59 UTC
Created attachment 15221 [details]
Preprocessed file (.ii)
Comment 2 Andrew Pinski 2008-02-25 18:16:02 UTC
What is the ICE?
Comment 3 Sebastian Steiger 2008-02-25 18:20:16 UTC
(In reply to comment #2)
> What is the ICE?
Segmentation fault.

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 84cf8bc685ded1e544606791a260313c
ice.h: In member function 'void A::foo()':
ice.h:11: internal compiler error: Segmentation fault
Comment 4 Jim Wilson 2008-04-01 06:26:14 UTC
Subject: Re:   New: ICE on ia64 with vector declaration
 inside #pragma omp parallel

steigers at phys dot ethz dot ch wrote:
> g++ -Wall -fopenmp -save-temps -o ice.o -c ice.h

I can reproduce this.

It dies in the eh pass.  We have a TRY_CATCH_EXPR with an empty catch 
clause.  This fails in lower_eh_constructs_1 case TRY_CATCH_EXPR, as 
i->ptr is null, and hence tsi_stmt segfaults.

It seems wrong to have an empty catch clause here.  This was created 
during the ehopt pass by optimize_double_finally.  We have
     try { A() } finally { try { } catch { ~A() } }
     try { ... } finally { ~A() }
which is converted into
     try { A() } catch { }
     try { ~B() ... } finally { ~A() }
thus giving us the problematic empty catch clause.

The testcase doesn't fail on x86 as we end up with slightly different 
gimple. In the 004t.gimple dump file, for x86 we have
           struct vector x;
           __comp_ctor  (&D.7263);
               D.7261 = 0.0;
and for IA-64 we have
           struct vector x;
           D.7300 = 0.0;
               __comp_ctor  (&D.7302);
The different placement of the ctor means the dtor ends up in different 
places, and hence the bug triggers on IA-64 but not x86.  I don't know 
why we are getting the different gimplification here.  This seems odd, 
but I haven't tried looking into this yet.

Comment 5 Jim Wilson 2008-04-01 06:31:23 UTC
Created attachment 15401 [details]
tree-eh.c optimize_double_finally patch

This patch works for the testcase, but is otherwise untested.  My knowledge in this area is limited, so this needs to be reviewed by someone with more tree-ssa and tree-eh knowledge than me.
Comment 6 Jakub Jelinek 2008-04-04 14:38:51 UTC
optimize_double_finally relies here on the useless pass doing its job.
But on the trunk/4.3 the useless pass doesn't dive into OpenMP constructs.
This is fixed on the gomp-3_0-branch, see the remove_useless_stmts_1 hunk
in http://gcc.gnu.org/ml/gcc-patches/2008-02/msg00261.html
At that point I didn't know of any testcase that would be affected on the trunk/4.3 too, so I've committed that just to gomp-3_0-branch, but will backport it now to the trunk/4.3.
Comment 7 Jakub Jelinek 2008-04-04 17:49:40 UTC
Subject: Bug 35364

Author: jakub
Date: Fri Apr  4 17:48:45 2008
New Revision: 133905

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133905
	PR target/35364
	* tree-cfg.c (remove_useless_stmts_1): Handle OMP_* containers.

	* g++.dg/gomp/pr35364.C: New test.


Comment 8 Jakub Jelinek 2008-04-04 18:01:21 UTC
Subject: Bug 35364

Author: jakub
Date: Fri Apr  4 18:00:25 2008
New Revision: 133906

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133906
	PR target/35364
	* tree-cfg.c (remove_useless_stmts_1): Handle OMP_* containers.

	* g++.dg/gomp/pr35364.C: New test.


Comment 9 Jakub Jelinek 2008-04-04 18:01:58 UTC