diff mbox

ARMv6-M MI thunk fix

Message ID 51B0AE22.2070209@codesourcery.com
State New
Headers show

Commit Message

Cesar Philippidis June 6, 2013, 3:43 p.m. UTC
This patch addresses the following FAILs on armv6-m:

  FAIL: g++.sum:g++.old-deja/g++.jason/thunk2.C -std=gnu++11 execution test
  FAIL: g++.sum:g++.old-deja/g++.jason/thunk2.C -std=gnu++98 execution test

The source of the problem is the use of ARM thunk offsets for Thumb1. 
This test is using multiple inheritance, and that triggered the
problem. 

I tested this patch with the default ARM and THUMB multilibs in 
additional to -march=armv6-m.

OK for trunk?

Cesar


2013-06-06  Julian Brown  <julian@codesourcery.com>
	    Cesar Philippidis  <cesar@codesourcery.com>

	gcc/
	* config/arm/arm.c (arm_output_mi_thunk): Fix offset for
	TARGET_THUMB1_ONLY.

Comments

Richard Earnshaw June 6, 2013, 4 p.m. UTC | #1
On 06/06/13 16:43, Cesar Philippidis wrote:
> This patch addresses the following FAILs on armv6-m:
>
>    FAIL: g++.sum:g++.old-deja/g++.jason/thunk2.C -std=gnu++11 execution test
>    FAIL: g++.sum:g++.old-deja/g++.jason/thunk2.C -std=gnu++98 execution test
>
> The source of the problem is the use of ARM thunk offsets for Thumb1.
> This test is using multiple inheritance, and that triggered the
> problem.
>
> I tested this patch with the default ARM and THUMB multilibs in
> additional to -march=armv6-m.
>
> OK for trunk?
>
> Cesar
>
>
> 2013-06-06  Julian Brown  <julian@codesourcery.com>
> 	    Cesar Philippidis  <cesar@codesourcery.com>
>
> 	gcc/
> 	* config/arm/arm.c (arm_output_mi_thunk): Fix offset for
> 	TARGET_THUMB1_ONLY.
>
>
> ARM-fix-mi-thunks-TARGET_THUMB1_ONLY.patch
>
>
> Index: gcc/config/arm/arm.c
> ===================================================================
> --- gcc/config/arm/arm.c	(revision 405523)
> +++ gcc/config/arm/arm.c	(revision 405524)
> @@ -23140,7 +23140,11 @@
>   	{
>   	  /* Output ".word .LTHUNKn-7-.LTHUNKPCn".  */
>   	  rtx tem = XEXP (DECL_RTL (function), 0);
> -	  tem = gen_rtx_PLUS (GET_MODE (tem), tem, GEN_INT (-7));
> +	  /* For TARGET_THUMB1_ONLY the thunk is in Thumb mode, so the PC
> +	     pipeline offset is four rather than eight.  Adjust the offset
> +	     accordingly.  */
> +	  tem = gen_rtx_PLUS (GET_MODE (tem), tem,
> +			      GEN_INT (TARGET_THUMB1_ONLY ? -3 : -7));
>   	  tem = gen_rtx_MINUS (GET_MODE (tem),
>   			       tem,
>   			       gen_rtx_SYMBOL_REF (Pmode,
>

The pipeline offset is 4 for Thumb2 as well.  So at the very least you 
need to explain why your change doesn't apply then as well.

R.
diff mbox

Patch

Index: gcc/config/arm/arm.c
===================================================================
--- gcc/config/arm/arm.c	(revision 405523)
+++ gcc/config/arm/arm.c	(revision 405524)
@@ -23140,7 +23140,11 @@ 
 	{
 	  /* Output ".word .LTHUNKn-7-.LTHUNKPCn".  */
 	  rtx tem = XEXP (DECL_RTL (function), 0);
-	  tem = gen_rtx_PLUS (GET_MODE (tem), tem, GEN_INT (-7));
+	  /* For TARGET_THUMB1_ONLY the thunk is in Thumb mode, so the PC
+	     pipeline offset is four rather than eight.  Adjust the offset
+	     accordingly.  */
+	  tem = gen_rtx_PLUS (GET_MODE (tem), tem,
+			      GEN_INT (TARGET_THUMB1_ONLY ? -3 : -7));
 	  tem = gen_rtx_MINUS (GET_MODE (tem),
 			       tem,
 			       gen_rtx_SYMBOL_REF (Pmode,