On Wed, May 04, 2016 at 02:21:18PM +0930, Alan Modra wrote: > For ABI_V4, -mrelocatable and -fPIC both generate position independent > code, with some extra "fixup" output for -mrelocatable. The > similarity of these two options has led to the situation where the > sysv4.h SUBTARGET_OVERRIDE_OPTIONS sets flag_pic on seeing > -mrelocatable, and sets TARGET_RELOCATABLE on seeing -fPIC. That > prevents LTO from properly optimizing position dependent executables, > because the mutual dependence of the flags and the fact that LTO > streaming records the state of rs6000_isa_flags, result in flag_pic > being set when it shouldn't be. > > So, don't set TARGET_RELOCATABLE when -fPIC. Places that currently > test TARGET_RELOCATABLE can instead test > TARGET_RELOCATABLE || (DEFAULT_ABI == ABI_V4 && flag_pic > 1) > or since TARGET_RELOCATABLE can only be enabled when ABI_V4, > DEFAULT_ABI == ABI_V4 && (TARGET_RELOCATABLE || flag_pic > 1).
That last one is even readable! :-) > Also, since flag_pic is set by -mrelocatable, a number of places that > currently test TARGET_RELOCATABLE can be simplified. I also made > -mrelocatable set TARGET_NO_FP_IN_TOC, allowing TARGET_RELOCATABLE to > be removed from ASM_OUTPUT_SPECIAL_POOL_ENTRY_P. Reducing occurrences > of TARGET_RELOCATABLE is a good thing. Does this TARGET_NO_FP_IN_TOC setting need documenting somewhere? > Bootstrapped and regression tested powerpc64-linux. OK? Okay for trunk, one nit... > @@ -23868,7 +23869,9 @@ rs6000_stack_info (void) > && !TARGET_PROFILE_KERNEL) > || (DEFAULT_ABI == ABI_V4 && cfun->calls_alloca) > #ifdef TARGET_RELOCATABLE > - || (TARGET_RELOCATABLE && (get_pool_size () != 0)) > + || (DEFAULT_ABI == ABI_V4 > + && (TARGET_RELOCATABLE || flag_pic > 1) > + && (get_pool_size () != 0)) Superfluous parens on that last line. Segher