public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/23774] New: dealloc of dynamic stack space breaks backchain
@ 2005-09-08 0:55 amodra at bigpond dot net dot au
2005-09-08 0:57 ` [Bug target/23774] " amodra at bigpond dot net dot au
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: amodra at bigpond dot net dot au @ 2005-09-08 0:55 UTC (permalink / raw)
To: gcc-bugs
The following compiled with -m32 -O2 -S
void badFunc (int size)
{
char temp[size];
temp[size-1] = '\0';
};
gives
badFunc:
mflr 0
stwu 1,-16(1)
stw 0,20(1)
addi 0,3,30
lwz 9,0(1)
mr 11,1
stw 31,12(1)
mr 31,1
rlwinm 0,0,0,0,27
neg 0,0
stwux 9,1,0
li 9,0
addi 0,1,23
rlwinm 0,0,0,0,27
add 3,3,0
stb 9,-1(3) <- old backchain possibly overwritten
nop
nop
nop
lwz 0,0(1)
mr 1,11 <- adjust stack, backchain possibly invalid!
stw 0,0(1) <- write backchain
nop
lwz 11,0(1)
lwz 0,4(11)
lwz 31,-4(11)
mr 1,11
mtlr 0
blr
This testcase also shows
a) excess allocation of dynamic stack space,
b) needless alignment of dynamic stack space,
c) poor epilogue code, with unnecesary stack adjustments.
--
Summary: dealloc of dynamic stack space breaks backchain
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: amodra at bigpond dot net dot au
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: powerpc-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23774
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/23774] dealloc of dynamic stack space breaks backchain
2005-09-08 0:55 [Bug target/23774] New: dealloc of dynamic stack space breaks backchain amodra at bigpond dot net dot au
@ 2005-09-08 0:57 ` amodra at bigpond dot net dot au
2005-09-08 3:22 ` amodra at bigpond dot net dot au
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: amodra at bigpond dot net dot au @ 2005-09-08 0:57 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |4.0.2 4.1.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23774
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/23774] dealloc of dynamic stack space breaks backchain
2005-09-08 0:55 [Bug target/23774] New: dealloc of dynamic stack space breaks backchain amodra at bigpond dot net dot au
2005-09-08 0:57 ` [Bug target/23774] " amodra at bigpond dot net dot au
@ 2005-09-08 3:22 ` amodra at bigpond dot net dot au
2005-09-09 3:14 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: amodra at bigpond dot net dot au @ 2005-09-08 3:22 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |amodra at bigpond dot net
|dot org |dot au
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-09-08 03:22:26
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23774
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/23774] dealloc of dynamic stack space breaks backchain
2005-09-08 0:55 [Bug target/23774] New: dealloc of dynamic stack space breaks backchain amodra at bigpond dot net dot au
2005-09-08 0:57 ` [Bug target/23774] " amodra at bigpond dot net dot au
2005-09-08 3:22 ` amodra at bigpond dot net dot au
@ 2005-09-09 3:14 ` pinskia at gcc dot gnu dot org
2005-09-13 0:33 ` amodra at bigpond dot net dot au
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-09 3:14 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-09-09 03:14 -------
This causes wrong code in a way and also causes wrong debugging too as the backchain is broken.
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code, wrong-debug
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23774
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/23774] dealloc of dynamic stack space breaks backchain
2005-09-08 0:55 [Bug target/23774] New: dealloc of dynamic stack space breaks backchain amodra at bigpond dot net dot au
` (2 preceding siblings ...)
2005-09-09 3:14 ` pinskia at gcc dot gnu dot org
@ 2005-09-13 0:33 ` amodra at bigpond dot net dot au
2005-09-13 2:01 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: amodra at bigpond dot net dot au @ 2005-09-13 0:33 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From amodra at bigpond dot net dot au 2005-09-13 00:33 -------
The same thing happens with __builtin_longjmp, eg. extracted from
gcc.c-torture/execute/builtins/lib/chk.c
void __attribute__((noreturn))
__chk_fail (void)
{
if (chk_fail_allowed)
__builtin_longjmp (chk_fail_buf, 1);
abort ();
}
generates
__chk_fail:
stwu 1,-16(1)
mflr 0
stw 31,12(1)
stw 0,20(1)
mr 31,1
lis 9,chk_fail_allowed@ha
lwz 0,chk_fail_allowed@l(9)
cmpwi 7,0,0
beq- 7,.L133
lis 11,chk_fail_buf@ha
la 9,chk_fail_buf@l(11)
lwz 0,4(9)
mtctr 0
lwz 31,chk_fail_buf@l(11)
lwz 0,8(9)
lwz 1,12(9) <- stack adjusted
stw 0,0(1) <- backchain written
bctr
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23774
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/23774] dealloc of dynamic stack space breaks backchain
2005-09-08 0:55 [Bug target/23774] New: dealloc of dynamic stack space breaks backchain amodra at bigpond dot net dot au
` (3 preceding siblings ...)
2005-09-13 0:33 ` amodra at bigpond dot net dot au
@ 2005-09-13 2:01 ` cvs-commit at gcc dot gnu dot org
2005-09-13 3:02 ` cvs-commit at gcc dot gnu dot org
2005-09-13 4:07 ` amodra at bigpond dot net dot au
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-09-13 2:01 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-09-13 02:01 -------
Subject: Bug 23774
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: amodra@gcc.gnu.org 2005-09-13 02:01:04
Modified files:
gcc : ChangeLog
gcc/config/rs6000: rs6000.md
Log message:
PR target/23774
* config/rs6000/rs6000.md (restore_stack_block): Write the backchain
word before changing the stack pointer. Use gen_frame_mem for MEMs.
Use UNSPEC_TIE to prevent insn scheduling reordering the insns.
(restore_stack_nonlocal): Likewise.
(save_stack_nonlocal): Use template to emit insns, and gen_frame_mem.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9942&r2=2.9943
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/rs6000/rs6000.md.diff?cvsroot=gcc&r1=1.407&r2=1.408
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23774
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/23774] dealloc of dynamic stack space breaks backchain
2005-09-08 0:55 [Bug target/23774] New: dealloc of dynamic stack space breaks backchain amodra at bigpond dot net dot au
` (4 preceding siblings ...)
2005-09-13 2:01 ` cvs-commit at gcc dot gnu dot org
@ 2005-09-13 3:02 ` cvs-commit at gcc dot gnu dot org
2005-09-13 4:07 ` amodra at bigpond dot net dot au
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-09-13 3:02 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-09-13 03:01 -------
Subject: Bug 23774
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-4_0-branch
Changes by: amodra@gcc.gnu.org 2005-09-13 03:01:08
Modified files:
gcc : ChangeLog
gcc/config/rs6000: rs6000.md
Log message:
PR target/23774
* config/rs6000/rs6000.md (restore_stack_block): Write the backchain
word before changing the stack pointer. Use gen_frame_mem for MEMs.
Use UNSPEC_TIE to prevent insn scheduling reordering the insns.
(restore_stack_nonlocal): Likewise.
(save_stack_nonlocal): Use template to emit insns, and gen_frame_mem.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.427&r2=2.7592.2.428
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/rs6000/rs6000.md.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.350.2.3&r2=1.350.2.4
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23774
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug target/23774] dealloc of dynamic stack space breaks backchain
2005-09-08 0:55 [Bug target/23774] New: dealloc of dynamic stack space breaks backchain amodra at bigpond dot net dot au
` (5 preceding siblings ...)
2005-09-13 3:02 ` cvs-commit at gcc dot gnu dot org
@ 2005-09-13 4:07 ` amodra at bigpond dot net dot au
6 siblings, 0 replies; 8+ messages in thread
From: amodra at bigpond dot net dot au @ 2005-09-13 4:07 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From amodra at bigpond dot net dot au 2005-09-13 04:07 -------
Part (a) Fixed 4.0 and 4.1. Opening another bug for (c), and (b) isn't worth
worrying about.
4.1 patch relies on http://gcc.gnu.org/ml/gcc-cvs/2005-09/msg00429.html and
http://gcc.gnu.org/ml/gcc-cvs/2005-09/msg00447.html
4.0 on http://gcc.gnu.org/ml/gcc-cvs/2005-09/msg00448.html
Followup fix for 4.0, http://gcc.gnu.org/ml/gcc-cvs/2005-09/msg00480.html
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23774
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-09-13 4:07 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-08 0:55 [Bug target/23774] New: dealloc of dynamic stack space breaks backchain amodra at bigpond dot net dot au
2005-09-08 0:57 ` [Bug target/23774] " amodra at bigpond dot net dot au
2005-09-08 3:22 ` amodra at bigpond dot net dot au
2005-09-09 3:14 ` pinskia at gcc dot gnu dot org
2005-09-13 0:33 ` amodra at bigpond dot net dot au
2005-09-13 2:01 ` cvs-commit at gcc dot gnu dot org
2005-09-13 3:02 ` cvs-commit at gcc dot gnu dot org
2005-09-13 4:07 ` amodra at bigpond dot net dot au
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).