Hi! Depending on the computed hash of the parameter register, corresponding ENTRY_VALUE and the size of the hash table it can sometimes happen that val2 = cselib_lookup_from_insn will actually find val, which means that ENTRY_VALUEs in DEBUG_INSNs will be kept as ENTRY_VALUEs instead of REGs or similar preferrable locations if the value is still live there. Fixed by adding the ENTRY_VALUE to val->loc only after the cselib_lookup_from_insn.
Bootstrapped/regtested on x86_64-linux and i686-linux, fixes PASS: gcc.dg/guality/pr45882.c -O0 line 16 e == 142 PASS: gcc.dg/guality/pr45882.c -O1 (test for excess errors) PASS: gcc.dg/guality/pr45882.c -O1 execution test -UNSUPPORTED: gcc.dg/guality/pr45882.c -O1 line 16 b == 7 +PASS: gcc.dg/guality/pr45882.c -O1 line 16 b == 7 +PASS: gcc.dg/guality/pr45882.c -O1 line 16 c == 11 +PASS: gcc.dg/guality/pr45882.c -O1 line 16 d == 112 +PASS: gcc.dg/guality/pr45882.c -O1 line 16 e == 142 PASS: gcc.dg/guality/pr45882.c -O2 (test for excess errors) PASS: gcc.dg/guality/pr45882.c -O2 execution test -UNSUPPORTED: gcc.dg/guality/pr45882.c -O2 line 16 e == 142 +PASS: gcc.dg/guality/pr45882.c -O2 line 16 b == 7 +PASS: gcc.dg/guality/pr45882.c -O2 line 16 c == 11 +PASS: gcc.dg/guality/pr45882.c -O2 line 16 d == 112 +PASS: gcc.dg/guality/pr45882.c -O2 line 16 e == 142 PASS: gcc.dg/guality/pr45882.c -O3 -fomit-frame-pointer (test for excess errors) PASS: gcc.dg/guality/pr45882.c -O3 -fomit-frame-pointer execution test +PASS: gcc.dg/guality/pr45882.c -O3 -fomit-frame-pointer line 16 b == 7 +PASS: gcc.dg/guality/pr45882.c -O3 -fomit-frame-pointer line 16 c == 11 +PASS: gcc.dg/guality/pr45882.c -O3 -fomit-frame-pointer line 16 d == 112 +PASS: gcc.dg/guality/pr45882.c -O3 -fomit-frame-pointer line 16 e == 142 PASS: gcc.dg/guality/pr45882.c -O3 -g (test for excess errors) PASS: gcc.dg/guality/pr45882.c -O3 -g execution test +PASS: gcc.dg/guality/pr45882.c -O3 -g line 16 b == 7 +PASS: gcc.dg/guality/pr45882.c -O3 -g line 16 c == 11 +PASS: gcc.dg/guality/pr45882.c -O3 -g line 16 d == 112 +PASS: gcc.dg/guality/pr45882.c -O3 -g line 16 e == 142 PASS: gcc.dg/guality/pr45882.c -Os (test for excess errors) PASS: gcc.dg/guality/pr45882.c -Os execution test +PASS: gcc.dg/guality/pr45882.c -Os line 16 b == 7 +PASS: gcc.dg/guality/pr45882.c -Os line 16 c == 11 +PASS: gcc.dg/guality/pr45882.c -Os line 16 d == 112 +PASS: gcc.dg/guality/pr45882.c -Os line 16 e == 142 PASS: gcc.dg/guality/pr45882.c -O2 -flto -flto-partition=none (test for excess errors) PASS: gcc.dg/guality/pr45882.c -O2 -flto -flto-partition=none execution test +PASS: gcc.dg/guality/pr45882.c -O2 -flto -flto-partition=none line 16 b == 7 +PASS: gcc.dg/guality/pr45882.c -O2 -flto -flto-partition=none line 16 c == 11 +PASS: gcc.dg/guality/pr45882.c -O2 -flto -flto-partition=none line 16 d == 112 +PASS: gcc.dg/guality/pr45882.c -O2 -flto -flto-partition=none line 16 e == 142 PASS: gcc.dg/guality/pr45882.c -O2 -flto (test for excess errors) PASS: gcc.dg/guality/pr45882.c -O2 -flto execution test +PASS: gcc.dg/guality/pr45882.c -O2 -flto line 16 b == 7 +PASS: gcc.dg/guality/pr45882.c -O2 -flto line 16 c == 11 +PASS: gcc.dg/guality/pr45882.c -O2 -flto line 16 d == 112 +PASS: gcc.dg/guality/pr45882.c -O2 -flto line 16 e == 142 which broke when SIMPLE_RETURN has been added to rtl.def and thus rtx codes of REG and ENTRY_VALUE changed and with that changed also the hashing of it. Ok for trunk? 2011-08-28 Jakub Jelinek <ja...@redhat.com> PR debug/50215 * var-tracking.c (create_entry_value): Call cselib_lookup_from_insn before adding ENTRY_VALUE to val->locs. --- gcc/var-tracking.c.jj 2011-07-29 17:07:20.000000000 +0200 +++ gcc/var-tracking.c 2011-08-28 13:14:07.000000000 +0200 @@ -8488,13 +8488,13 @@ create_entry_value (rtx rtl, cselib_val cselib_val *val2; struct elt_loc_list *el; el = (struct elt_loc_list *) ggc_alloc_cleared_atomic (sizeof (*el)); - el->next = val->locs; el->loc = gen_rtx_ENTRY_VALUE (GET_MODE (rtl)); ENTRY_VALUE_EXP (el->loc) = rtl; - el->setting_insn = get_insns (); - val->locs = el; val2 = cselib_lookup_from_insn (el->loc, GET_MODE (rtl), true, VOIDmode, get_insns ()); + el->next = val->locs; + el->setting_insn = get_insns (); + val->locs = el; if (val2 && val2 != val && val2->locs Jakub