Blame SOURCES/gcc48-rh1537828-8.patch

22033d
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
22033d
index a8238a001ee..34f27c597a2 100644
22033d
--- a/gcc/config/i386/i386.c
22033d
+++ b/gcc/config/i386/i386.c
22033d
@@ -8770,13 +8770,16 @@ ix86_setup_frame_addresses (void)
22033d
    labels in call and return thunks.  */
22033d
 static int indirectlabelno;
22033d
 
22033d
-/* True if call and return thunk functions are needed.  */
22033d
+/* True if call thunk function is needed.  */
22033d
 static bool indirect_thunk_needed = false;
22033d
 
22033d
 /* Bit masks of integer registers, which contain branch target, used
22033d
-   by call and return thunks functions.  */
22033d
+   by call thunk functions.  */
22033d
 static int indirect_thunks_used;
22033d
 
22033d
+/* True if return thunk function is needed.  */
22033d
+static bool indirect_return_needed = false;
22033d
+
22033d
 /* True if return thunk function via CX is needed.  */
22033d
 static bool indirect_return_via_cx;
22033d
 
22033d
@@ -8899,17 +8902,19 @@ output_indirect_thunk (int regno)
22033d
 }
22033d
 
22033d
 /* Output a funtion with a call and return thunk for indirect branch.
22033d
-   If REGNO != -1, the function address is in REGNO.  Otherwise, the
22033d
-   function address is on the top of stack.  */
22033d
+   If REGNO != UNVALID_REGNUM,
22033d
+   the function address is in REGNO.  Otherwise, the function address is
22033d
+   on the top of stack.  Thunk is used for function return if RET_P is
22033d
+   true.  */
22033d
 
22033d
 static void
22033d
-output_indirect_thunk_function (int regno)
22033d
+output_indirect_thunk_function (unsigned int regno, bool ret_p)
22033d
 {
22033d
   char name[32];
22033d
   tree decl;
22033d
 
22033d
   /* Create __x86_indirect_thunk.  */
22033d
-  indirect_thunk_name (name, regno, false);
22033d
+  indirect_thunk_name (name, regno, ret_p);
22033d
   decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
22033d
 		     get_identifier (name),
22033d
 		     build_function_type_list (void_type_node, NULL_TREE));
22033d
@@ -8953,45 +8958,6 @@ output_indirect_thunk_function (int regno)
22033d
 	ASM_OUTPUT_LABEL (asm_out_file, name);
22033d
       }
22033d
 
22033d
-  /* Create alias for __x86_return_thunk or
22033d
-     __x86_return_thunk_ecx.  */
22033d
-  bool need_alias;
22033d
-  if (regno == INVALID_REGNUM)
22033d
-    need_alias = true;
22033d
-  else if (regno == CX_REG)
22033d
-    need_alias = indirect_return_via_cx;
22033d
-  else
22033d
-    need_alias = false;
22033d
-
22033d
-  if (need_alias)
22033d
-    {
22033d
-      char alias[32];
22033d
-
22033d
-      indirect_thunk_name (alias, regno, true);
22033d
-#if TARGET_MACHO
22033d
-      if (TARGET_MACHO)
22033d
-	{
22033d
-	  fputs ("\t.weak_definition\t", asm_out_file);
22033d
-	  assemble_name (asm_out_file, alias);
22033d
-	  fputs ("\n\t.private_extern\t", asm_out_file);
22033d
-	  assemble_name (asm_out_file, alias);
22033d
-	  putc ('\n', asm_out_file);
22033d
-	  ASM_OUTPUT_LABEL (asm_out_file, alias);
22033d
-	}
22033d
-#else
22033d
-      ASM_OUTPUT_DEF (asm_out_file, alias, name);
22033d
-      if (USE_HIDDEN_LINKONCE)
22033d
-	{
22033d
-	  fputs ("\t.globl\t", asm_out_file);
22033d
-	  assemble_name (asm_out_file, alias);
22033d
-	  putc ('\n', asm_out_file);
22033d
-	  fputs ("\t.hidden\t", asm_out_file);
22033d
-	  assemble_name (asm_out_file, alias);
22033d
-	  putc ('\n', asm_out_file);
22033d
-	}
22033d
-#endif
22033d
-    }
22033d
-
22033d
   DECL_INITIAL (decl) = make_node (BLOCK);
22033d
   current_function_decl = decl;
