Patchwork Fix ENTRY_VALUE parameter setup in var-tracking (PR debug/50215)

login
register
mail settings
Submitter Jakub Jelinek
Date Aug. 28, 2011, 6:56 p.m.
Message ID <20110828185610.GA2687@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/111935/
State New
Headers show

Comments

Jakub Jelinek - Aug. 28, 2011, 6:56 p.m.
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  <jakub@redhat.com>

	PR debug/50215
	* var-tracking.c (create_entry_value): Call cselib_lookup_from_insn
	before adding ENTRY_VALUE to val->locs.


	Jakub
Richard Guenther - Aug. 29, 2011, 7:10 a.m.
On Sun, Aug 28, 2011 at 8:56 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> 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?

Ok.

Thanks,
Richard.

> 2011-08-28  Jakub Jelinek  <jakub@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
>

Patch

--- 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