public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH ARM] Fix PR60264 (ICE in dwarf2out_frame_debug_adjust_cfa)
@ 2014-02-18 15:33 Christian Bruel
  2014-02-18 15:36 ` Christian Bruel
  2014-02-19 14:49 ` [PATCH ARM] Fix PR60264 (ICE in dwarf2out_frame_debug_adjust_cfa) part 2 Christian Bruel
  0 siblings, 2 replies; 3+ messages in thread
From: Christian Bruel @ 2014-02-18 15:33 UTC (permalink / raw)
  To: gcc-patches

Hello,

Considering the attached trivial case with the epilogue:

 sub     sp, fp, #12        
 ldmia   sp, {fp, sp, lr}        frame_related_p
 
the sub instruction should also be frame_related_fp. (a gcc_assert
triggers in dwarf2out_frame_debug_adjust_cfa)

This patch sets RTX_FRAME_RELATED_P on stack restore instructions for
the -mapcs ABI.

A second problem arise with -mfloat-abi=hard, hidden by the above. a vrp
poping instruction in the epilogue (see tescase from the PR)  sets the
cfa register to IP, although the following instruction updates FP

 fldmfdd ip!, {d8}            frame_related_p
 sub     sp, fp, #12           frame_related_p
 ldmia   sp, {fp, sp, lr}    frame_related_p

This patch adds a  REG_CFA_DEF_CFA note so the sub instruction gets the
FP as expected.

Regression tested for  for armv7-a
--target_board=arm-sim/\{,-mapcs-frame\}. Fixes a large number of
compilation errors in the testsuite.

OK for trunk ?

Many Thanks






^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH ARM] Fix PR60264 (ICE in dwarf2out_frame_debug_adjust_cfa)
  2014-02-18 15:33 [PATCH ARM] Fix PR60264 (ICE in dwarf2out_frame_debug_adjust_cfa) Christian Bruel
@ 2014-02-18 15:36 ` Christian Bruel
  2014-02-19 14:49 ` [PATCH ARM] Fix PR60264 (ICE in dwarf2out_frame_debug_adjust_cfa) part 2 Christian Bruel
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Bruel @ 2014-02-18 15:36 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 50 bytes --]

probably easier to review with patch attached...


