Blame SOURCES/gcc48-rh1537828-8.patch

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