Bug 56694 - [4.8/4.9 Regression] Internal compiler error when compiling OpenMP code
Summary: [4.8/4.9 Regression] Internal compiler error when compiling OpenMP code
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.8.1
Assignee: Richard Biener
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-23 09:01 UTC by Jürgen Knödlseder
Modified: 2013-03-25 14:54 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.8.0
Last reconfirmed: 2013-03-23 00:00:00


Attachments
GObservations_optimizer.ii (91.57 KB, application/octet-stream)
2013-03-23 12:24 UTC, Jürgen Knödlseder
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jürgen Knödlseder 2013-03-23 09:01:03 UTC
While compiling my GammaLib suite with the new gcc 4.8.0 an internal compiler error occurred in a routine that uses OpenMP for multi-threading. The following message occurs:

GObservations_optimizer.cpp: In member function 'virtual void GObservations::optimizer::eval(const GOptimizerPars&)':
GObservations_optimizer.cpp:431:1: internal compiler error: in change_scope, at final.c:1575
 }
 ^
0x8340bb8 change_scope
	../../gcc-4.8.0/gcc/final.c:1575
0x8344526 reemit_insn_block_notes
	../../gcc-4.8.0/gcc/final.c:1650
0x8344526 final_start_function(rtx_def*, _IO_FILE*, int)
	../../gcc-4.8.0/gcc/final.c:1743
0x8345b9a rest_of_handle_final
	../../gcc-4.8.0/gcc/final.c:4341
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../.. -I../../include -I../../src -I../../src/support -I/home/jenkins/cfitsio/cfitsio3310/include -I/home/jenkins/readline/readline62/include -I/home/jenkins/python/python273/include/python2.7 -g -O2 -fopenmp -c GObservation.cpp -o GObservation.o >/dev/null 2>&1
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

I created a branch on GitHub to download the relevant code:
https://github.com/gammalib/gammalib/tree/gcc480-compile-error
Comment 1 Marek Polacek 2013-03-23 09:19:11 UTC
Please provide a preprocessed source.
Comment 2 Jürgen Knödlseder 2013-03-23 10:22:28 UTC
What do you mean by preprocessed source ???

Le 23 mars 2013 à 10:19, mpolacek at gcc dot gnu.org a écrit :

> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56694
> 
> Marek Polacek <mpolacek at gcc dot gnu.org> changed:
> 
>           What    |Removed                     |Added
> ----------------------------------------------------------------------------
>             Status|UNCONFIRMED                 |WAITING
>   Last reconfirmed|                            |2013-03-23
>                 CC|                            |mpolacek at gcc dot gnu.org
>     Ever Confirmed|0                           |1
> 
> --- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> 2013-03-23 09:19:11 UTC ---
> Please provide a preprocessed source.
> 
> -- 
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You reported the bug.

============================
Please note my new e-mail address:
Jurgen.Knodlseder@irap.omp.eu
============================
Comment 3 Andrew Pinski 2013-03-23 10:28:57 UTC
Created attachment 29710 [details]
GObservations_optimizer.ii

Add -save-temps to the command line and attach the resulting *.ii file.
This is all mentioned in http://gcc.gnu.org/bugs/ .
Comment 4 Jürgen Knödlseder 2013-03-23 12:24:18 UTC
Okay, here it comes. But believe me or not: with the -save-temps option the code compiles through!

I rechecked by removing the option, and the code fails again. Putting it back makes it work ... so this is a repeatable experiment.

Cheers,
Jürgen
Comment 5 Richard Biener 2013-03-25 10:25:58 UTC
Confirmed.

> /abuild/rguenther/gcc48-g/gcc/cc1plus  -quiet t.ii -fopenmp -m32 -O2
GObservations_optimizer.cpp: In member function 'virtual void GObservations::optimizer::eval(const GOptimizerPars&)':
GObservations_optimizer.cpp:188:6: error: location references block not in block tree
# VUSE <.MEM_295>
std::terminate ();

GObservations_optimizer.cpp:188:6: internal compiler error: verify_gimple failed
0xc92abe verify_gimple_in_cfg(function*)
        /space/rguenther/src/svn/gcc-4_8-branch/gcc/tree-cfg.c:4738
0xb768c1 execute_function_todo
        /space/rguenther/src/svn/gcc-4_8-branch/gcc/passes.c:1963
0xb75c19 do_per_function
        /space/rguenther/src/svn/gcc-4_8-branch/gcc/passes.c:1701
0xb769e5 execute_todo
        /space/rguenther/src/svn/gcc-4_8-branch/gcc/passes.c:1996
Please submit a full bug report,

I will take a look.
Comment 6 Richard Biener 2013-03-25 12:28:55 UTC
Reduced testcase:

class GException {
public:
    class vector_mismatch {
    public:
        vector_mismatch(int size1, int size2);
    };
};
class GVector{
public:
    GVector& operator+=(const GVector& v);
    int m_num;
    double* m_data;
};
inline GVector& GVector::operator+= (const GVector& v)
{
  if (m_num != v.m_num)
    throw GException::vector_mismatch(m_num, v.m_num);
  for (int i = 0; i < m_num; ++i)  m_data[i] += v.m_data[i];
};
void eval(GVector* m_gradient, GVector* vect_cpy_grad, int n)
{
#pragma omp sections
    {
      for (int i = 0; i < n; ++i)
        *m_gradient += vect_cpy_grad[i];
    }
}
Comment 7 Richard Biener 2013-03-25 12:49:34 UTC
It's the lower RESX pass that causes the location to appear.  And likely
bogus locations in the EH on-the-side info:

              x = gimple_build_call (fn, 0);
              gimple_set_location (x, dst_r->u.must_not_throw.failure_loc);

thus, the must_not_throw failure_loc either shouldn't have a BLOCK associated
or it needs re-mapping during inlining / cloning.

Using LOCATION_LOCUS above fixes the ICE.
Comment 8 Richard Biener 2013-03-25 14:54:26 UTC
Author: rguenth
Date: Mon Mar 25 14:46:08 2013
New Revision: 197047

URL: http://gcc.gnu.org/viewcvs?rev=197047&root=gcc&view=rev
Log:
2013-03-25  Richard Biener  <rguenther@suse.de>

	PR middle-end/56694
	* tree-eh.c (lower_eh_must_not_throw): Strip BLOCKs from the
	must-not-throw stmt location.

	* g++.dg/torture/pr56694.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/torture/pr56694.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-eh.c

Author: rguenth
Date: Mon Mar 25 14:47:56 2013
New Revision: 197048

URL: http://gcc.gnu.org/viewcvs?rev=197048&root=gcc&view=rev
Log:
2013-03-25  Richard Biener  <rguenther@suse.de>

	PR middle-end/56694
	* tree-eh.c (lower_eh_must_not_throw): Strip BLOCKs from the
	must-not-throw stmt location.

	* g++.dg/torture/pr56694.C: New testcase.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/torture/pr56694.C
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_8-branch/gcc/tree-eh.c