22033d
   allocate_struct_function (decl, false);
22033d
@@ -9038,14 +9004,19 @@ ix86_code_end (void)
22033d
   rtx xops[2];
22033d
   int regno;
22033d
 
22033d
+  if (indirect_return_needed)
22033d
+    output_indirect_thunk_function (INVALID_REGNUM, true);
22033d
+  if (indirect_return_via_cx)
22033d
+    output_indirect_thunk_function (CX_REG, true);
22033d
   if (indirect_thunk_needed)
22033d
-    output_indirect_thunk_function (-1);
22033d
+    output_indirect_thunk_function (INVALID_REGNUM, false);
22033d
 
22033d
   for (regno = FIRST_REX_INT_REG; regno <= LAST_REX_INT_REG; regno++)
22033d
     {
22033d
       int i = regno - FIRST_REX_INT_REG + LAST_INT_REG + 1;
22033d
       if ((indirect_thunks_used & (1 << i)))
22033d
-	output_indirect_thunk_function (regno);
22033d
+	output_indirect_thunk_function (regno, false);
22033d
+
22033d
     }
22033d
 
22033d
   for (regno = AX_REG; regno <= SP_REG; regno++)
22033d
@@ -9054,7 +9025,7 @@ ix86_code_end (void)
22033d
       tree decl;
22033d
 
22033d
       if ((indirect_thunks_used & (1 << regno)))
22033d
-	output_indirect_thunk_function (regno);
22033d
+	output_indirect_thunk_function (regno, false);
22033d
 
22033d
       if (!(pic_labels_used & (1 << regno)))
22033d
 	continue;
22033d
@@ -24758,8 +24729,8 @@ ix86_output_function_return (bool long_p)
22033d
 	{
22033d
 	  bool need_thunk = (cfun->machine->function_return_type
22033d
 			     == indirect_branch_thunk);
22033d
-	  indirect_thunk_name (thunk_name, -1, true);
22033d
-	  indirect_thunk_needed |= need_thunk;
22033d
+	  indirect_thunk_name (thunk_name, INVALID_REGNUM, true);
22033d
+	  indirect_return_needed |= need_thunk;
22033d
 	  fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
22033d
 	}
22033d
       else
22033d
@@ -24783,8 +24754,6 @@ ix86_output_indirect_function_return (rtx ret_op)
22033d
   if (cfun->machine->function_return_type != indirect_branch_keep)
22033d
     {
22033d
       char thunk_name[32];
22033d
-      enum indirect_thunk_prefix need_prefix
22033d
-	= indirect_thunk_need_prefix (current_output_insn);
22033d
       unsigned int regno = REGNO (ret_op);
22033d
       gcc_assert (regno == CX_REG);
22033d
 
22033d
@@ -24793,7 +24762,7 @@ ix86_output_indirect_function_return (rtx ret_op)
22033d
 	{
22033d
 	  bool need_thunk = (cfun->machine->function_return_type
22033d
 			     == indirect_branch_thunk);
22033d
-	  indirect_thunk_name (thunk_name, regno, need_prefix, true);
22033d
+	  indirect_thunk_name (thunk_name, regno, true);
22033d
 	  if (need_thunk)
22033d
 	    {
22033d
 	      indirect_return_via_cx = true;
22033d
@@ -24802,7 +24771,7 @@ ix86_output_indirect_function_return (rtx ret_op)
22033d
 	  fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name);
22033d
 	}
22033d
       else
22033d
-	output_indirect_thunk (need_prefix, regno);
22033d
+	output_indirect_thunk (regno);
22033d
 
22033d
       return "";
22033d
     }
22033d
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
22033d
index d1db41cc128..a605c26c46f 100644
22033d
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
22033d
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
22033d
@@ -13,7 +13,7 @@ foo (void)
22033d
 /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */
22033d
 /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
22033d
 /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
22033d
-/* { dg-final { scan-assembler "__x86_indirect_thunk:" } } */
22033d
+/* { dg-final { scan-assembler "__x86_return_thunk:" } } */
22033d
 /* { dg-final { scan-assembler-times {\tpause} 1 { target { ! x32 } } } } */
22033d
 /* { dg-final { scan-assembler-times {\tlfence} 1 { target { ! x32 } } } } */
22033d
 /* { dg-final { scan-assembler "push(?:l|q)\[ \t\]*_?bar" { target { { ! x32 } && *-*-linux* } } } } */