This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Bug debug/13974] [3.4/3.5 regression] bad line marker in debug info


> 
> ------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-03-11 05:07 -------
> Jan, please let me know what is going on with this bug.

Hi,
I still tend to think in favour of explicitly setting locators for places where
we know we are splitting single instruction into multiple ones in some way.  It
seems to me that in most cases optimizers insert new instructions that are not
explicitly attached to statements assigned to surrounding instrucitons.
however I am not thrilled about it and the other way around may work well in
most cases.

The attached patch fix the testcase by similar way as we fixed reload
previously.  The other way is to make emit_insn_after behave as
emit_insn_after_sameloc but I think it is more intrussive.  Sorry for taking my
time.  The patch has failed for misterous reasons and it took me a while to
realize that it is the side effect of macro argument being evaulated multiple
times, so I also moved everything offline.

Bootstrapped/regtested ppc-linux.  Ok for mainline/branch 

2004-03-13  Jan Hubicka  <jh@suse.cz>
	* emit-rtl.c (emit_insn_after_sameloc, emit_jump_insn_after_sameloc,
	emit_call_insn_after_sameloc, emit_insn_before_sameloc): New functions.
	* function.c (fixup_var_refs_insn): Set locators correctly.
	(fixup_var_refs_1): Likewise.
	(fixup_memory_subreg): Likewise.
	(fixup_stack_1): Likewise.
	(optimize-bit_filed): Likewise.
	(purge_addressof_1): Likewise.
	* emit-rtl.c (emit_insn_after_sameloc, emit_jump_insn_after_sameloc,
	emit_call_insn_after_sameloc, emit_insn_before_sameloc): Turn into
	function.
Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v
retrieving revision 1.383
diff -c -3 -p -r1.383 emit-rtl.c
*** emit-rtl.c	6 Mar 2004 01:21:26 -0000	1.383
--- emit-rtl.c	13 Mar 2004 15:44:26 -0000
*************** emit_insn_after_setloc (rtx pattern, rtx
*** 4363,4368 ****
--- 4363,4378 ----
    return last;
  }
  
+ /* Like emit_insn_after, but set INSN_LOCATOR according to INSN.  */
+ rtx
+ emit_insn_after_sameloc (rtx pattern, rtx after)
+ {
+   if (INSN_P (after))
+     return emit_insn_after_setloc (pattern, after, INSN_LOCATOR (after));
+   else
+     return emit_insn_after (pattern, after);
+ }
+ 
  /* Like emit_jump_insn_after, but set INSN_LOCATOR according to SCOPE.  */
  rtx
  emit_jump_insn_after_setloc (rtx pattern, rtx after, int loc)
*************** emit_jump_insn_after_setloc (rtx pattern
*** 4384,4389 ****
--- 4394,4409 ----
    return last;
  }
  
+ /* Like emit_jump_insn_after, but set INSN_LOCATOR according to INSN.  */
+ rtx
+ emit_jump_insn_after_sameloc (rtx pattern, rtx after)
+ {
+   if (INSN_P (after))
+     return emit_jump_insn_after_setloc (pattern, after, INSN_LOCATOR (after));
+   else
+     return emit_jump_insn_after (pattern, after);
+ }
+ 
  /* Like emit_call_insn_after, but set INSN_LOCATOR according to SCOPE.  */
  rtx
  emit_call_insn_after_setloc (rtx pattern, rtx after, int loc)
*************** emit_call_insn_after_setloc (rtx pattern
*** 4405,4410 ****
--- 4425,4440 ----
    return last;
  }
  
+ /* Like emit_call_insn_after, but set INSN_LOCATOR according to INSN.  */
+ rtx
+ emit_call_insn_after_sameloc (rtx pattern, rtx after)
+ {
+   if (INSN_P (after))
+     return emit_call_insn_after_setloc (pattern, after, INSN_LOCATOR (after));
+   else
+     return emit_call_insn_after (pattern, after);
+ }
+ 
  /* Like emit_insn_before, but set INSN_LOCATOR according to SCOPE.  */
  rtx
  emit_insn_before_setloc (rtx pattern, rtx before, int loc)
*************** emit_insn_before_setloc (rtx pattern, rt
*** 4425,4430 ****
--- 4455,4470 ----
        first = NEXT_INSN (first);
      }
    return last;
