This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/28493] Wrong address of stack object used for destructor call on PPC
- From: "atgraham at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Aug 2006 21:11:20 -0000
- Subject: [Bug target/28493] Wrong address of stack object used for destructor call on PPC
- References: <bug-28493-12114@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from atgraham at gmail dot com 2006-08-05 21:11 -------
Actually, it turns out that gcc versions before the 4.1 series all get it wrong
too, at -O0. The bug gets masked when introducing optimization. Here is the
-O0 output from 4.0.3:
g++-4.0.3 -O0 -msoft-float -mcpu=405 -c bug.cc -fno-inline
00000000 <tryfunc()>:
0: 94 21 ff 50 stwu r1,-176(r1)
4: 7c 08 02 a6 mflr r0
8: 7d 80 00 26 mfcr r12
c: 91 c1 00 68 stw r14,104(r1)
10: 91 e1 00 6c stw r15,108(r1)
14: 92 01 00 70 stw r16,112(r1)
18: 92 21 00 74 stw r17,116(r1)
1c: 92 41 00 78 stw r18,120(r1)
20: 92 61 00 7c stw r19,124(r1)
24: 92 81 00 80 stw r20,128(r1)
28: 92 a1 00 84 stw r21,132(r1)
2c: 92 c1 00 88 stw r22,136(r1)
30: 92 e1 00 8c stw r23,140(r1)
34: 93 01 00 90 stw r24,144(r1)
38: 93 21 00 94 stw r25,148(r1)
3c: 93 41 00 98 stw r26,152(r1)
40: 93 61 00 9c stw r27,156(r1)
44: 93 81 00 a0 stw r28,160(r1)
48: 93 a1 00 a4 stw r29,164(r1)
4c: 93 c1 00 a8 stw r30,168(r1)
50: 93 e1 00 ac stw r31,172(r1)
54: 90 01 00 b4 stw r0,180(r1)
58: 91 81 00 64 stw r12,100(r1)
5c: 7c 3f 0b 78 mr r31,r1
60: 3d 20 00 00 lis r9,0
62: R_PPC_ADDR16_HA __gxx_personality_sj0
64: 38 09 00 00 addi r0,r9,0
66: R_PPC_ADDR16_LO __gxx_personality_sj0
68: 90 1f 00 30 stw r0,48(r31)
6c: 3d 20 00 00 lis r9,0
6e: R_PPC_ADDR16_HA .gcc_except_table
70: 38 09 00 00 addi r0,r9,0
72: R_PPC_ADDR16_LO .gcc_except_table
74: 90 1f 00 34 stw r0,52(r31)
78: 39 7f 00 38 addi r11,r31,56
7c: 38 1f 00 08 addi r0,r31,8
80: 90 0b 00 00 stw r0,0(r11)
84: 3d 20 00 00 lis r9,0
86: R_PPC_ADDR16_HA .text+0xe8
88: 38 09 00 e8 addi r0,r9,232
8a: R_PPC_ADDR16_LO .text+0xe8
8c: 90 0b 00 04 stw r0,4(r11)
90: 80 01 00 00 lwz r0,0(r1)
94: 90 0b 00 08 stw r0,8(r11)
98: 90 2b 00 0c stw r1,12(r11)
9c: 38 1f 00 18 addi r0,r31,24
a0: 7c 03 03 78 mr r3,r0
a4: 48 00 00 01 bl a4 <tryfunc()+0xa4>
a4: R_PPC_REL24 _Unwind_SjLj_Register
a8: 38 7f 00 08 addi r3,r31,8
ac: 48 00 00 01 bl ac <tryfunc()+0xac>
ac: R_PPC_REL24 Command::Command()
b0: 38 60 00 04 li r3,4
b4: 48 00 00 01 bl b4 <tryfunc()+0xb4>
b4: R_PPC_REL24 __cxa_allocate_exception
b8: 7c 60 1b 78 mr r0,r3
bc: 7c 0b 03 78 mr r11,r0
c0: 7d 69 5b 78 mr r9,r11
c4: 38 00 00 01 li r0,1
c8: 90 09 00 00 stw r0,0(r9)
cc: 7d 63 5b 78 mr r3,r11
d0: 3d 20 00 00 lis r9,0
d2: R_PPC_ADDR16_HA typeinfo for int
d4: 38 00 00 01 li r0,1
d8: 90 1f 00 1c stw r0,28(r31)
dc: 38 89 00 00 addi r4,r9,0
de: R_PPC_ADDR16_LO typeinfo for int
e0: 38 a0 00 00 li r5,0
e4: 48 00 00 01 bl e4 <tryfunc()+0xe4>
e4: R_PPC_REL24 __cxa_throw
e8: 38 1f ff f8 addi r0,r31,-8
ec: 7c 1f 03 78 mr r31,r0
f0: 80 1f 00 20 lwz r0,32(r31)
f4: 90 1f 00 50 stw r0,80(r31)
f8: 80 1f 00 50 lwz r0,80(r31)
fc: 90 1f 00 4c stw r0,76(r31)
100: 38 7f 00 08 addi r3,r31,8
104: 48 00 00 01 bl 104 <tryfunc()+0x104>
104: R_PPC_REL24 Command::~Command()
108: 80 1f 00 4c lwz r0,76(r31)
10c: 90 1f 00 50 stw r0,80(r31)
110: 38 00 ff ff li r0,-1
114: 90 1f 00 1c stw r0,28(r31)
118: 80 7f 00 50 lwz r3,80(r31)
11c: 48 00 00 01 bl 11c <tryfunc()+0x11c>
In summary: All gcc versions since 3.4.0 (inclusive) display this bug at -O0,
but until 4.1.*, the bug didn't appear in optimized output. In 4.1.0 and
4.1.1, the bug appears consistently at all optimization levels.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28493