[Bug target/68662] [6 regression] FAIL: gcc.dg/lto/20090210 c_lto_20090210_0.o-c_lto_20090210_1.o link, -O2 -flto -flto-partition=none -fuse-linker-plugin -fno-fat-lto-objects

2016-05-04 Thread amodra at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68662

--- Comment #15 from Alan Modra  ---
Author: amodra
Date: Thu May  5 00:07:27 2016
New Revision: 235914

URL: https://gcc.gnu.org/viewcvs?rev=235914=gcc=rev
Log:
[RS6000] TARGET_RELOCATABLE

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).

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.

PR target/68662
* config/rs6000/sysv4.h (SUBTARGET_OVERRIDE_OPTIONS): Don't
set OPTION_MASK_RELOCATABLE when flag_pic == 2.  Set
TARGET_NO_FP_IN_TOC for -mrelocatable.
(MINIMAL_TOC_SECTION_ASM_OP): Remove redundant
TARGET_RELOCATABLE test.
(ASM_OUTPUT_SPECIAL_POOL_ENTRY_P): Likewise.
(ASM_PREFERRED_EH_DATA_FORMAT): Likewise.
* config/rs6000/linux64.h (MINIMAL_TOC_SECTION_ASM_OP): Likewise.
(ASM_OUTPUT_SPECIAL_POOL_ENTRY_P): Likewise.
(ASM_PREFERRED_EH_DATA_FORMAT): Likewise.
* config/rs6000/freebsd64.h (MINIMAL_TOC_SECTION_ASM_OP): Likewise.
(ASM_OUTPUT_SPECIAL_POOL_ENTRY_P): Likewise.
(ASM_PREFERRED_EH_DATA_FORMAT): Likewise.
* config/rs6000/predicates.md (easy_fp_constant): Likewise.
* config/rs6000/rs6000.c (rs6000_elf_output_toc_section_asm_op):
Likewise.
(rs6000_assemble_integer): Update TARGET_RELOCATABLE test.
(rs6000_stack_info): Likewise.
(rs6000_elf_asm_out_constructor): Likewise.
(rs6000_elf_asm_out_destructor): Likewise.
(rs6000_elf_declare_function_name): Likewise.
* config/rs6000/rs6000.md (load_toc_aix_di): Likewise.
* config/rs6000/rs6000.h (MASK_RELOCATABLE, MASK_MINIMAL_TOC):
Don't define.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/rs6000/freebsd64.h
trunk/gcc/config/rs6000/linux64.h
trunk/gcc/config/rs6000/predicates.md
trunk/gcc/config/rs6000/rs6000.c
trunk/gcc/config/rs6000/rs6000.h
trunk/gcc/config/rs6000/rs6000.md
trunk/gcc/config/rs6000/sysv4.h

[Bug target/68662] [6 regression] FAIL: gcc.dg/lto/20090210 c_lto_20090210_0.o-c_lto_20090210_1.o link, -O2 -flto -flto-partition=none -fuse-linker-plugin -fno-fat-lto-objects

2016-02-01 Thread amodra at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68662

--- Comment #13 from Alan Modra  ---
Author: amodra
Date: Tue Feb  2 00:01:16 2016
New Revision: 233061

URL: https://gcc.gnu.org/viewcvs?rev=233061=gcc=rev
Log:
[RS6000] ABI_V4 init of toc section

Since 4c4a180d lto has turned off flag_pic when linking a fixed
position executable.  So flag_pic is zero in rs6000_file_start.
However, when we get to actually emitting code, flag_pic may be on
again.  This results in undefined references to ".LCTOC1".

PR target/68662
* config/rs6000/rs6000.c (need_toc_init): New var, set it
whenever toc_label_name used.
(rs6000_file_start): Don't set up toc section here,
(rs6000_output_function_epilogue): do so here instead,
(rs6000_xcoff_file_start): and here.
* config/rs6000/rs6000.md (load_toc_aix_si): Set need_toc_init.
(load_toc_aix_di): Likewise.


Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/rs6000/rs6000.c
trunk/gcc/config/rs6000/rs6000.md

[Bug target/68662] [6 regression] FAIL: gcc.dg/lto/20090210 c_lto_20090210_0.o-c_lto_20090210_1.o link, -O2 -flto -flto-partition=none -fuse-linker-plugin -fno-fat-lto-objects

2016-02-01 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68662

Alan Modra  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #14 from Alan Modra  ---
Fixed with workaround. 
https://gcc.gnu.org/ml/gcc-patches/2016-02/msg2.html queued for gcc-7 and
6.1.

[Bug target/68662] [6 regression] FAIL: gcc.dg/lto/20090210 c_lto_20090210_0.o-c_lto_20090210_1.o link, -O2 -flto -flto-partition=none -fuse-linker-plugin -fno-fat-lto-objects

2016-01-28 Thread bergner at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68662

--- Comment #12 from Peter Bergner  ---
Should we add an assert somewhere to ensure that flag_pic and
TARGET_RELOCATABLE are consistent?

[Bug target/68662] [6 regression] FAIL: gcc.dg/lto/20090210 c_lto_20090210_0.o-c_lto_20090210_1.o link, -O2 -flto -flto-partition=none -fuse-linker-plugin -fno-fat-lto-objects

2016-01-28 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68662

Alan Modra  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |amodra at gmail dot com

--- Comment #11 from Alan Modra  ---
Making the toc initialization in rs6000_file_start not depend on flag_pic, ie.
use
  if (DEFAULT_ABI != ABI_DARWIN)
{
  switch_to_section (toc_section);
  switch_to_section (text_section);
}

