]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[RS6000] TARGET_RELOCATABLE
authoramodra <amodra@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 5 May 2016 00:07:27 +0000 (00:07 +0000)
committeramodra <amodra@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 5 May 2016 00:07:27 +0000 (00:07 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235914 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 64b2541eaa03f38011c111c58d6d6cc49a09b971..ba7f398b889b9ad160f57840087ed358e2fe214d 100644 (file)
@@ -1,3 +1,31 @@
+2016-05-05  Alan Modra  <amodra@gmail.com>
+
+       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.
+
 2016-05-05  Alan Modra  <amodra@gmail.com>
 
        * config/rs6000/rs6000.c (rs6000_frame_related): Rewrite.
index 899b858d821680f33098574b634a8098eb9fddb9..3038c43b25fa07564d6e7268b85c6eedf942b2a2 100644 (file)
@@ -349,7 +349,7 @@ extern int dot_symbols;
    true if the symbol may be affected by dynamic relocations.  */
 #undef ASM_PREFERRED_EH_DATA_FORMAT
 #define        ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
-  ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE)                    \
+  (TARGET_64BIT || flag_pic                                            \
    ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel              \
       | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4))            \
    : DW_EH_PE_absptr)
@@ -384,7 +384,7 @@ extern int dot_symbols;
 #define MINIMAL_TOC_SECTION_ASM_OP \
   (TARGET_64BIT                                         \
    ? "\t.section\t\".toc1\",\"aw\""                     \
-   : ((TARGET_RELOCATABLE || flag_pic)                  \
+   : (flag_pic                                         \
       ? "\t.section\t\".got2\",\"aw\""                  \
       : "\t.section\t\".got1\",\"aw\""))
 
@@ -422,7 +422,6 @@ extern int dot_symbols;
                         && ! TARGET_NO_FP_IN_TOC)))                     \
                || (!TARGET_64BIT                                        \
                    && !TARGET_NO_FP_IN_TOC                              \
-                   && !TARGET_RELOCATABLE                               \
                    && SCALAR_FLOAT_MODE_P (GET_MODE (X))                \
                    && BITS_PER_WORD == HOST_BITS_PER_INT)))))
 
index fefa0c4eef305fc756e6ada67f6c2fd6dfdc569b..e86b5d52ad6db214bd9644e9c8752790fa9423bc 100644 (file)
@@ -489,7 +489,7 @@ extern int dot_symbols;
 #define MINIMAL_TOC_SECTION_ASM_OP \
   (TARGET_64BIT                                                \
    ? "\t.section\t\".toc1\",\"aw\""                    \
-   : ((TARGET_RELOCATABLE || flag_pic)                 \
+   : (flag_pic                                         \
       ? "\t.section\t\".got2\",\"aw\""                 \
       : "\t.section\t\".got1\",\"aw\""))
 
@@ -585,7 +585,6 @@ extern int dot_symbols;
                        && ! TARGET_NO_FP_IN_TOC)))                     \
               || (!TARGET_64BIT                                        \
                   && !TARGET_NO_FP_IN_TOC                              \
-                  && !TARGET_RELOCATABLE                               \
                   && SCALAR_FLOAT_MODE_P (GET_MODE (X))                \
                   && BITS_PER_WORD == HOST_BITS_PER_INT)))))
 
@@ -594,7 +593,7 @@ extern int dot_symbols;
    true if the symbol may be affected by dynamic relocations.  */
 #undef ASM_PREFERRED_EH_DATA_FORMAT
 #define        ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
-  ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE)                    \
+  (TARGET_64BIT || flag_pic                                            \
    ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel              \
       | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4))            \
    : DW_EH_PE_absptr)
index 71fac765e24f4fdc9b03c7d1048e6c6096a9958e..3b40e3ad9538f9d92ec234b361048c946faec432 100644 (file)
   if (flag_pic && DEFAULT_ABI == ABI_V4)
     return 0;
 
