Bug 37394 - [4.4 Regression] Segfault in ia64_variable_issue with -O -fschedule-insns2
Summary: [4.4 Regression] Segfault in ia64_variable_issue with -O -fschedule-insns2
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.4.0
: P2 normal
Target Milestone: 4.4.0
Assignee: Not yet assigned to anyone
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-valid-code
Depends on: 37565
Blocks:
  Show dependency treegraph
 
Reported: 2008-09-06 08:55 UTC by Martin Michlmayr
Modified: 2008-09-18 20:35 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-09-14 05:02:20


Attachments
Preprocessed code (60.35 KB, application/octet-stream)
2008-09-06 08:58 UTC, Martin Michlmayr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Michlmayr 2008-09-06 08:55:15 UTC
With -O -fschedule-insns2 on current trunk (r140054):

(sid)tbm@coconut0:~$ /usr/lib/gcc-snapshot/bin/gcc -O -fschedule-insns2  pfstmo_drago03.ii
In file included from /usr/include/pfs-1.2/pfs.h:46,
                 from pfstmo_drago03.cpp:41:
/usr/include/pfs-1.2/array2d.h: In destructor 'virtual pfs::Array2D::~Array2D()':
/usr/include/pfs-1.2/array2d.h:141: internal compiler error: Segmentation fault
Please submit a full bug report,
Comment 1 Martin Michlmayr 2008-09-06 08:55:52 UTC
Program received signal SIGSEGV, Segmentation fault.
0x4000000000cf1810 in ia64_variable_issue (dump=0x20000000003eb488, sched_verbose=0, insn=0x2000000002080550,
    can_issue_more=15540576) at gcc/config/ia64/ia64.c:6645
6645          stops_p [INSN_UID (insn)] = stop_before_p;
(gdb) where
#0  0x4000000000cf1810 in ia64_variable_issue (dump=0x20000000003eb488, sched_verbose=0, insn=0x2000000002080550,
    can_issue_more=15540576) at gcc/config/ia64/ia64.c:6645
#1  0x4000000000ed2160 in schedule_block (target_bb=0x60000ffffe7d36a0) at gcc/haifa-sched.c:2673
#2  0x4000000000875880 in schedule_insns () at gcc/sched-rgn.c:2933
#3  0x4000000000875f70 in rest_of_handle_sched2 () at gcc/sched-rgn.c:3474
#4  0x400000000078d4d0 in execute_one_pass (pass=0x600000000007b670) at gcc/passes.c:1278
#5  0x400000000078db70 in execute_pass_list (pass=0x600000000007b670) at gcc/passes.c:1326
#6  0x400000000078dbc0 in execute_pass_list (pass=0x6000000000079dc0) at gcc/passes.c:1327
#7  0x400000000078dbc0 in execute_pass_list (pass=0x6000000000079d70) at gcc/passes.c:1327
#8  0x40000000009e1800 in tree_rest_of_compilation (fndecl=0x2000000001a24f00)
    at gcc/tree-optimize.c:418
#9  0x4000000000d02160 in cgraph_expand_function (node=0x2000000001ab5100) at gcc/cgraphunit.c:1038
#10 0x4000000000d07070 in cgraph_optimize () at gcc/cgraphunit.c:1097
#11 0x4000000000160130 in cp_write_global_declarations () at gcc/cp/decl2.c:3608
#12 0x4000000000924f70 in toplev_main (argc=<value optimized out>, argv=<value optimized out>)
    at gcc/toplev.c:979
#13 0x4000000000390d30 in main (argc=5, argv=0x60000ffffe7d39c8) at gcc/main.c:35
(gdb)
Comment 2 Martin Michlmayr 2008-09-06 08:58:46 UTC
Created attachment 16243 [details]
Preprocessed code
Comment 3 Martin Michlmayr 2008-09-06 08:59:07 UTC
/* Testcase by Martin Michlmayr <tbm@cyrius.com> */

struct _Words
{
  void *_M_pword;
  _Words ():
   _M_pword (0)
  {
  }
} _M_word_zero;
Comment 4 H.J. Lu 2008-09-06 17:07:32 UTC
The problem is IA64 has

void
ia64_optimization_options (int level ATTRIBUTE_UNUSED,
                           int size ATTRIBUTE_UNUSED)
{
  /* Disable the second machine independent scheduling pass and use one for the
     IA-64.  This needs to be here instead of in OVERRIDE_OPTIONS because this
     is done whenever the optimization is changed via #pragma GCC optimize or
     attribute((optimize(...))).  */
  ia64_flag_schedule_insns2 = flag_schedule_insns_after_reload;
  flag_schedule_insns_after_reload = 0;

We didn't handle "-O -fschedule-insns2" properly when after function
specific change. Michael, can you take a look at it?  Thanks.
Comment 5 H.J. Lu 2008-09-07 20:11:12 UTC
--- gcc/opts.c.over	2008-09-07 12:50:39.000000000 -0700
+++ gcc/opts.c	2008-09-07 12:47:04.000000000 -0700
@@ -1001,13 +1001,13 @@ decode_options (unsigned int argc, const
       flag_unwind_tables = targetm.unwind_tables_default;
     }
 
+  handle_options (argc, argv, lang_mask);
+
 #ifdef OPTIMIZATION_OPTIONS
   /* Allow default optimizations to be specified on a per-machine basis.  */
   OPTIMIZATION_OPTIONS (optimize, optimize_size);
 #endif
 
-  handle_options (argc, argv, lang_mask);
-
   /* Handle related options for unit-at-a-time, toplevel-reorder, and
      section-anchors.  */
   if (!flag_unit_at_a_time)

Michael, this patch allows ia64_optimization_options to override
-fschedule-insns2. But I am not sure if it is a proper fix.
Comment 6 H.J. Lu 2008-09-08 00:04:41 UTC
We have OPTIMIZATION_OPTIONS which is executed once just after
the optimization level is determined and before the remainder
of the command options have been parsed. This macro is run once
at program startup and when the optimization options are changed
via "pragma GCC optimize" or by using the "optimize" attribute.

We have OVERRIDE_OPTIONS which is executed once just after all
the command options have been parsed.

They don't cover this case as well as the case in

http://gcc.gnu.org/ml/gcc-patches/2008-08/msg00524.html
Comment 7 Andrew Pinski 2008-09-14 05:02:20 UTC
Should have been confirmed already.
Comment 8 H.J. Lu 2008-09-17 18:06:01 UTC
It may also impact PR 37283.
Comment 9 H.J. Lu 2008-09-18 14:14:11 UTC
A patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2008-09/msg01275.html
Comment 10 hjl@gcc.gnu.org 2008-09-18 20:28:53 UTC
Subject: Bug 37394

Author: hjl
Date: Thu Sep 18 20:27:36 2008
New Revision: 140475

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=140475
Log:
gcc/

2008-09-18  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/37394
	* config/ia64/ia64.c (ia64_optimization_options): Move
	checking and setting flag_schedule_insns_after_reload and
	ia64_flag_schedule_insns2 back to ...
	(ia64_override_options): Here.

gcc/testsuite/

2008-09-18  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/37394
	* g++.dg/other/pr37394.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/other/pr37394.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/ia64/ia64.c
    trunk/gcc/testsuite/ChangeLog

Comment 11 H.J. Lu 2008-09-18 20:35:31 UTC
Fixed.