[Bug target/32577] [SH] static inline attribute causes stack overflow
--- Comment #2 from saito at densan dot co dot jp 2007-07-23 01:23 --- How about following testcase. I list the value which moves current sp as to some architectures. In the following case, listed value is 24. > add #-24,r15 <-- stack grows down With the result that only gcc-4.2.0 for sh4 accumulates the stack space for inlined variables. Actually, I need to spread the stack size for sh-linux's kernel-thread from 0x2000 byte to 0x4000 byte, although I specify optimization option(-O2). Gcc-4.1.2 does not have this problem. -testcase-- struct xxx { int x; int y; }; static inline __attribute__((always_inline)) int add(int x, int y) { struct xxx xxx; xxx.x = x; xxx.y = y; dummy(&xxx); return x + y; } int x, y; main(int ac, char** av) { x = add(x, y); /* count of add is one */ return x; } -end testcase-- compiling options: gcc test.c -O2 -S case of gcc-4.2.0 --- count of add | 1 2 4 8 16 - the valuesh4 | 8 16 24 40 68 ppc | 48 64 64 64 64 i686 | 16 16 16 16 16 case of gcc-4.1.2 --- the valuesh4 | 8 8 8 8 8 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32577
[Bug target/32577] New: [SH] static inline attribute causes stack overflow
When I use static inline attribute without any optimization as follows, stack space is stacked. As a result, a stack overflow is caused. This problem came from using gcc-4.2.0 for linux kernel which uses many inlines. -compile options- sh4-linux-gcc -S test.c -testcase #1--- static inline __attribute__((always_inline)) int add(int x, int y) { return x + y; } int x, y; main(int ac, char** av) { x = add(x, y); return x; } -testcase #2--- static inline __attribute__((always_inline)) int add(int x, int y) { return x + y; } int x, y; main(int ac, char** av) { x = add(x, y); x = add(x, y); return x; } -assembled code for testcase #1--- .global main .type main, @function main: mov.l r14,@-r15 add #-16,r15 mov r15,r14 mov r14,r1 add #-48,r1 mov.l r4,@(52,r1) ... -assembled code for testcase #2--- .global main .type main, @function main: mov.l r14,@-r15 add #-24,r15 <-- stack grows down mov r15,r14 mov r14,r1 add #-40,r1 mov.l r4,@(44,r1) ... -- Summary: [SH] static inline attribute causes stack overflow Product: gcc Version: 4.2.0 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=32577
[Bug target/31022] New: [SH4] internal compiler error with inline
When I compile a testcase that includes float and inline, it asserts internal compiler error if it is optimized with -O2. If it is optimized with -O, this error is not asserted. % gcc -c test.c -O2 -m4 test.c: In function 'fff': test.c:19: internal compiler error: in reg_overlap_mentioned_p, at rtlanal.c:1382 Please submit a full bug report, with preprocessed source if appropriate. See http://gcc.gnu.org/bugs.html> for instructions. -test case typedef union { float f; int i; } fi_type; static __inline__ float LOG2(float val) { fi_type num; int i; num.f = val; i = num.i >> 23; num.i++; return num.f + i; } float f; float fff() { return LOG2(f); } -- Summary: [SH4] internal compiler error with inline Product: gcc Version: 4.1.2 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=31022
[Bug target/28055] New: [SH] a function attributed to weak is discarded, if '-O' is specified
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
[Bug target/28011] [SH] g++ generates wrong code, if '-fno-exceptions' and '-O' options are specified
--- Comment #1 from saito at densan dot co dot jp 2006-06-13 10:43 --- Created an attachment (id=11660) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11660&action=view) testcase This testcase is very large because this file already includes header files and this came from firefox's build. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28011
[Bug target/28011] New: [SH] g++ generates wrong code, if '-fno-exceptions' and '-O' options are specified
g++ generates wrong code, if '-fno-exceptions' and '-O' options are specified. I did following tests. In the case of 1, wrong code was generated. 1. sh4-linux-g++ -S -O -fno-exceptions testcase.cc 2. sh4-linux-g++ -S -O2 -fno-exceptions testcase.cc Source code is as follows but I will attach the testcase. PRBool dummy; asm("POST:"); return target->DispatchEvent(event, aDefaultAction ? aDefaultAction : &dummy); The result of case 1. #APP POST: #NO_APP mov.w .L76,r0 mov.w .L79,r3 add r14,r3 mov.l @(r0,r3),r4 mov.l @r4,r1 mov.l @(20,r1),r2 mov.l @r8,r5 mov.l @(44,r3),r1 tst r1,r1 bf .L27 mov.w .L66,r1# .L66: .short -188 mov.w .L79,r3# .L79: .short 188 add r14,r3 add r1,r3 mov.l r3,@(44,r3) # this code is wrong because 44 is not right value .L27:# the value should be 232 - (188 - 188) but not 232 - 188 mov.w .L68,r0# .L68: .short 232 mov.l @(r0,r14),r6 jsr @r2 nop The result of case 2. It seems that this case is right. #APP POST: #NO_APP mov.w .L62,r3 mov.l @r13,r5 add r14,r3 mov.l @(0,r3),r4 mov.l @(44,r3),r2 mov.l @r4,r1 tst r2,r2 mov.l @(20,r1),r1 bt .L34 .L27: mov.w .L58,r0 mov.l @(r0,r14),r6 jsr @r1 nop mov r0,r9 .L24: mov.l .L63,r1 jsr @r1 mov r8,r4 ... .L34: mov.w .L67,r2 mov.w .L68,r0 add r14,r2 mov.l r2,@(r0,r14) bra .L27 nop -- Summary: [SH] g++ generates wrong code, if '-fno-exceptions' and '-O' options are 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=28011
[Bug target/27621] [SH] generated pic code is not right
--- Comment #4 from saito at densan dot co dot jp 2006-05-16 09:13 --- I can not look the problem of the testcase using gcc-4.1.0. I will try to use gcc-4.1.0 on shlinux instead of gcc-3.4.6. Thanks for your support. -- saito at densan dot co dot jp changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27621
[Bug c++/27621] [SH] generated pic code is not right
--- Comment #3 from saito at densan dot co dot jp 2006-05-16 02:53 --- I could not build glibc for sh using 4.0.1 before, then I use 3.4.6 now, but I will test and report the result using gcc-4.1.0. -- saito at densan dot co dot jp changed: What|Removed |Added Component|target |c++ http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27621
[Bug c++/27621] [SH] generated pic code is not right
--- Comment #1 from saito at densan dot co dot jp 2006-05-16 02:28 --- Created an attachment (id=11472) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11472&action=view) testcase -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27621
[Bug c++/27621] New: [SH] generated pic code is not right
This problem depends on generated pic code for sh. For reproducing, needs two files a shared library(musician.so) and a executable file(main). I will attach these files. musician.so is shared library compiled with -fPIC option. musician.so is linked dynamically if main is excuted as follows. g++ -g -o musician.so musician.cc -shared -fPIC g++ -g -o main main.cc musician.so env LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH main actual result: main issues a following error. Segmentation fault expected result: main prints a following message. playing=1 The following code generated by g++ is wrong for the pic code because r12 is not set for this shared library. .weak _ZThn4_N6typist5printEv .type _ZThn4_N6typist5printEv, @function _ZThn4_N6typist5printEv: .LFB46: mov.l .L153,r3 add r12,r3 jmp @r3 add #-4,r4 .L154: .align 2 .L153: .long [EMAIL PROTECTED] -- Summary: [SH] generated pic code is not right Product: gcc Version: 3.4.6 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ 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=27621