Bug 11320 - [3.3 regression] Scheduler bug
Summary: [3.3 regression] Scheduler bug
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3.1
: P2 critical
Target Milestone: 3.3.1
Assignee: Eric Botcazou
URL:
Keywords: wrong-code
: 11399 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-06-25 14:30 UTC by Andreas Schwab
Modified: 2011-07-15 13:20 UTC (History)
3 users (show)

See Also:
Host: ia64-suse-linux
Target: ia64-suse-linux
Build: ia64-suse-linux
Known to work:
Known to fail:
Last reconfirmed: 2003-07-06 11:25:21


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schwab 2003-06-25 14:30:23 UTC
Register r14 is used for two different values at the same time. 
 
$ cat http_core.c 
int strcmp (const char *, const char *); 
int printf (const char *, ...); 
int ap_standalone; 
const char * 
ap_check_cmd_context (void *a, int b) 
{ 
  return 0; 
} 
 
const char * 
server_type (void *a, void *b, char *arg) 
{ 
  const char *err = ap_check_cmd_context (a, 0x01|0x02|0x04|0x08|0x10); 
  if (err) 
    return err; 
 
  if (!strcmp (arg, "inetd")) 
    ap_standalone = 0; 
  else if (!strcmp (arg, "standalone")) 
    { 
      // printf ("standalone"); 
      ap_standalone = 1; 
    } 
  else 
    return "ServerType must be either 'inetd' or 'standalone'"; 
 
  return 0; 
} 
 
