This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RS6000] TARGET_RELOCATABLE
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Alan Modra <amodra at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org, David Edelsohn <dje dot gcc at gmail dot com>
- Date: Wed, 4 May 2016 11:55:31 -0500
- Subject: Re: [RS6000] TARGET_RELOCATABLE
- Authentication-results: sourceware.org; auth=none
- References: <20160504045118 dot GT18915 at bubble dot grove dot modra dot org>
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