[PATCH] Fix PR bootstrap/11297

Jakub Jelinek jakub@redhat.com
Fri Jun 27 09:00:00 GMT 2003


Hi!

No idea why is current rs6000_output_mi_thunk clearing SYMBOL_FLAG_LOCAL.
Certainly the code before 2003-01-08 rewrite used to emit b .LTHUNK0@local
if function binds locally, now it does not.
The following patch fixes that and also, given that rs6000_output_mi_thunk
does not run combiner and other optimizations on the generated rtl tries
to optimize vcall_offset handling.
Say -fno-pic -m32 thunk looks like:
        lwz 9,0(3)
        lwz 0,-12(9)
        add 3,3,0
        b .LTHUNK0
on gcc-3_3-rhl-branch while:
        lwz 12,0(3)
        addi 12,12,-12
        lwz 12,0(12)
        add 3,3,12
        b .LTHUNK0
on current trunk.
Tested on a testcase with virtual thunks with
{-m32,-m64} {-fno-pic,-fpic,-fPIC}.
Ok to commit?

2003-06-27  Jakub Jelinek  <jakub@redhat.com>

	* config/rs6000/rs6000.c (rs6000_output_mi_thunk): Remove bogus
	clearing of SYMBOL_FLAG_LOCAL bit.
	If vcall_offset fits into signed 16-bit immediate, use
	one instruction for both addition and load.

--- gcc/config/rs6000/rs6000.c.jj	2003-06-21 05:09:31.000000000 -0400
+++ gcc/config/rs6000/rs6000.c	2003-06-27 04:38:25.000000000 -0400
@@ -12279,10 +12279,19 @@ rs6000_output_mi_thunk (file, thunk_fnde
       rtx tmp = gen_rtx_REG (Pmode, 12);
 
       emit_move_insn (tmp, gen_rtx_MEM (Pmode, this));
-      emit_insn (TARGET_32BIT
-		 ? gen_addsi3 (tmp, tmp, vcall_offset_rtx)
-		 : gen_adddi3 (tmp, tmp, vcall_offset_rtx));
-      emit_move_insn (tmp, gen_rtx_MEM (Pmode, tmp));
+      if (((unsigned HOST_WIDE_INT) vcall_offset) + 0x8000 >= 0x10000)
+	{
+	  emit_insn (TARGET_32BIT
+		     ? gen_addsi3 (tmp, tmp, vcall_offset_rtx)
+		     : gen_adddi3 (tmp, tmp, vcall_offset_rtx));
+	  emit_move_insn (tmp, gen_rtx_MEM (Pmode, tmp));
+	}
+      else
+	{
+	  rtx loc = gen_rtx_PLUS (Pmode, tmp, vcall_offset_rtx);
+
+	  emit_move_insn (tmp, gen_rtx_MEM (Pmode, loc));
+	}
       emit_insn (TARGET_32BIT
 		 ? gen_addsi3 (this, this, tmp)
 		 : gen_adddi3 (this, this, tmp));
@@ -12295,7 +12304,6 @@ rs6000_output_mi_thunk (file, thunk_fnde
       TREE_USED (function) = 1;
     }
   funexp = XEXP (DECL_RTL (function), 0);
-  SYMBOL_REF_FLAGS (funexp) &= ~SYMBOL_FLAG_LOCAL;
   funexp = gen_rtx_MEM (FUNCTION_MODE, funexp);
 
 #if TARGET_MACHO

	Jakub



More information about the Gcc-patches mailing list