Bug 35185 - ICE using openmp with g++-4.2
Summary: ICE using openmp with g++-4.2
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.3.1
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code, openmp
: 35247 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-02-13 18:28 UTC by Eduardo Gurgel Pinho
Modified: 2008-03-13 09:59 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.3.1 4.4.0
Known to fail: 4.2.3 4.3.0
Last reconfirmed: 2008-03-12 21:23:57


Attachments
source (908 bytes, text/x-c++src)
2008-02-13 18:30 UTC, Eduardo Gurgel Pinho
Details
header (354 bytes, text/x-c++hdr)
2008-02-13 18:30 UTC, Eduardo Gurgel Pinho
Details
.i (124.45 KB, application/octet-stream)
2008-02-13 18:31 UTC, Eduardo Gurgel Pinho
Details
gcc44-pr35185.patch (2.12 KB, patch)
2008-03-12 17:49 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eduardo Gurgel Pinho 2008-02-13 18:28:17 UTC
System: Ubuntu 7.10
gcc version: 4.2.0

Problem: Using openmp extension

erro interno de compilação: in create_tmp_var, at gimplify.c:487
Comment 1 Eduardo Gurgel Pinho 2008-02-13 18:30:05 UTC
Created attachment 15142 [details]
source
Comment 2 Eduardo Gurgel Pinho 2008-02-13 18:30:54 UTC
Created attachment 15143 [details]
header
Comment 3 Eduardo Gurgel Pinho 2008-02-13 18:31:40 UTC
Created attachment 15144 [details]
.i
Comment 4 Eduardo Gurgel Pinho 2008-02-13 18:33:26 UTC
G++ gives

raycaster.cpp: In member function ‘void Raycaster::cast() const’:
raycaster.cpp:43: erro interno de compilação: in create_tmp_var, at gimplify.c:487
Por favor, envie um relato completo de erro,
com o código pré-processado se possível.
Veja <URL:http://gcc.gnu.org/bugs.html> para instruções.
For Debian GNU/Linux specific bug reporting instructions,
see <URL:file:///usr/share/doc/gcc-4.2/README.Bugs>.
make: ** [raycaster.o] Erro 1

trying to compile raycaster.cpp with g++-4.2 -c -O3 -pipe -mmmx -m3dnow -msse2 -msse  -fopenmp -save-temps raycaster.cpp -o raycaster.o

on ubuntu 7.10
Comment 5 Jakub Jelinek 2008-02-15 18:58:42 UTC
Simplified testcase:
struct S
{
  S ();
  ~S ();
  int s;
};

void bar (S);

void
foo ()
{
  S s;
#pragma omp parallel shared (s)
  bar (s);
}

Works if s is firstprivate or private, or if it doesn't have user defined destructor.
Comment 6 Jakub Jelinek 2008-02-15 21:07:12 UTC
The problem is the regimplifying done by lower_omp_1.
We have
D.NNNN = s;
where both of the vars have RECORD_TYPE with TREE_ADDRESSABLE types.
lower_omp_1 sees on the right hand side VAR_DECL with DECL_VALUE_EXPR (wi->is_lhs = false, wi->val_only = true), which is replaced with
*.omp_data_i->s which doesn't satisfy is_gimple_val predicate lower_regimplify
uses and of course the compiler isn't allowed to create temporaries of
TREE_ADDRESSABLE types on its own.  In this case I believe we need to force
the .omp_data_i->s address into a temporary first and then *temp should
hopefully satisfy the predicate.  Diego, any ideas?
Comment 7 Richard Biener 2008-02-18 09:41:37 UTC
*** Bug 35247 has been marked as a duplicate of this bug. ***
Comment 8 Jakub Jelinek 2008-03-12 17:49:48 UTC
Created attachment 15305 [details]
gcc44-pr35185.patch

WIP patch I'm playing with.  It just looks for statements that reference
variables with DECL_HAS_VALUE_EXPR_P and regimplifies them as whole, rather than
only regimplifying parts of them.
I still get 4 libgomp regressions:
FAIL: libgomp.c/nestedfn-4.c execution test
FAIL: libgomp.c/pr33880.c execution test
FAIL: libgomp.c/pr35130.c execution test
FAIL: libgomp.fortran/pr35130.f90  -O  execution test
and most likely further work will be needed for -ftree-parallelize-loops
where lower_omp is called on SSA.
Comment 9 Jakub Jelinek 2008-03-13 09:27:14 UTC
Subject: Bug 35185

Author: jakub
Date: Thu Mar 13 09:26:25 2008
New Revision: 133162

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133162
Log:
	PR middle-end/35185
	* omp-low.c (lower_regimplify, init_tmp_var, save_tmp_var): Removed.
	(lower_omp_2): New function.
	(lower_omp_1, lower_omp): Rewritten.

	* testsuite/libgomp.c++/pr35185.C: New test.

Added:
    trunk/libgomp/testsuite/libgomp.c++/pr35185.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/omp-low.c
    trunk/libgomp/ChangeLog

Comment 10 Jakub Jelinek 2008-03-13 09:58:23 UTC
Subject: Bug 35185

Author: jakub
Date: Thu Mar 13 09:57:34 2008
New Revision: 133165

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133165
Log:
	PR middle-end/35185
	* omp-low.c (lower_regimplify, init_tmp_var, save_tmp_var): Removed.
	(lower_omp_2): New function.
	(lower_omp_1, lower_omp): Rewritten.

	* testsuite/libgomp.c++/pr35185.C: New test.

Added:
    branches/gcc-4_3-branch/libgomp/testsuite/libgomp.c++/pr35185.C
      - copied unchanged from r133162, trunk/libgomp/testsuite/libgomp.c++/pr35185.C
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/omp-low.c
    branches/gcc-4_3-branch/libgomp/ChangeLog

Comment 11 Jakub Jelinek 2008-03-13 09:59:00 UTC
Fixed for 4.3.1 and later.