diff mbox

[ARM] MI-thunk fix for TARGET_THUMB1_ONLY

Message ID 5394488D.6060806@codesourcery.com
State New
Headers show

Commit Message

Chung-Lin Tang June 8, 2014, 11:27 a.m. UTC
Hi Richard, Ramana,

Attached is a small fix for resolving a g++.old-deja/g++.jason/thunk2.C
regression we found under a TARGET_THUMB1_ONLY multilib (-mthumb
-march=armv6-m to be exact). Basically under those conditions, the thunk
is in Thumb mode, so the subtraction should be 4 rather than 8.

Original patch was by Julian, with trivial adaptations for trunk by me.
We've been carrying this fix for a while by now. Okay for trunk? (and
stable branches?)

Thanks,
Chung-Lin

2014-06-08  Julian Brown  <julian@codesourcery.com>
            Chung-Lin Tang  <cltang@codesourcery.com>

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

Comments

Ramana Radhakrishnan June 17, 2014, 10:26 p.m. UTC | #1
On Sun, Jun 8, 2014 at 12:27 PM, Chung-Lin Tang <cltang@codesourcery.com> wrote:
> Hi Richard, Ramana,
>
> Attached is a small fix for resolving a g++.old-deja/g++.jason/thunk2.C
> regression we found under a TARGET_THUMB1_ONLY multilib (-mthumb
> -march=armv6-m to be exact). Basically under those conditions, the thunk
> is in Thumb mode, so the subtraction should be 4 rather than 8.

Yep, this is OK with a minor change to the comment to make it more explicit.

>+      /* Output ".word .LTHUNKn-[37]-.LTHUNKPCn".  */

s/37/3,7/


Ok with that change and if no regressions.

OK for release branches unless the RM's object in 24 hours.

It would be nice to see if we could rewrite the mi thunk code like
other backends but that's the matter of a separate patch.

Ramana
>
> Original patch was by Julian, with trivial adaptations for trunk by me.
> We've been carrying this fix for a while by now. Okay for trunk? (and
> stable branches?)
>
> Thanks,
> Chung-Lin
>
> 2014-06-08  Julian Brown  <julian@codesourcery.com>
>             Chung-Lin Tang  <cltang@codesourcery.com>
>
>         * config/arm/arm.c (arm_output_mi_thunk): Fix offset for
>         TARGET_THUMB1_ONLY. Add comments.
Chung-Lin Tang June 20, 2014, 6:24 a.m. UTC | #2
On 2014/6/18 上午 06:26, Ramana Radhakrishnan wrote:
> On Sun, Jun 8, 2014 at 12:27 PM, Chung-Lin Tang <cltang@codesourcery.com> wrote:
>> > Hi Richard, Ramana,
>> >
>> > Attached is a small fix for resolving a g++.old-deja/g++.jason/thunk2.C
>> > regression we found under a TARGET_THUMB1_ONLY multilib (-mthumb
>> > -march=armv6-m to be exact). Basically under those conditions, the thunk
>> > is in Thumb mode, so the subtraction should be 4 rather than 8.
> Yep, this is OK with a minor change to the comment to make it more explicit.
> 
>> >+      /* Output ".word .LTHUNKn-[37]-.LTHUNKPCn".  */
> s/37/3,7/
> 
> 
> Ok with that change and if no regressions.
> 
> OK for release branches unless the RM's object in 24 hours.

Re-tested on a recent trunk, verified g++.jason/thunk2.C resolved with
patch and no regressions. Committed on trunk and backported to 4.8, 4.9
branches.

Thanks,
Chung-Lin
diff mbox

Patch

Index: config/arm/arm.c
===================================================================
--- config/arm/arm.c	(revision 211353)
+++ config/arm/arm.c	(working copy)
@@ -28428,9 +28428,13 @@  arm_output_mi_thunk (FILE *file, tree thunk ATTRIB
       fputs (":\n", file);
       if (flag_pic)
 	{
-	  /* Output ".word .LTHUNKn-7-.LTHUNKPCn".  */
+	  /* Output ".word .LTHUNKn-[37]-.LTHUNKPCn".  */
 	  rtx tem = XEXP (DECL_RTL (function), 0);
-	  tem = plus_constant (GET_MODE (tem), tem, -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 = plus_constant (GET_MODE (tem), tem,
+			       TARGET_THUMB1_ONLY ? -3 : -7);
 	  tem = gen_rtx_MINUS (GET_MODE (tem),
 			       tem,
 			       gen_rtx_SYMBOL_REF (Pmode,