[-- Attachment #2: vrp_cfa.patch --]
[-- Type: text/x-patch, Size: 3151 bytes --]

2014-02-18  Christian Bruel  <christian.bruel@st.com>

	PR target/60264
	* config/arm/arm.c (arm_emit_vfp_multi_reg_pop): Restore cfa register.
	(arm_expand_epilogue_apcs_frame): Set RTX_FRAME_RELATED_P.

2014-02-18  Christian Bruel  <christian.bruel@st.com>

	PR target/60264
	* gcc.target/arm/pr60264.c
	* gcc.target/arm/pr60264-2.c

Index: gcc/config/arm/arm.c
===================================================================
--- gcc/config/arm/arm.c	(revision 207817)
+++ gcc/config/arm/arm.c	(working copy)
@@ -19909,8 +19909,13 @@ arm_emit_vfp_multi_reg_pop (int first_reg, int num
   par = emit_insn (par);
   REG_NOTES (par) = dwarf;
 
+  /* Make sure cfa doesn't leave with IP_REGNUM.  */
+  if (TARGET_VFP && REGNO (base_reg) == IP_REGNUM)
+    add_reg_note (par, REG_CFA_DEF_CFA, hard_frame_pointer_rtx);
+
   arm_add_cfa_adjust_cfa_note (par, 2 * UNITS_PER_WORD * num_regs,
 			       base_reg, base_reg);
+
 }
 
 /* Generate and emit a pattern that will be recognized as LDRD pattern.  If even
@@ -27103,10 +27108,12 @@ arm_expand_epilogue_apcs_frame (bool really_return
       int saved_size = arm_get_vfp_saved_size ();
       if (saved_size > 0)
         {
-          floats_from_frame += saved_size;
-          emit_insn (gen_addsi3 (gen_rtx_REG (SImode, IP_REGNUM),
-                                 hard_frame_pointer_rtx,
-                                 GEN_INT (-floats_from_frame)));
+	  rtx insn;
+	  floats_from_frame += saved_size;
+	  insn = emit_insn (gen_addsi3 (gen_rtx_REG (SImode, IP_REGNUM),
+					hard_frame_pointer_rtx,
+					GEN_INT (-floats_from_frame)));
+	  RTX_FRAME_RELATED_P (insn) = 1;
         }
 
       /* Generate VFP register multi-pop.  */
@@ -27179,11 +27186,13 @@ arm_expand_epilogue_apcs_frame (bool really_return
   num_regs = bit_count (saved_regs_mask);
   if ((offsets->outgoing_args != (1 + num_regs)) || cfun->calls_alloca)
     {
+      rtx insn;
       emit_insn (gen_blockage ());
       /* Unwind the stack to just below the saved registers.  */
-      emit_insn (gen_addsi3 (stack_pointer_rtx,
-                             hard_frame_pointer_rtx,
-                             GEN_INT (- 4 * num_regs)));
+      insn = emit_insn (gen_addsi3 (stack_pointer_rtx,
+				    hard_frame_pointer_rtx,
+				    GEN_INT (- 4 * num_regs)));
+      RTX_FRAME_RELATED_P (insn) = 1;
     }
 
   arm_emit_multi_reg_pop (saved_regs_mask);
Index: gcc/testsuite/gcc.target/arm/pr60264-2.c
===================================================================
--- gcc/testsuite/gcc.target/arm/pr60264-2.c	(revision 0)
+++ gcc/testsuite/gcc.target/arm/pr60264-2.c	(working copy)
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-mapcs -mfloat-abi=hard  -g" } */
+
+double bar(void);
+
+int foo(void)
+{
+  int i = bar() + bar();
+
+  return i;
+}
+
Index: gcc/testsuite/gcc.target/arm/pr60264.c
===================================================================
--- gcc/testsuite/gcc.target/arm/pr60264.c	(revision 0)
+++ gcc/testsuite/gcc.target/arm/pr60264.c	(working copy)
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-mapcs -g" } */
+
+void
+bar()
+{
+  foo();
+  foo();
+}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH ARM] Fix PR60264 (ICE in dwarf2out_frame_debug_adjust_cfa) part 2
  2014-02-18 15:33 [PATCH ARM] Fix PR60264 (ICE in dwarf2out_frame_debug_adjust_cfa) Christian Bruel
  2014-02-18 15:36 ` Christian Bruel
@ 2014-02-19 14:49 ` Christian Bruel
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Bruel @ 2014-02-19 14:49 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ramana Radhakrishnan

[-- Attachment #1: Type: text/plain, Size: 2706 bytes --]

Hello,

This patch is a followup of
http://gcc.gnu.org/ml/gcc-patches/2014-02/msg01042.html

If fixes a bunch of ICEs for the testsuite ran with
--target_board=arm-sim/\{-mapcs-frame\},  noticed on a reference branch
for testing the former patch.

One of the strange issue I had to deal with, for instance with
./gcc.c-torture/compile/991202-1.c,  is that the epilogue emitted the
CFA notes in the following order:

            (set/f (reg:SI 12 ip)
                (plus:SI (reg:SI 12 ip)
                    (const_int 16 [0x10])))
            (set/f (reg:DF 32 s16)
                (mem/c:DF (reg:SI 12 ip) [3  S8 A64]))
            (set/f (reg:DF 34 s18)
                (mem/c:DF (plus:SI (reg:SI 12 ip)
                        (const_int 8 [0x8])) [3  S8 A64]))
        ]) /home/bruelc/tmp/991202-1.c:18 347
{*vfp_pop_multiple_with_writeback}
     (expr_list:REG_UNUSED (reg:SI 12 ip)
        (expr_list:REG_CFA_ADJUST_CFA (set (reg:SI 12 ip)
                (plus:SI (reg:SI 12 ip)
                    (const_int 16 [0x10])))
            (expr_list:REG_CFA_DEF_CFA (reg/f:SI 11 fp)
                (expr_list:REG_CFA_RESTORE (reg:DF 34 s18)
                    (expr_list:REG_CFA_RESTORE (reg:DF 32 s16)
                        (nil)))))))

but shrink-wrapping duplicates it as

