This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] var-tracking: Fix negative location ranges
- From: "Andreas Krebbel" <krebbel at linux dot vnet dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 14 Oct 2010 09:38:02 +0200
- Subject: [PATCH] var-tracking: Fix negative location ranges
Hi,
the attached patch fixes a problem with negative location ranges
generated in var tracking.
Here the description of the problem from the bugzilla:
When compiling the testcase with -O2 -g a negative location range for a
variable is generated:
00000371 0000000000000174 0000000000000176 (DW_OP_breg10: 4)
00000371 0000000000000176 0000000000000175 (DW_OP_fbreg: -412) [without
DW_AT_frame_base] (start > end)
.8byte .LVL20-.Ltext0 # Location list begin address (*.LLST13)
.8byte .LVL20-1-.Ltext0 # Location list end address (*.LLST13)
.2byte 0x3 # Location expression size
.byte 0x91 # DW_OP_fbreg
The problem seem to arise from call related var_location note to be mixed with
non call related. 209r.vartrack:
(call_insn 150 580 583 20 wrongvainfo.c:31 (parallel [
(call (mem:QI (reg/v/f:DI 6 %r6 [orig:120 getRegUsage ] [120]) [0
S1 A8])
(const_int 0 [0x0]))
(clobber (reg:DI 14 %r14))
]) 546 {*basr} (expr_list:REG_DEAD (reg:DI 4 %r4)
(expr_list:REG_DEAD (reg:DI 3 %r3)
(expr_list:REG_DEAD (reg:DI 2 %r2)
(nil))))
(expr_list:REG_DEP_TRUE (use (reg:DI 4 %r4))
(expr_list:REG_DEP_TRUE (use (reg:DI 3 %r3))
(expr_list:REG_DEP_TRUE (use (reg:DI 2 %r2))
(nil)))))
(note 583 150 582 20 (var_location r (mem/c:SI (plus:DI (reg/f:DI 32 %ap)
(const_int -412 [0xfffffffffffffe64])) [14 %sfp+-252 S4 A32]))
NOTE_INSN_VAR_LOCATION)
(note/c 582 583 581 20 (var_location instr (nil)) NOTE_INSN_VAR_LOCATION)
(note/c 581 582 584 20 (var_location r (reg:SI 14 %r14))
NOTE_INSN_VAR_LOCATION)
For note 582 the LVL20-1 label is being generated while note 583 belongs to
label LVL20. That makes the location range of note 583 to be LVL20...LVL20-1.
The attached patch fixes the problem by making sure that normal var
location notes cannot be inserted before call related notes.
Bootstrapped with 4.5 and mainline on s390x and x86_64.
No regressions.
Ok for 4.5 and mainline?
Bye,
-Andreas-
2010-10-14 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
PR debug/45939
* var-tracking.c (emit_note_insn_var_location): Make sure that
call related var location notes come before the normal ones.
Index: gcc/var-tracking.c
===================================================================
*** gcc/var-tracking.c.orig
--- gcc/var-tracking.c
*************** emit_note_insn_var_location (void **varp
*** 7322,7328 ****
NOTE_DURING_CALL_P (note) = true;
}
else
! note = emit_note_before (NOTE_INSN_VAR_LOCATION, insn);
NOTE_VAR_LOCATION (note) = note_vl;
clear:
--- 7322,7338 ----
NOTE_DURING_CALL_P (note) = true;
}
else
! {
! /* Make sure that the call related notes come first. */
! while (NEXT_INSN (insn)
! && NOTE_P (insn)
! && NOTE_DURING_CALL_P (insn))
! insn = NEXT_INSN (insn);
! if (NOTE_P (insn) && NOTE_DURING_CALL_P (insn))
! note = emit_note_after (NOTE_INSN_VAR_LOCATION, insn);
! else
! note = emit_note_before (NOTE_INSN_VAR_LOCATION, insn);
! }
NOTE_VAR_LOCATION (note) = note_vl;
clear: