[-fcompare-debug] retain insn locations when turning dbr seq into return
authorAlexandre Oliva <aoliva@redhat.com>
Thu, 21 Dec 2017 18:14:21 +0000 (18:14 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Thu, 21 Dec 2017 18:14:21 +0000 (18:14 +0000)
A number of -fcompare-debug errors on sparc arise as we split a dbr
SEQUENCE back into separate insns to turn the branch into a return.
If we just take the location from the PREV_INSN, it might be a debug
insn without INSN_LOCATION, or an insn with an unrelated location.
But that's silly: each of the SEQUENCEd insns is still an insn with
its own INSN_LOCATION, so use that instead, even though some may have
been adjusted while constructing the SEQUENCE.

for  gcc/ChangeLog

* reorg.c (make_return_insns): Reemit each insn with its own
location.

From-SVN: r255948

gcc/ChangeLog
gcc/reorg.c

index 2851eb6..7200561 100644 (file)
@@ -1,5 +1,10 @@
 2017-12-21  Alexandre Oliva <aoliva@redhat.com>
 
+       * reorg.c (make_return_insns): Reemit each insn with its own
+       location.
+
+2017-12-21  Alexandre Oliva <aoliva@redhat.com>
+
        PR debug/83419
        * c-family/c-semantics.c (pop_stmt_list): Propagate side
        effects from single nondebug stmt to container list.
index 96778ad..02d8adc 100644 (file)
@@ -3612,9 +3612,14 @@ make_return_insns (rtx_insn *first)
 
          delete_related_insns (insn);
          for (i = 1; i < XVECLEN (pat, 0); i++)
-           prev = emit_insn_after (PATTERN (XVECEXP (pat, 0, i)), prev);
+           {
+             rtx_insn *in_seq_insn = as_a<rtx_insn *> (XVECEXP (pat, 0, i));
+             prev = emit_insn_after_setloc (PATTERN (in_seq_insn), prev,
+                                            INSN_LOCATION (in_seq_insn));
+           }
 
-         insn = emit_jump_insn_after (PATTERN (jump_insn), prev);
+         insn = emit_jump_insn_after_setloc (PATTERN (jump_insn), prev,
+                                             INSN_LOCATION (jump_insn));
          emit_barrier_after (insn);
 
          if (slots)