This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC patch]: Skip EH_RETURN_STACKADJ_RTX assignments in create_pre_exit


  There is a problem in create_pre_exit() function of mode switching pass when
exception handlers are processed. In i386 case, following code could be produced
in exit block:

;; Start of basic block 2, registers live: 6 [bp] 7 [sp] 16 [argp] 20 [frame] 60
(code_label:HI 87 60 42 2 439 "" [1 uses])

(note:HI 42 87 63 2 [bb 2] NOTE_INSN_BASIC_BLOCK)

(insn:HI 63 42 64 2 (set (reg/i:SI 0 ax [ <result> ])
        (reg/v:SI 60 [ code ])) 40 {*movsi_1} (nil)
    (expr_list:REG_DEAD (reg/v:SI 60 [ code ])

(insn:HI 64 63 80 2 (set (reg:DI 2 cx)
        (const_int 0 [0x0])) 80 {*movdi_1_rex64} (nil)

(insn:HI 80 64 0 2 (use (reg/i:SI 0 ax [ <result> ])) -1 (insn_list:REG_DEP_TRUE
63 (nil))
;; End of basic block 2, registers live:
 0 [ax] 2 [cx] 6 [bp] 7 [sp] 16 [argp] 20 [frame]

  The problem is in instruction 64, which is inserted between use of return
register (insn 80) and "return_copy" of return register (insn 63). When the do
loop in the pre_mode_exit() searches for the return_copy pattern that
corresponds to use of ax register, it gets confused by assignment to cx register
in the middle (this assignment is inserted by eh_return expander). The loop is
broken in:

		    if (copy_start >= ret_start
			&& copy_start + copy_num <= ret_end)
		      nregs -= copy_num;
		    else if (!(maybe_builtin_apply
			       && FUNCTION_VALUE_REGNO_P (copy_start)))

because ret start is ax register, and copy_start is cx register.

The proposed solution is to ignore assignments to EH_RETURN_STACKADJ_RTX. This
is the same solution as the handling of assignments to FUNCTION_VALUE_REGNO_P
and their uses.

BTW: Even, if the loop is not broken in above break, the code that should handle
exception handling would not be triggered.

		if (return_copy == BB_HEAD (src_bb))

BB_HEAD (src_bb) points to the first code_label in BB, not to the first insn

  Attached patch is regtested/bootstrapped pn i686-pc-linux-gnu and should fix
the bootstrap failure with mmx/x87 switching patch on x86_64. It also passes all
x87/mmx switching testcases.

Thanks to Pawel Sikora for his help with testing the mmx/x87 switching patch on

2005-08-19  Uros Bizjak  <>

	* mode-switching.c (create_pre_exit): Skip assignments to
	EH_RETURN_STACKADJ_RTX when searching for return_copy insn.
	Add comment regarding use insn and simplify check for insns,
	generated by builtin_apply_return.


Attachment: mode.diff
Description: Binary data

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]