This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/28055] New: [SH] a function attributed to weak is discarded, if '-O' is specified
- From: "saito at densan dot co dot jp" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Jun 2006 05:08:11 -0000
- Subject: [Bug target/28055] New: [SH] a function attributed to weak is discarded, if '-O' is specified
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I tested using gcc-3.4.6 and gcc-4.1.1. The code generated by gcc-4.1.1 is
wrong, because a function attributed to weak is discarded by optimization.
I wander if this problem is gcc4's specification because I can see same problem
with gcc-4.1.1 for PowerPC.
The source code is as follows. The command line is "sh4-linux-gcc -S testcase.c
-O".
void __attribute__ ((weak))
arch_init_clk_ops()
{
}
void clk_init(void)
{
arch_init_clk_ops();
}
The result for gcc-4.1.1:
.weak arch_init_clk_ops
.type arch_init_clk_ops, @function
arch_init_clk_ops:
mov.l r14,@-r15
mov r15,r14
mov r14,r15
mov.l @r15+,r14
rts
nop
.size arch_init_clk_ops, .-arch_init_clk_ops
.align 1
.global clk_init
.type clk_init, @function
clk_init:
mov.l r14,@-r15
mov r15,r14 # arch_init_clk_op can not be called
mov r14,r15
mov.l @r15+,r14
rts
nop
The result for gcc-3.4.6:
arch_init_clk_ops:
mov.l r14,@-r15
sts.l pr,@-r15
mov r15,r14
mov r14,r15
lds.l @r15+,pr
rts
mov.l @r15+,r14
.size arch_init_clk_ops, .-arch_init_clk_ops
.align 1
.global clk_init
.type clk_init, @function
clk_init:
mov.l r14,@-r15
sts.l pr,@-r15
mov.l .L3,r1
jsr @r1
mov r15,r14
mov r14,r15
lds.l @r15+,pr
rts
mov.l @r15+,r14
.L4:
.align 2
.L3:
.long arch_init_clk_ops
--
Summary: [SH] a function attributed to weak is discarded, if '-O'
is specified
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: saito at densan dot co dot jp
GCC build triplet: sh4-linux
GCC host triplet: sh4-linux
GCC target triplet: sh4-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28055