public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/18032] New: [4.0.0] SH: wrong code for EH
@ 2004-10-16 8:22 kkojima at gcc dot gnu dot org
2004-10-16 8:26 ` [Bug target/18032] " kkojima at gcc dot gnu dot org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: kkojima at gcc dot gnu dot org @ 2004-10-16 8:22 UTC (permalink / raw)
To: gcc-bugs
The program below doesn't exit with 0 as expected when it's compiled
with -O2. It works fine with -O1 or -O2 -fno-delayed-branch.
--
int *dummy;
void
bar (int *p)
{
dummy = p;
}
void
foo (int x)
{
int var;
bar (&var);
if (x)
throw 1;
}
int
main ()
{
try {
foo (1);
} catch (...) {
return 0;
}
return 1;
}
--
With -O2, the function foo looks like:
_Z3fooi:
.LFB3:
mov.l r8,@-r15
.LCFI3:
mov r4,r8
mov.l r14,@-r15
.LCFI4:
sts.l pr,@-r15
.LCFI5:
mov.l .L11,r1
add #-4,r15
.LCFI6:
mov r15,r14
.LCFI7:
jsr @r1
mov r14,r4
tst r8,r8
bf/s .L10
add #4,r14
mov r14,r15
lds.l @r15+,pr
mov.l @r15+,r14
rts
mov.l @r15+,r8
.align 5
.L10:
mov.l .L12,r0
jsr @r0
mov #4,r4
mov #1,r1
mov.l r1,@r0
mov.l .L13,r1
mov r0,r4
mov.l .L14,r5
jsr @r1
mov #0,r6
...
Thus the throw part starting with .L10 is called after the excution of
"add #4,r14" in the delayed slot. It seems that this doesn't match
the frame info of foo:
$ readelf -a ./a.out | grep foo
99: 00400760 100 FUNC GLOBAL DEFAULT 11 _Z3fooi
$ readelf --debug-dump=frames ./a.out
The section .eh_frame contains:
...
0000001c 00000028 00000020 FDE cie=00000000 pc=00400760..004007c4
Augmentation data: 00 00 00 00
DW_CFA_advance_loc: 2 to 00400762
DW_CFA_def_cfa_offset: 4
DW_CFA_offset: r8 at cfa-4
DW_CFA_advance_loc: 4 to 00400766
DW_CFA_def_cfa_offset: 8
DW_CFA_advance_loc: 2 to 00400768
DW_CFA_def_cfa_offset: 12
DW_CFA_advance_loc: 4 to 0040076c
DW_CFA_def_cfa_offset: 16
DW_CFA_offset: r17 at cfa-12
DW_CFA_offset: r14 at cfa-8
DW_CFA_advance_loc: 2 to 0040076e
DW_CFA_def_cfa_reg: r14
DW_CFA_nop
DW_CFA_nop
which assumes that r14 points the bottom of the frame when the throw
part is called.
--
Summary: [4.0.0] SH: wrong code for EH
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kkojima at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: sh4-unknown-linux-gnu
GCC host triplet: sh4-unknown-linux-gnu
GCC target triplet: sh4-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18032
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/18032] [4.0.0] SH: wrong code for EH
2004-10-16 8:22 [Bug target/18032] New: [4.0.0] SH: wrong code for EH kkojima at gcc dot gnu dot org
@ 2004-10-16 8:26 ` kkojima at gcc dot gnu dot org
2004-10-16 13:58 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: kkojima at gcc dot gnu dot org @ 2004-10-16 8:26 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |3.4.2 4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18032
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/18032] [4.0.0] SH: wrong code for EH
2004-10-16 8:22 [Bug target/18032] New: [4.0.0] SH: wrong code for EH kkojima at gcc dot gnu dot org
2004-10-16 8:26 ` [Bug target/18032] " kkojima at gcc dot gnu dot org
@ 2004-10-16 13:58 ` pinskia at gcc dot gnu dot org
2004-10-18 15:49 ` amylaar at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-16 13:58 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18032
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/18032] [4.0.0] SH: wrong code for EH
2004-10-16 8:22 [Bug target/18032] New: [4.0.0] SH: wrong code for EH kkojima at gcc dot gnu dot org
2004-10-16 8:26 ` [Bug target/18032] " kkojima at gcc dot gnu dot org
2004-10-16 13:58 ` pinskia at gcc dot gnu dot org
@ 2004-10-18 15:49 ` amylaar at gcc dot gnu dot org
2004-10-18 22:43 ` kkojima at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: amylaar at gcc dot gnu dot org @ 2004-10-18 15:49 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From amylaar at gcc dot gnu dot org 2004-10-18 15:49 -------
We don't emit call frame information for the epilogue. If we did, than any
basic blocks that happen to come after the epilogue due to block reordering
would end up with incorrect cfi information, since we don't have any machinery
for writing compensating cfi when we skip over an epilogue.
Thus, the only way we have to make this work with the current infrastructure
is to avoid scheduling the epilogue with previous basic blocks when exception
handling is enabled (this also affects debugging information, but I'd say we
shouldn't pessimize -O2 code to get better debugging information).
There is already code in sh.c:sh_expand_epilogue to emit a blockage instruction
before the stack adjustments. However, if a frame pointer is needed, the
initial adjustment of the frame pointer isn't adjusted, since this doesn't
matter for interrupts:
if (frame_pointer_needed)
{
output_stack_adjust (frame_size, frame_pointer_rtx, e, &live_regs_mask);
/* We must avoid moving the stack pointer adjustment past code
which reads from the local frame, else an interrupt could
occur after the SP adjustment and clobber data in the local
frame. */
emit_insn (gen_blockage ());
emit_insn (GEN_MOV (stack_pointer_rtx, frame_pointer_rtx));
}
So, if flag_exceptions is set, we should emit this blockage before the frame
pointer adjustment.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |amylaar at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18032
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/18032] [4.0.0] SH: wrong code for EH
2004-10-16 8:22 [Bug target/18032] New: [4.0.0] SH: wrong code for EH kkojima at gcc dot gnu dot org
` (2 preceding siblings ...)
2004-10-18 15:49 ` amylaar at gcc dot gnu dot org
@ 2004-10-18 22:43 ` kkojima at gcc dot gnu dot org
2004-10-20 13:57 ` cvs-commit at gcc dot gnu dot org
2004-10-20 17:39 ` pinskia at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: kkojima at gcc dot gnu dot org @ 2004-10-18 22:43 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From kkojima at gcc dot gnu dot org 2004-10-18 22:43 -------
I'm testing a patch you suggest with the usual bootstrap and
regression test. I'll send it to gcc-patches if it passes.
--- ORIG/gcc/gcc/config/sh/sh.c 2004-10-08 07:46:30.000000000 +0900
+++ LOCAL/gcc/gcc/config/sh/sh.c 2004-10-19 07:20:50.000000000 +0900
@@ -5828,6 +5828,10 @@ sh_expand_epilogue (bool sibcall_p)
if (frame_pointer_needed)
{
+ /* We must avoid scheduling the epilogue with previous basic blocks
+ when exception handling is enabled. See PR/18032. */
+ if (flag_exceptions)
+ emit_insn (gen_blockage ());
output_stack_adjust (frame_size, frame_pointer_rtx, e, &live_regs_mask);
/* We must avoid moving the stack pointer adjustment past code
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18032
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/18032] [4.0.0] SH: wrong code for EH
2004-10-16 8:22 [Bug target/18032] New: [4.0.0] SH: wrong code for EH kkojima at gcc dot gnu dot org
` (3 preceding siblings ...)
2004-10-18 22:43 ` kkojima at gcc dot gnu dot org
@ 2004-10-20 13:57 ` cvs-commit at gcc dot gnu dot org
2004-10-20 17:39 ` pinskia at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-10-20 13:57 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-10-20 13:57 -------
Subject: Bug 18032
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: kkojima@gcc.gnu.org 2004-10-20 13:57:23
Modified files:
gcc : ChangeLog
gcc/config/sh : sh.c
Log message:
PR target/18032
* config/sh/sh.c (sh_expand_epilogue): Emit a blockage insn before
the frame pointer adjustment when exception handling is enabled.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.5957&r2=2.5958
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sh/sh.c.diff?cvsroot=gcc&r1=1.306&r2=1.307
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18032
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/18032] [4.0.0] SH: wrong code for EH
2004-10-16 8:22 [Bug target/18032] New: [4.0.0] SH: wrong code for EH kkojima at gcc dot gnu dot org
` (4 preceding siblings ...)
2004-10-20 13:57 ` cvs-commit at gcc dot gnu dot org
@ 2004-10-20 17:39 ` pinskia at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-20 17:39 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-10-20 17:39 -------
Fixed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18032
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-10-20 17:39 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-16 8:22 [Bug target/18032] New: [4.0.0] SH: wrong code for EH kkojima at gcc dot gnu dot org
2004-10-16 8:26 ` [Bug target/18032] " kkojima at gcc dot gnu dot org
2004-10-16 13:58 ` pinskia at gcc dot gnu dot org
2004-10-18 15:49 ` amylaar at gcc dot gnu dot org
2004-10-18 22:43 ` kkojima at gcc dot gnu dot org
2004-10-20 13:57 ` cvs-commit at gcc dot gnu dot org
2004-10-20 17:39 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).