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