-#ifdef TARGET_RELOCATABLE
-  /* Similarly if we are using -mrelocatable, consider all constants
-     to be hard.  */
-  if (TARGET_RELOCATABLE)
-    return 0;
-#endif
-
   /* If we have real FPRs, consider floating point constants hard (other than
      0.0 under VSX), so that the constant gets pushed to memory during the
      early RTL phases.  This has the advantage that double precision constants
index 701530205fca135d099cefd6f68bcf5fa82e54bf..368fec2b3c857bf98ee0ef38b616d36c776a4075 100644 (file)
@@ -20665,7 +20665,8 @@ rs6000_assemble_integer (rtx x, unsigned int size, int aligned_p)
         don't need to mark it here.  We used to skip the text section, but it
         should never be valid for relocated addresses to be placed in the text
         section.  */
-      if (TARGET_RELOCATABLE
+      if (DEFAULT_ABI == ABI_V4
+         && (TARGET_RELOCATABLE || flag_pic > 1)
          && in_section != toc_section
          && !recurse
          && !CONST_SCALAR_INT_P (x)
@@ -23862,7 +23863,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)
 #endif
       || rs6000_ra_ever_killed ())
     info->lr_save_p = 1;
@@ -31314,8 +31317,7 @@ static void
 rs6000_elf_output_toc_section_asm_op (const void *data ATTRIBUTE_UNUSED)
 {
   if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
-      && TARGET_MINIMAL_TOC
-      && !TARGET_RELOCATABLE)
+      && TARGET_MINIMAL_TOC)
     {
       if (!toc_initialized)
        {
@@ -31336,8 +31338,7 @@ rs6000_elf_output_toc_section_asm_op (const void *data ATTRIBUTE_UNUSED)
       else
        fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP);
     }
-  else if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
-          && !TARGET_RELOCATABLE)
+  else if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
     {
       fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP);
       if (!toc_initialized)
@@ -31928,7 +31929,8 @@ rs6000_elf_asm_out_constructor (rtx symbol, int priority)
   switch_to_section (get_section (section, SECTION_WRITE, NULL));
   assemble_align (POINTER_SIZE);
 