(insn/f:TI 140 137 171 (parallel [
            (set/f (reg:SI 12 ip)
                (plus:SI (reg:SI 12 ip)
                    (const_int 16 [0x10])))
            (set/f (reg:DF 32 s16)
                (mem/c:DF (reg:SI 12 ip) [3  S8 A64]))
            (set/f (reg:DF 34 s18)
                (mem/c:DF (plus:SI (reg:SI 12 ip)
                        (const_int 8 [0x8])) [3  S8 A64]))
        ]) /home/bruelc/tmp/991202-1.c:18 347
{*vfp_pop_multiple_with_writeback}
     (expr_list:REG_UNUSED (reg:SI 12 ip)
        (expr_list:REG_CFA_RESTORE (reg:DF 32 s16)
            (expr_list:REG_CFA_RESTORE (reg:DF 34 s18)
                (expr_list:REG_CFA_DEF_CFA (reg/f:SI 11 fp)
                    (expr_list:REG_CFA_ADJUST_CFA (set (reg:SI 12 ip)
                            (plus:SI (reg:SI 12 ip)
                                (const_int 16 [0x10])))
                        (nil)))))))

Since the CFA_RESTORE order is inverted with CFA_DEF_CFA, cur_cfa->reg
was set with IP instead of FP

I fixed this by not emitting the CFA_ADJUST_CFA in this case, since it's
not needed anyway as we have:

    fldmfdd    ip!, {d8-d9}    @ 140    *vfp_pop_multiple_with_writeback
    sub    sp, fp, #12    @ 142  
    ldmfd    sp, {fp, sp, pc}    @ 143   

so after @140 cur_cfa can't be IP.

Regression tested for for armv7-a
--target_board=arm-sim/\{,-mapcs-frame\}. Fixes a large number of tests

OK for trunk ?

Many thanks



[-- Attachment #2: vrp_cfa-2.patch --]
[-- Type: text/x-patch, Size: 1452 bytes --]

--- config/arm/arm.c	2014-02-19 15:28:34.000000000 +0100
+++ /work1/bruel/superh_elf/gnu_trunk.devs/gcc/gcc/config/arm/arm.c	2014-02-19 14:30:44.000000000 +0100
@@ -19911,10 +19911,14 @@
 
   /* Make sure cfa doesn't leave with IP_REGNUM.  */
   if (TARGET_VFP && REGNO (base_reg) == IP_REGNUM)
-    add_reg_note (par, REG_CFA_DEF_CFA, hard_frame_pointer_rtx);
+    {
+      RTX_FRAME_RELATED_P (par) = 1;
+      add_reg_note (par, REG_CFA_DEF_CFA, hard_frame_pointer_rtx);
+    }
+  else
+    arm_add_cfa_adjust_cfa_note (par, 2 * UNITS_PER_WORD * num_regs,
+				 base_reg, base_reg);
 
-  arm_add_cfa_adjust_cfa_note (par, 2 * UNITS_PER_WORD * num_regs,
-			       base_reg, base_reg);
 
 }
 
@@ -27109,8 +27113,8 @@
       if (saved_size > 0)
         {
 	  rtx insn;
-	  floats_from_frame += saved_size;
-	  insn = emit_insn (gen_addsi3 (gen_rtx_REG (SImode, IP_REGNUM),
+          floats_from_frame += saved_size;
+          insn = emit_insn (gen_addsi3 (gen_rtx_REG (SImode, IP_REGNUM),
 					hard_frame_pointer_rtx,
 					GEN_INT (-floats_from_frame)));
 	  RTX_FRAME_RELATED_P (insn) = 1;
@@ -27192,7 +27196,9 @@
       insn = emit_insn (gen_addsi3 (stack_pointer_rtx,
 				    hard_frame_pointer_rtx,
 				    GEN_INT (- 4 * num_regs)));
-      RTX_FRAME_RELATED_P (insn) = 1;
+
+      arm_add_cfa_adjust_cfa_note (insn, - 4 * num_regs,
+				   stack_pointer_rtx, hard_frame_pointer_rtx);
     }
 
   arm_emit_multi_reg_pop (saved_regs_mask);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-02-19 14:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-18 15:33 [PATCH ARM] Fix PR60264 (ICE in dwarf2out_frame_debug_adjust_cfa) Christian Bruel
2014-02-18 15:36 ` Christian Bruel
2014-02-19 14:49 ` [PATCH ARM] Fix PR60264 (ICE in dwarf2out_frame_debug_adjust_cfa) part 2 Christian Bruel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).