Fix line number data for PIC register setup code.
authorvries <vries@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 27 Oct 2013 23:36:51 +0000 (23:36 +0000)
committervries <vries@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 27 Oct 2013 23:36:51 +0000 (23:36 +0000)
2013-10-27  Tom de Vries  <tom@codesourcery.com>

* cfgexpand.c (gimple_expand_cfg): Remove test for parm_birth_insn.
Don't commit insertions after NOTE_INSN_FUNCTION_BEG.

* gcc.target/arm/require-pic-register-loc.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204112 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cfgexpand.c
gcc/testsuite/ChangeLog
testsuite/gcc.target/arm/require-pic-register-loc.c [new file with mode: 0644]

index f4ad221..8d6147a 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-27  Tom de Vries  <tom@codesourcery.com>
+
+       * cfgexpand.c (gimple_expand_cfg): Remove test for parm_birth_insn.
+       Don't commit insertions after NOTE_INSN_FUNCTION_BEG.
+
 2013-10-27  Oleg Endo  <olegendo@gcc.gnu.org>
 
        * config/sh/sh.c (MSW, LSW): Move and rename macros to...
index ba4c0e6..9705036 100644 (file)
@@ -4789,14 +4789,18 @@ gimple_expand_cfg (void)
          if (e->insns.r)
            {
              rebuild_jump_labels_chain (e->insns.r);
-             /* Avoid putting insns before parm_birth_insn.  */
+             /* Put insns after parm birth, but before
+                NOTE_INSNS_FUNCTION_BEG.  */
              if (e->src == ENTRY_BLOCK_PTR
-                 && single_succ_p (ENTRY_BLOCK_PTR)
-                 && parm_birth_insn)
+                 && single_succ_p (ENTRY_BLOCK_PTR))
                {
                  rtx insns = e->insns.r;
                  e->insns.r = NULL_RTX;
-                 emit_insn_after_noloc (insns, parm_birth_insn, e->dest);
+                 if (NOTE_P (parm_birth_insn)
+                     && NOTE_KIND (parm_birth_insn) == NOTE_INSN_FUNCTION_BEG)
+                   emit_insn_before_noloc (insns, parm_birth_insn, e->dest);
+                 else
+                   emit_insn_after_noloc (insns, parm_birth_insn, e->dest);
                }
              else
                commit_one_edge_insertion (e);
index b3e5dc4..12028b4 100644 (file)
@@ -1,3 +1,7 @@
+2013-10-27  Tom de Vries  <tom@codesourcery.com>
+
+       * gcc.target/arm/require-pic-register-loc.c: New test.
+
 2013-10-27  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/58679
diff --git a/testsuite/gcc.target/arm/require-pic-register-loc.c b/testsuite/gcc.target/arm/require-pic-register-loc.c
new file mode 100644 (file)
index 0000000..bd85e86
--- /dev/null
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-g -fPIC" } */
+
+void *v;
+void a (void *x) { }
+void b (void) { }
+                       /* line 7.  */
+int                    /* line 8.  */
+main (int argc)        /* line 9.  */
+{                      /* line 10.  */
+  if (argc == 12345)   /* line 11.  */
+    {
+      a (v);
+      return 1;
+    }
+  b ();
+
+  return 0;
+}
+
+/* { dg-final { scan-assembler-not "\.loc 1 7 0" } } */
+/* { dg-final { scan-assembler-not "\.loc 1 8 0" } } */
+/* { dg-final { scan-assembler-not "\.loc 1 9 0" } } */
+
+/* The loc at the start of the prologue.  */
+/* { dg-final { scan-assembler-times "\.loc 1 10 0" 1 } } */
+
+/* The loc at the end of the prologue, with the first user line.  */
+/* { dg-final { scan-assembler-times "\.loc 1 11 0" 1 } } */