http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51872
Bug #: 51872 Summary: [4.7 Regression] Shrink-wrapping with -mminimal-toc causes bootstrap failure Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: bootstrap AssignedTo: unassig...@gcc.gnu.org ReportedBy: ja...@gcc.gnu.org CC: amo...@gcc.gnu.org, ber...@gcc.gnu.org, d...@gcc.gnu.org Target: powerpc64-linux powerpc64-linux doesn't bootstrap with -mminimal-toc in CFLAGS/CXXFLAGS, due to shrink-wrapping, as crtbegin.o is miscompiled. Short testcase for -m64 -O2 -mminimal-toc: static void *var[] __attribute__ ((used, section("jlist"), aligned(sizeof(void*)))) = { }; extern void bar (void *) __attribute__ ((weak)); static void __attribute__((noinline, noclone)) baz (void) { asm volatile ("" : : : "memory"); } void foo (void) { if (var[0]) { void (*register_classes) (void *) = bar; __asm ("" : "+r" (register_classes)); if (register_classes) register_classes (var); } baz (); } The problem is that the TOC register (r30) isn't added to the set_up_by_prologue regset (flag_pic is 0, TARGET_MINIMAL_TOC is true and the prologue computes the TOC_REGISTER). I wonder if we don't need a target hook that will add additional registers to set_up_by_prologue regset.