int 
main () 
{ 
  server_type (0, 0, "standalone"); 
} 
$ gcc -O2 -g http_core.c 
$ ./a.out 
Segmentation fault 
 
	addl r14 = @ltoffx(ap_standalone#), r1 
	;; 
	.mii 
	ld8.mov r15 = [r14], ap_standalone# 
	addl r14 = @ltoffx(.LC2), r1 
	;; 
	(p7) addl r14 = 1, r0		<--- r14 clobbered 
	;; 
	.mii 
	(p7) st4 [r15] = r14 
	nop.i 0 
	nop.i 0 
	.mbb 
	ld8.mov r14 = [r14], .LC2	<--- crash 
 
Workaround: compile with -fno-sched-interblock or -fno-if-conversion2 or 
-fno-sched-spec or -fno-schedule-insns.
Comment 1 Eric Botcazou 2003-07-06 11:25:20 UTC
Confirmed on gcc version 3.3.1 20030703 (prerelease).

Preliminary investigations suggest that the culprit is the machine dependent
reorganisation pass, which swaps

(jump_insn 82 88 122 3 0x401b54c0 (set (pc)
        (if_then_else (eq (reg:BI 262 p6 [361])
                (const_int 0 [0x0]))
            (label_ref 100)
            (pc))) 214 {*br_true} (insn_list 81 (nil))
    (expr_list:REG_DEAD (reg:BI 262 p6 [361])
        (expr_list:REG_BR_PROB (const_int 5000 [0x1388])
            (nil))))

(insn 96 122 159 4 0x401b54c0 (set (reg/f:DI 14 r14 [340])
        (lo_sum:DI (reg:DI 14 r14 [365])
            (symbol_ref/f:DI ("*.LC2")))) 12 {*load_symptr_low} (nil)
    (expr_list:REG_EQUAL (symbol_ref/f:DI ("*.LC2"))
        (nil)))

to produce

	.mbb
	ld8 r14 = [r14]
	(p7) br.cond.dptk .L4


I don't know enough of IA-64 to say whether swapping back the instructions in
the assembly file is sufficient, or whether they should not have ended up in the
 same bundle in the first place.
Comment 2 Andreas Schwab 2003-07-08 13:56:23 UTC
Replacing: 
	.mii 
	(p7) st4 [r15] = r14 
	nop.i 0 
	nop.i 0 
	.mbb 
	ld8.mov r14 = [r14], .LC2 
	(p7) br.cond.dptk .L5 
	br .L2 
	;; 
with: 
	.mib 
	(p7) st4 [r15] = r14 
	nop.i 0 
	(p7) br.cond.dptk .L5 
	.mbb 
	ld8.mov r14 = [r14], .LC2 
	nop.b 0 
	br .L2 
	;; 
(thus effectively undoing the swapping) produces working code. 
Comment 3 Eric Botcazou 2003-07-10 08:05:30 UTC
Thanks. I think I've found the root of the problem and even a possible solution,
but I'll need your help for testing because I don't have access to IA-64 hardware.
Comment 4 Mark Mitchell 2003-07-11 23:09:50 UTC
Postponed until GCC 3.3.2; IA64 is not a primary platform.
Comment 5 Eric Botcazou 2003-07-12 07:45:24 UTC
*** Bug 11399 has been marked as a duplicate of this bug. ***
Comment 6 CVS Commits 2003-07-15 13:02:30 UTC
Subject: Bug 11320

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	ebotcazou@gcc.gnu.org	2003-07-15 13:02:21

Modified files:
	gcc            : ChangeLog sched-deps.c sched-ebb.c sched-int.h 
	                 sched-rgn.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/execute: 20030715-1.c 

Log message:
	PR optimization/11320
	* sched-int.h (struct deps) [reg_conditional_sets]: New field.
	(struct sched_info) [compute_jump_reg_dependencies]: New prototype.
	* sched-deps.c (sched_analyze_insn) [JUMP_INSN]: Update call to
	current_sched_info->compute_jump_reg_dependencies. Record which
	registers are used and which registers are set by the jump.
	Clear deps->reg_conditional_sets after a barrier.
	Set deps->reg_conditional_sets if the insn is a COND_EXEC.
	Clear deps->reg_conditional_sets if the insn is not a COND_EXEC.
	(init_deps): Initialize reg_conditional_sets.
	(free_deps): Clear reg_conditional_sets.
	* sched-ebb.c (compute_jump_reg_dependencies): New prototype.
	Mark registers live on entry of the fallthrough block and conditionally
	set as set by the jump. Mark registers live on entry of non-fallthrough
	blocks as used by the jump.
	* sched-rgn.c (compute_jump_reg_dependencies): New prototype.
	Mark new parameters as unused.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.511&r2=2.512
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/sched-deps.c.diff?cvsroot=gcc&r1=1.59&r2=1.60
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/sched-ebb.c.diff?cvsroot=gcc&r1=1.29&r2=1.30
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/sched-int.h.diff?cvsroot=gcc&r1=1.27&r2=1.28
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/sched-rgn.c.diff?cvsroot=gcc&r1=1.60&r2=1.61
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2877&r2=1.2878
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20030715-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 7 CVS Commits 2003-07-15 13:09:19 UTC
Subject: Bug 11320

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	ebotcazou@gcc.gnu.org	2003-07-15 13:09:15

Modified files:
	gcc            : ChangeLog sched-deps.c sched-ebb.c sched-int.h 
	                 sched-rgn.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/execute: 20030715-1.c 

Log message:
	PR optimization/11320
	* sched-int.h (struct deps) [reg_conditional_sets]: New field.
	(struct sched_info) [compute_jump_reg_dependencies]: New prototype.
	* sched-deps.c (sched_analyze_insn) [JUMP_INSN]: Update call to
	current_sched_info->compute_jump_reg_dependencies. Record which
	registers are used and which registers are set by the jump.
	Clear deps->reg_conditional_sets after a barrier.
	Set deps->reg_conditional_sets if the insn is a COND_EXEC.
	Clear deps->reg_conditional_sets if the insn is not a COND_EXEC.
	(init_deps): Initialize reg_conditional_sets.
	(free_deps): Clear reg_conditional_sets.
	* sched-ebb.c (compute_jump_reg_dependencies): New prototype.
	Mark registers live on entry of the fallthrough block and conditionally
	set as set by the jump. Mark registers live on entry of non-fallthrough
	blocks as used by the jump.
	* sched-rgn.c (compute_jump_reg_dependencies): New prototype.
	Mark new parameters as unused.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.658&r2=1.16114.2.659
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/sched-deps.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.49&r2=1.49.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/sched-ebb.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.17&r2=1.17.20.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/sched-int.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.23&r2=1.23.4.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/sched-rgn.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.50&r2=1.50.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.233&r2=1.2261.2.234
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20030715-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1

Comment 8 Eric Botcazou 2003-07-15 13:17:24 UTC
See http://gcc.gnu.org/ml/gcc-patches/2003-07/msg01044.html
Comment 9 CVS Commits 2004-02-28 11:22:29 UTC
Subject: Bug 11320

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_2-rhl8-branch
Changes by:	jakub@gcc.gnu.org	2004-02-28 11:22:23

Modified files:
	gcc            : ChangeLog sched-deps.c sched-ebb.c sched-int.h 
	                 sched-rgn.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/execute: 20030715-1.c 

Log message:
	2003-07-15  Eric Botcazou  <ebotcazou@libertysurf.fr>
	
	PR optimization/11320
	* sched-int.h (struct deps) [reg_conditional_sets]: New field.
	(struct sched_info) [compute_jump_reg_dependencies]: New prototype.
	* sched-deps.c (sched_analyze_insn) [JUMP_INSN]: Update call to
	current_sched_info->compute_jump_reg_dependencies. Record which
	registers are used and which registers are set by the jump.
	Clear deps->reg_conditional_sets after a barrier.
	Set deps->reg_conditional_sets if the insn is a COND_EXEC.
	Clear deps->reg_conditional_sets if the insn is not a COND_EXEC.
	(init_deps): Initialize reg_conditional_sets.
	(free_deps): Clear reg_conditional_sets.
	* sched-ebb.c (compute_jump_reg_dependencies): New prototype.
	Mark registers live on entry of the fallthrough block and conditionally
	set as set by the jump. Mark registers live on entry of non-fallthrough
	blocks as used by the jump.
	* sched-rgn.c (compute_jump_reg_dependencies): New prototype.
	Mark new parameters as unused.
	
	* gcc.c-torture/execute/20030715-1.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.13152.2.657.2.27.2.186&r2=1.13152.2.657.2.27.2.187
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/sched-deps.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.34.6.1.2.3&r2=1.34.6.1.2.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/sched-ebb.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.8.12.4&r2=1.8.12.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/sched-int.h.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.18.2.1.4.1.2.2&r2=1.18.2.1.4.1.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/sched-rgn.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.32.2.3.8.2&r2=1.32.2.3.8.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=1.1672.2.166.2.8.2.77&r2=1.1672.2.166.2.8.2.78
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20030715-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-rhl8-branch&r1=NONE&r2=1.1.34.1

Comment 10 Bernd Schmidt 2011-07-14 17:06:38 UTC
Author: bernds
Date: Thu Jul 14 17:06:33 2011
New Revision: 176280

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176280
Log:
	PR rtl-optimization/11320
	* config/ia64/ia64.md (load_symptr_low): Show a MEM.
	* config/ia64/ia64.c (ia64_expand_load_address): Generate it.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/ia64/ia64.c
    trunk/gcc/config/ia64/ia64.md
Comment 11 Bernd Schmidt 2011-07-15 13:20:17 UTC
Author: bernds
Date: Fri Jul 15 13:20:10 2011
New Revision: 176315

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176315
Log:
	Revert
	2003-07-10  Eric Botcazou  <ebotcazou@libertysurf.fr>
	PR rtl-optimization/11320
	* sched-int.h (struct deps) [reg_conditional_sets]: New field.
	(struct sched_info) [compute_jump_reg_dependencies]: New prototype.
	* sched-deps.c (sched_analyze_insn) [JUMP_INSN]: Update call to
	current_sched_info->compute_jump_reg_dependencies. Record which
	registers are used and which registers are set by the jump.
	Clear deps->reg_conditional_sets after a barrier.
	Set deps->reg_conditional_sets if the insn is a COND_EXEC.
	Clear deps->reg_conditional_sets if the insn is not a COND_EXEC.
	(init_deps): Initialize reg_conditional_sets.
	(free_deps): Clear reg_conditional_sets.
	* sched-ebb.c (compute_jump_reg_dependencies): New prototype.
	Mark registers live on entry of the fallthrough block and conditionally
	set as set by the jump. Mark registers live on entry of non-fallthrough
	blocks as used by the jump.
	* sched-rgn.c (compute_jump_reg_dependencies): New prototype.
	Mark new parameters as unused.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/modulo-sched.c
    trunk/gcc/sched-deps.c
    trunk/gcc/sched-ebb.c
    trunk/gcc/sched-int.h
    trunk/gcc/sched-rgn.c