+ }
+ 
+ /* Like emit_insn_before, but set INSN_LOCATOR according to INSN.  */
+ rtx
+ emit_insn_before_sameloc (rtx pattern, rtx before)
+ {
+   if (INSN_P (before))
+     return emit_insn_before_setloc (pattern, before, INSN_LOCATOR (before));
+   else
+     return emit_insn_before (pattern, before);
  }
  
  /* Take X and emit it at the end of the doubly-linked
Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.504
diff -c -3 -p -r1.504 function.c
*** function.c	12 Mar 2004 10:03:27 -0000	1.504
--- function.c	13 Mar 2004 15:44:27 -0000
*************** fixup_var_refs_insn (rtx insn, rtx var, 
*** 1735,1741 ****
  	    {
  	      rtx temp = gen_reg_rtx (GET_MODE (call_dest));
  
! 	      emit_insn_before (gen_move_insn (temp, call_dest), insn);
  
  	      PATTERN (insn) = replace_rtx (PATTERN (insn),
  					    call_dest, temp);
--- 1735,1741 ----
  	    {
  	      rtx temp = gen_reg_rtx (GET_MODE (call_dest));
  
! 	      emit_insn_before_sameloc (gen_move_insn (temp, call_dest), insn);
  
  	      PATTERN (insn) = replace_rtx (PATTERN (insn),
  					    call_dest, temp);
*************** fixup_var_refs_insn (rtx insn, rtx var, 
*** 1809,1815 ****
  		seq = gen_move_insn (replacements->new,
  				     replacements->old);
  
! 	      emit_insn_before (seq, insert_before);
  	    }
  
  	  next = replacements->next;
--- 1809,1815 ----
  		seq = gen_move_insn (replacements->new,
  				     replacements->old);
  
! 	      emit_insn_before_sameloc (seq, insert_before);
  	    }
  
  	  next = replacements->next;
*************** fixup_var_refs_1 (rtx var, enum machine_
*** 1900,1906 ****
  		insn = PREV_INSN (insn);
  #endif
  
! 	      emit_insn_before (seq, insn);
  	    }
  	}
        return;
--- 1900,1906 ----
  		insn = PREV_INSN (insn);
  #endif
  
! 	      emit_insn_before_sameloc (seq, insn);
  	    }
  	}
        return;
*************** fixup_var_refs_1 (rtx var, enum machine_
*** 2061,2067 ****
  	     reference.  Copy the input into a register.  */
  
  	  tem1 = gen_reg_rtx (GET_MODE (tem));
! 	  emit_insn_before (gen_move_insn (tem1, tem), insn);
  	  XEXP (x, 0) = tem1;
  	  return;
  	}
--- 2061,2067 ----
  	     reference.  Copy the input into a register.  */
  
  	  tem1 = gen_reg_rtx (GET_MODE (tem));
! 	  emit_insn_before_sameloc (gen_move_insn (tem1, tem), insn);
  	  XEXP (x, 0) = tem1;
  	  return;
  	}
*************** fixup_var_refs_1 (rtx var, enum machine_
*** 2157,2163 ****
  	    replacement->new = gen_reg_rtx (GET_MODE (var));
  
  	  SUBREG_REG (XEXP (SET_DEST (x), 0)) = replacement->new;
! 	  emit_insn_after (gen_move_insn (var, replacement->new), insn);
  	}
  
        /* If SET_DEST is now a paradoxical SUBREG, put the result of this
--- 2157,2163 ----
  	    replacement->new = gen_reg_rtx (GET_MODE (var));
  
  	  SUBREG_REG (XEXP (SET_DEST (x), 0)) = replacement->new;
! 	  emit_insn_after_sameloc (gen_move_insn (var, replacement->new), insn);
  	}
  
        /* If SET_DEST is now a paradoxical SUBREG, put the result of this
*************** fixup_var_refs_1 (rtx var, enum machine_
*** 2168,2176 ****
  	      > GET_MODE_SIZE (GET_MODE (var))))
  	{
  	  SET_DEST (x) = tem = gen_reg_rtx (GET_MODE (SET_DEST (x)));
! 	  emit_insn_after (gen_move_insn (var, gen_lowpart (GET_MODE (var),
! 							    tem)),
! 			   insn);
  	  break;
  	}
  
--- 2168,2176 ----
  	      > GET_MODE_SIZE (GET_MODE (var))))
  	{
  	  SET_DEST (x) = tem = gen_reg_rtx (GET_MODE (SET_DEST (x)));
! 	  emit_insn_after_sameloc (gen_move_insn (var, gen_lowpart (GET_MODE (var),
! 							           tem)),
! 				   insn);
  	  break;
  	}
  
*************** fixup_var_refs_1 (rtx var, enum machine_
*** 2264,2271 ****
  	       a register, do the store, and put it back into memory.  */
  
  	    tem1 = gen_reg_rtx (GET_MODE (tem));
