Original patch:
http://gcc.gnu.org/ml/gcc-patches/2012-03/msg01393.html
'Tested' with..
../gcc-4_7-branch/configure --target=sh-elf --prefix=/usr/local
--enable-languages=c,c++ --enable-multilib --disable-libssp
--disable-nls --disable-werror --enable-lto --with-newlib --with-gnu-as
--with-gnu-ld --with-system-zlib
make all
OK for 4.7 branch?
ChangeLog:
Backport from mainline
2012-03-21 Kaz Kojima <[email protected]>
PR target/52642
* config/sh/sh.c (sh_expand_prologue): Emit blockage at the end
of prologue for unwinder and profiler.
Index: gcc/config/sh/sh.c
===================================================================
--- gcc/config/sh/sh.c (revision 185554)
+++ gcc/config/sh/sh.c (working copy)
@@ -7239,6 +7239,13 @@
emit_insn (gen_shcompact_incoming_args ());
}
+ /* If we are profiling, make sure no instructions are scheduled before
+ the call to mcount. Similarly if some call instructions are swapped
+ before frame related insns, it'll confuse the unwinder because
+ currently SH has no unwind info for function epilogues. */
+ if (crtl->profile || flag_exceptions || flag_unwind_tables)
+ emit_insn (gen_blockage ());
+
if (flag_stack_usage_info)
current_function_static_stack_size = stack_usage;
}