-  if (TARGET_RELOCATABLE)
+  if (DEFAULT_ABI == ABI_V4
+      && (TARGET_RELOCATABLE || flag_pic > 1))
     {
       fputs ("\t.long (", asm_out_file);
       output_addr_const (asm_out_file, symbol);
@@ -31958,7 +31960,8 @@ rs6000_elf_asm_out_destructor (rtx symbol, int priority)
   switch_to_section (get_section (section, SECTION_WRITE, NULL));
   assemble_align (POINTER_SIZE);
 
-  if (TARGET_RELOCATABLE)
+  if (DEFAULT_ABI == ABI_V4
+      && (TARGET_RELOCATABLE || flag_pic > 1))
     {
       fputs ("\t.long (", asm_out_file);
       output_addr_const (asm_out_file, symbol);
@@ -32000,7 +32003,8 @@ rs6000_elf_declare_function_name (FILE *file, const char *name, tree decl)
       return;
     }
 
-  if (TARGET_RELOCATABLE
+  if (DEFAULT_ABI == ABI_V4
+      && (TARGET_RELOCATABLE || flag_pic > 1)
       && !TARGET_SECURE_PLT
       && (get_pool_size () != 0 || crtl->profile)
       && uses_TOC ())
index c89236a29eefcba15e35e965330d04c5ce8dfd63..9647106fbcd04fe406014ca3e9878033770564f2 100644 (file)
@@ -636,18 +636,10 @@ extern int rs6000_vector_align[];
 #define MASK_64BIT                     OPTION_MASK_64BIT
 #endif
 
-#ifdef TARGET_RELOCATABLE
-#define MASK_RELOCATABLE               OPTION_MASK_RELOCATABLE
-#endif
-
 #ifdef TARGET_LITTLE_ENDIAN
 #define MASK_LITTLE_ENDIAN             OPTION_MASK_LITTLE_ENDIAN
 #endif
 
-#ifdef TARGET_MINIMAL_TOC
-#define MASK_MINIMAL_TOC               OPTION_MASK_MINIMAL_TOC
-#endif
-
 #ifdef TARGET_REGNAMES
 #define MASK_REGNAMES                  OPTION_MASK_REGNAMES
 #endif
index 5566185076a16cdc748f4cbd798a6b5fda01b4a4..ed1989cd2a633aa24b7f29480bd175f9c7a365fb 100644 (file)
   char buf[30];
   extern int need_toc_init;
   need_toc_init = 1;
-#ifdef TARGET_RELOCATABLE
   ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\",
-                              !TARGET_MINIMAL_TOC || TARGET_RELOCATABLE);
-#else
-  ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
-#endif
+                              !TARGET_ELF || !TARGET_MINIMAL_TOC);
   if (TARGET_ELF)
     strcat (buf, \"@toc\");
   operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
index af9fe1af7d02952b6b35896dd6e68dbc1d51d5fd..46d2b4bcdbc9f724f07129c32d959941af6d926e 100644 (file)
@@ -190,16 +190,25 @@ do {                                                                      \
       error ("-msecure-plt not supported by your assembler");          \
     }                                                                  \
                                                                        \
-  /* Treat -fPIC the same as -mrelocatable.  */                                \
   if (flag_pic > 1 && DEFAULT_ABI == ABI_V4)                           \
     {                                                                  \
-      rs6000_isa_flags |= OPTION_MASK_RELOCATABLE | OPTION_MASK_MINIMAL_TOC; \
+      /* Note: flag_pic should not change any option flags that would  \
+        be invalid with or pessimise -fno-PIC code.  LTO turns off     \
+        flag_pic when linking/recompiling a fixed position executable. \
+        However, if the objects were originally compiled with -fPIC,   \
+        then other target options forced on here by -fPIC are restored \
+        when recompiling those objects without -fPIC.  In particular   \
+        TARGET_RELOCATABLE must not be enabled here by flag_pic.  */   \
+      rs6000_isa_flags |= OPTION_MASK_MINIMAL_TOC;                     \
       TARGET_NO_FP_IN_TOC = 1;                                         \
     }                                                                  \
                                                                        \
-  else if (TARGET_RELOCATABLE)                                         \
-    if (!flag_pic)                                                     \
-      flag_pic = 2;                                                    \
+  if (TARGET_RELOCATABLE)                                              \
+    {                                                                  \
+      if (!flag_pic)                                                   \
+       flag_pic = 2;                                                   \
+      TARGET_NO_FP_IN_TOC = 1;                                         \
+    }                                                                  \
 } while (0)
 
 #ifndef RS6000_BI_ARCH
@@ -315,8 +324,7 @@ do {                                                                        \
 
 /* Put PC relative got entries in .got2.  */
 #define        MINIMAL_TOC_SECTION_ASM_OP \
-  (TARGET_RELOCATABLE || (flag_pic && DEFAULT_ABI == ABI_V4)           \
-   ? "\t.section\t\".got2\",\"aw\"" : "\t.section\t\".got1\",\"aw\"")
+  (flag_pic ? "\t.section\t\".got2\",\"aw\"" : "\t.section\t\".got1\",\"aw\"")
 
 #define        SDATA_SECTION_ASM_OP "\t.section\t\".sdata\",\"aw\""
 #define        SDATA2_SECTION_ASM_OP "\t.section\t\".sdata2\",\"a\""
@@ -350,7 +358,6 @@ do {                                                                        \
        || (GET_CODE (X) == CONST_INT                                   \
           && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode))      \
        || (!TARGET_NO_FP_IN_TOC                                                \
-          && !TARGET_RELOCATABLE                                       \
           && GET_CODE (X) == CONST_DOUBLE                              \
           && SCALAR_FLOAT_MODE_P (GET_MODE (X))                        \
           && BITS_PER_WORD == HOST_BITS_PER_INT)))
@@ -939,9 +946,10 @@ ncrtn.o%s"
 /* Select a format to encode pointers in exception handling data.  CODE
    is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
    true if the symbol may be affected by dynamic relocations.  */
-#define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)                           \
-  ((flag_pic || TARGET_RELOCATABLE)                                         \
-   ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4) \
+#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL)                     \
+  (flag_pic                                                            \
+   ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel              \
+      | DW_EH_PE_sdata4)                                               \
    : DW_EH_PE_absptr)
 
 #define DOUBLE_INT_ASM_OP "\t.quad\t"