! 	    emit_insn_before (gen_move_insn (tem1, tem), insn);
! 	    emit_insn_after (gen_move_insn (tem, tem1), insn);
  	    XEXP (outerdest, 0) = tem1;
  	    return;
  	  }
--- 2264,2271 ----
  	       a register, do the store, and put it back into memory.  */
  
  	    tem1 = gen_reg_rtx (GET_MODE (tem));
! 	    emit_insn_before_sameloc (gen_move_insn (tem1, tem), insn);
! 	    emit_insn_after_sameloc (gen_move_insn (tem, tem1), insn);
  	    XEXP (outerdest, 0) = tem1;
  	    return;
  	  }
*************** fixup_var_refs_1 (rtx var, enum machine_
*** 2338,2344 ****
  	    pat = gen_move_insn (SET_DEST (x), SET_SRC (x));
  	    if (NEXT_INSN (pat) != NULL_RTX)
  	      {
! 		last = emit_insn_before (pat, insn);
  
  		/* INSN might have REG_RETVAL or other important notes, so
  		   we need to store the pattern of the last insn in the
--- 2338,2344 ----
  	    pat = gen_move_insn (SET_DEST (x), SET_SRC (x));
  	    if (NEXT_INSN (pat) != NULL_RTX)
  	      {
! 		last = emit_insn_before_sameloc (pat, insn);
  
  		/* INSN might have REG_RETVAL or other important notes, so
  		   we need to store the pattern of the last insn in the
*************** fixup_var_refs_1 (rtx var, enum machine_
*** 2382,2388 ****
  	    pat = gen_move_insn (SET_DEST (x), SET_SRC (x));
  	    if (NEXT_INSN (pat) != NULL_RTX)
  	      {
! 		last = emit_insn_before (pat, insn);
  
  		/* INSN might have REG_RETVAL or other important notes, so
  		   we need to store the pattern of the last insn in the
--- 2382,2388 ----
  	    pat = gen_move_insn (SET_DEST (x), SET_SRC (x));
  	    if (NEXT_INSN (pat) != NULL_RTX)
  	      {
! 		last = emit_insn_before_sameloc (pat, insn);
  
  		/* INSN might have REG_RETVAL or other important notes, so
  		   we need to store the pattern of the last insn in the
*************** fixup_var_refs_1 (rtx var, enum machine_
*** 2437,2446 ****
  
  	    temp = gen_reg_rtx (temp_mode);
  
! 	    emit_insn_after (gen_move_insn (fixeddest,
! 					    gen_lowpart (GET_MODE (fixeddest),
! 							 temp)),
! 			     insn);
  
  	    SET_DEST (x) = temp;
  	  }
--- 2437,2446 ----
  
  	    temp = gen_reg_rtx (temp_mode);
  
! 	    emit_insn_after_sameloc
! 		   (gen_move_insn (fixeddest, gen_lowpart (GET_MODE (fixeddest),
! 							   temp)),
! 		    insn);
  
  	    SET_DEST (x) = temp;
  	  }
*************** fixup_memory_subreg (rtx x, rtx insn, en
*** 2508,2514 ****
    seq = get_insns ();
    end_sequence ();
  
!   emit_insn_before (seq, insn);
    return result;
  }
  
--- 2508,2514 ----
    seq = get_insns ();
    end_sequence ();
  
!   emit_insn_before_sameloc (seq, insn);
    return result;
  }
  
*************** fixup_stack_1 (rtx x, rtx insn)
*** 2595,2601 ****
  	  temp = copy_to_reg (ad);
  	  seq = get_insns ();
  	  end_sequence ();
! 	  emit_insn_before (seq, insn);
  	  return replace_equiv_address (x, temp);
  	}
        return x;
--- 2595,2601 ----
  	  temp = copy_to_reg (ad);
  	  seq = get_insns ();
  	  end_sequence ();
! 	  emit_insn_before_sameloc (seq, insn);
  	  return replace_equiv_address (x, temp);
  	}
        return x;
*************** optimize_bit_field (rtx body, rtx insn, 
*** 2701,2707 ****
  	  memref = adjust_address (memref, mode, offset);
  	  insns = get_insns ();
  	  end_sequence ();
! 	  emit_insn_before (insns, insn);
  
  	  /* Store this memory reference where
  	     we found the bit field reference.  */
--- 2701,2707 ----
  	  memref = adjust_address (memref, mode, offset);
  	  insns = get_insns ();
  	  end_sequence ();
! 	  emit_insn_before_sameloc (insns, insn);
  
  	  /* Store this memory reference where
  	     we found the bit field reference.  */
*************** optimize_bit_field (rtx body, rtx insn, 
*** 2769,2775 ****
  	     special; just let the optimization be suppressed.  */
  
  	  if (apply_change_group () && seq)
! 	    emit_insn_before (seq, insn);
  	}
      }
  }