and applying Jakub's option handling fix for pr61925 to the rs6000 backend, and
fixing a testcase seems to cure this problem.

However, I'll note that the comment #7 testcase fails to compile foo non-PIC,
even on x86 -m32.  Looks like flag_pic and a whole bunch of other flags are not
saved/restored around attribute((optimize())).

[Bug target/68662] [6 regression] FAIL: gcc.dg/lto/20090210 c_lto_20090210_0.o-c_lto_20090210_1.o link, -O2 -flto -flto-partition=none -fuse-linker-plugin -fno-fat-lto-objects

2016-01-27 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68662

--- Comment #10 from Alan Modra  ---
I guess rs6000 needs to implement targetm.override_options_after_change() if
we're to keep flag_pic and TARGET_RELOCATABLE consistent.

[Bug target/68662] [6 regression] FAIL: gcc.dg/lto/20090210 c_lto_20090210_0.o-c_lto_20090210_1.o link, -O2 -flto -flto-partition=none -fuse-linker-plugin -fno-fat-lto-objects

2016-01-27 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68662

--- Comment #9 from Alan Modra  ---
For the testcase in comment #7, global_options are inconsistent (*) and wrong
when compiling foo.  I see flag_pic == 2 there??

(*) In particular, TARGET_RELOCATABLE and flag_pic don't agree.  See
config/rs6000/sysv4.h SUBTARGET_OVERRIDE_OPTIONS.  flag_pic == 2 ought to mean
TARGET_RELOCATABLE is true, but TARGET_RELOCATABLE is false.  This combination
is not recognized in rs6000_emit_move.

[Bug target/68662] [6 regression] FAIL: gcc.dg/lto/20090210 c_lto_20090210_0.o-c_lto_20090210_1.o link, -O2 -flto -flto-partition=none -fuse-linker-plugin -fno-fat-lto-objects

2016-01-27 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68662

--- Comment #7 from Jakub Jelinek  ---
Seems like powerpc* has lots of other issues related to mixing pic and non-pic
code.  E.g.
int x;

int
foo (void)
{
  return x;
}

__attribute__((optimize ("PIC"))) int
bar (void)
{
  return x;
}

seems to ICE due to endless recursion with -O2 -m32 (every force_reg causes
another force_reg, at least in x86_64-linux -> powerpc64-linux cross).

[Bug target/68662] [6 regression] FAIL: gcc.dg/lto/20090210 c_lto_20090210_0.o-c_lto_20090210_1.o link, -O2 -flto -flto-partition=none -fuse-linker-plugin -fno-fat-lto-objects

2016-01-27 Thread bergner at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68662

--- Comment #8 from Peter Bergner  ---
(In reply to Jakub Jelinek from comment #7)
> seems to ICE due to endless recursion with -O2 -m32 (every force_reg causes
> another force_reg, at least in x86_64-linux -> powerpc64-linux cross).

I see a similar failure on a native compile too.

[Bug target/68662] [6 regression] FAIL: gcc.dg/lto/20090210 c_lto_20090210_0.o-c_lto_20090210_1.o link, -O2 -flto -flto-partition=none -fuse-linker-plugin -fno-fat-lto-objects

2016-01-26 Thread dje at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68662

--- Comment #5 from David Edelsohn  ---
Unconditionally generating toc_label_name is okay with me, but I thought that
Alan commented it was not sufficient in Comment #2.

[Bug target/68662] [6 regression] FAIL: gcc.dg/lto/20090210 c_lto_20090210_0.o-c_lto_20090210_1.o link, -O2 -flto -flto-partition=none -fuse-linker-plugin -fno-fat-lto-objects

2016-01-26 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68662

--- Comment #6 from Jakub Jelinek  ---
Author: jakub
Date: Tue Jan 26 19:53:37 2016
New Revision: 232844

URL: https://gcc.gnu.org/viewcvs?rev=232844=gcc=rev
Log:
PR target/68662
* config/rs6000/rs6000.c (rs6000_option_override_internal): Initialize
toc_label_name unconditionally.
(rs6000_emit_load_toc_table): Call ggc_strdup on toc_label_name for
SYMBOL_REF string.  Use toc_label_name instead of constructing
LCTOC1.
(rs6000_elf_declare_function_name): Use toc_label_name instead of
constructing LCTOC1.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/rs6000/rs6000.c

[Bug target/68662] [6 regression] FAIL: gcc.dg/lto/20090210 c_lto_20090210_0.o-c_lto_20090210_1.o link, -O2 -flto -flto-partition=none -fuse-linker-plugin -fno-fat-lto-objects

2016-01-26 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68662

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek  ---
Created attachment 37475
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37475=edit
gcc6-pr68662.patch

So what about this untested patch?  ASM_GENERATE_INTERNAL_LABEL doesn't look to
be too expensive to do unconditionally once, and for GC sanity it needs to go
through ggc_strdup anyway (it is invalid to refer to non-GC allocated strings
in GTY const char * fields that are not skipped by GC).

[Bug target/68662] [6 regression] FAIL: gcc.dg/lto/20090210 c_lto_20090210_0.o-c_lto_20090210_1.o link, -O2 -flto -flto-partition=none -fuse-linker-plugin -fno-fat-lto-objects

2016-01-18 Thread hubicka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68662

Jan Hubicka  changed:

   What|Removed |Added

  Component|lto |target

--- Comment #3 from Jan Hubicka  ---
OK, this looks more like target issue  so I am changing component. flag_pic is
a global option and it is merged by the lto wrapper and corrected based on the
linker output. Because static executable is built, flag_pic should be 0. 

Targets must be ready for -fPIC being different at compile time and link time
and ought to honor the link time setting...