--- 2769,2775 ----
  	     special; just let the optimization be suppressed.  */
  
  	  if (apply_change_group () && seq)
! 	    emit_insn_before_sameloc (seq, insn);
  	}
      }
  }
*************** purge_addressof_1 (rtx *loc, rtx insn, i
*** 3023,3029 ****
  
        insns = get_insns ();
        end_sequence ();
!       emit_insn_before (insns, insn);
        return true;
      }
  
--- 3023,3029 ----
  
        insns = get_insns ();
        end_sequence ();
!       emit_insn_before_sameloc (insns, insn);
        return true;
      }
  
*************** purge_addressof_1 (rtx *loc, rtx insn, i
*** 3178,3184 ****
  		    }
  		  seq = get_insns ();
  		  end_sequence ();
! 		  emit_insn_before (seq, insn);
  		  compute_insns_for_mem (p ? NEXT_INSN (p) : get_insns (),
  					 insn, ht);
  
--- 3178,3184 ----
  		    }
  		  seq = get_insns ();
  		  end_sequence ();
! 		  emit_insn_before_sameloc (seq, insn);
  		  compute_insns_for_mem (p ? NEXT_INSN (p) : get_insns (),
  					 insn, ht);
  
*************** purge_addressof_1 (rtx *loc, rtx insn, i
*** 3192,3198 ****
  
  		  seq = get_insns ();
  		  end_sequence ();
! 		  p = emit_insn_after (seq, insn);
  		  if (NEXT_INSN (insn))
  		    compute_insns_for_mem (NEXT_INSN (insn),
  					   p ? NEXT_INSN (p) : NULL_RTX,
--- 3192,3198 ----
  
  		  seq = get_insns ();
  		  end_sequence ();
! 		  p = emit_insn_after_sameloc (seq, insn);
  		  if (NEXT_INSN (insn))
  		    compute_insns_for_mem (NEXT_INSN (insn),
  					   p ? NEXT_INSN (p) : NULL_RTX,
*************** purge_addressof_1 (rtx *loc, rtx insn, i
*** 3217,3223 ****
  
  		  seq = get_insns ();
  		  end_sequence ();
! 		  emit_insn_before (seq, insn);
  		  compute_insns_for_mem (p ? NEXT_INSN (p) : get_insns (),
  					 insn, ht);
  		}
--- 3217,3223 ----
  
  		  seq = get_insns ();
  		  end_sequence ();
! 		  emit_insn_before_sameloc (seq, insn);
  		  compute_insns_for_mem (p ? NEXT_INSN (p) : get_insns (),
  					 insn, ht);
  		}
*************** instantiate_virtual_regs_1 (rtx *loc, rt
*** 3839,3845 ****
  	  seq = get_insns ();
  	  end_sequence ();
  
! 	  emit_insn_before (seq, object);
  	  SET_DEST (x) = new;
  
  	  if (! validate_change (object, &SET_SRC (x), temp, 0)
--- 3839,3845 ----
  	  seq = get_insns ();
  	  end_sequence ();
  
! 	  emit_insn_before_sameloc (seq, object);
  	  SET_DEST (x) = new;
  
  	  if (! validate_change (object, &SET_SRC (x), temp, 0)
*************** instantiate_virtual_regs_1 (rtx *loc, rt
*** 3937,3943 ****
  	      temp = gen_reg_rtx (Pmode);
  	      XEXP (x, 0) = new;
  	      if (validate_change (object, &XEXP (x, 1), temp, 0))
! 		emit_insn_before (gen_move_insn (temp, new_offset), object);
  	      else
  		{
  		  /* If that didn't work, replace this expression with a
--- 3937,3943 ----
  	      temp = gen_reg_rtx (Pmode);
  	      XEXP (x, 0) = new;
  	      if (validate_change (object, &XEXP (x, 1), temp, 0))
! 		emit_insn_before_sameloc (gen_move_insn (temp, new_offset), object);
  	      else
  		{
  		  /* If that didn't work, replace this expression with a
*************** instantiate_virtual_regs_1 (rtx *loc, rt
*** 3951,3957 ****
  		  seq = get_insns ();
  		  end_sequence ();
  
! 		  emit_insn_before (seq, object);
  		  if (! validate_change (object, loc, temp, 0)
  		      && ! validate_replace_rtx (x, temp, object))
  		    {
--- 3951,3957 ----
  		  seq = get_insns ();
  		  end_sequence ();
  
! 		  emit_insn_before_sameloc (seq, object);
  		  if (! validate_change (object, loc, temp, 0)
  		      && ! validate_replace_rtx (x, temp, object))
  		    {
*************** instantiate_virtual_regs_1 (rtx *loc, rt
*** 4110,4116 ****
  	      seq = get_insns ();
  	      end_sequence ();
  
! 	      emit_insn_before (seq, object);
  	      if (! validate_change (object, loc, temp, 0)
  		  && ! validate_replace_rtx (x, temp, object))
  	        instantiate_virtual_regs_lossage (object);
--- 4110,4116 ----
  	      seq = get_insns ();
  	      end_sequence ();
  
! 	      emit_insn_before_sameloc (seq, object);
  	      if (! validate_change (object, loc, temp, 0)
  		  && ! validate_replace_rtx (x, temp, object))
  	        instantiate_virtual_regs_lossage (object);
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.465
diff -c -3 -p -r1.465 rtl.h
*** rtl.h	9 Mar 2004 17:06:21 -0000	1.465
--- rtl.h	13 Mar 2004 15:44:27 -0000
*************** extern rtx assign_temp (tree, int, int, 
*** 1653,1671 ****
--- 1653,1677 ----
  /* In emit-rtl.c */
  extern rtx emit_insn_before (rtx, rtx);
  extern rtx emit_insn_before_setloc (rtx, rtx, int);
+ extern rtx emit_insn_before_sameloc (rtx, rtx);
  extern rtx emit_jump_insn_before (rtx, rtx);
  extern rtx emit_jump_insn_before_setloc (rtx, rtx, int);
+ extern rtx emit_jump_insn_before_sameloc (rtx, rtx);
  extern rtx emit_call_insn_before (rtx, rtx);
  extern rtx emit_call_insn_before_setloc (rtx, rtx, int);
+ extern rtx emit_call_insn_before_sameloc (rtx, rtx);
  extern rtx emit_barrier_before (rtx);
  extern rtx emit_label_before (rtx, rtx);
  extern rtx emit_note_before (int, rtx);
  extern rtx emit_insn_after (rtx, rtx);
  extern rtx emit_insn_after_setloc (rtx, rtx, int);
+ extern rtx emit_insn_after_sameloc (rtx, rtx);
  extern rtx emit_jump_insn_after (rtx, rtx);
  extern rtx emit_jump_insn_after_setloc (rtx, rtx, int);
+ extern rtx emit_jump_insn_after_sameloc (rtx, rtx);
  extern rtx emit_call_insn_after (rtx, rtx);
  extern rtx emit_call_insn_after_setloc (rtx, rtx, int);
+ extern rtx emit_call_insn_after_sameloc (rtx, rtx);
  extern rtx emit_barrier_after (rtx);
  extern rtx emit_label_after (rtx, rtx);
  extern rtx emit_note_after (int, rtx);
*************** extern rtx prev_label (rtx);
*** 1694,1712 ****
  extern rtx next_label (rtx);
  extern rtx next_cc0_user (rtx);
  extern rtx prev_cc0_setter (rtx);
- 
- #define emit_insn_before_sameloc(INSN, BEFORE) \
-   emit_insn_before_setloc (INSN, BEFORE, INSN_LOCATOR (BEFORE))
- #define emit_jump_insn_before_sameloc(INSN, BEFORE) \
-   emit_jump_insn_before_setloc (INSN, BEFORE, INSN_LOCATOR (BEFORE))
- #define emit_call_insn_before_sameloc(INSN, BEFORE) \
-   emit_call_insn_before_setloc (INSN, BEFORE, INSN_LOCATOR (BEFORE))
- #define emit_insn_after_sameloc(INSN, AFTER) \
-   emit_insn_after_setloc (INSN, AFTER, INSN_LOCATOR (AFTER))
- #define emit_jump_insn_after_sameloc(INSN, AFTER) \
-   emit_jump_insn_after_setloc (INSN, AFTER, INSN_LOCATOR (AFTER))
- #define emit_call_insn_after_sameloc(INSN, AFTER) \
-   emit_call_insn_after_setloc (INSN, AFTER, INSN_LOCATOR (AFTER))
  
  /* In cfglayout.c  */
  extern tree choose_inner_scope (tree, tree);
--- 1700,1705 ----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]