Bug 51570 - [4.7 Regression] FAIL: gcc.dg/guality/pr45003-[23].c
Summary: [4.7 Regression] FAIL: gcc.dg/guality/pr45003-[23].c
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.7.0
: P2 normal
Target Milestone: 4.8.0
Assignee: Alexandre Oliva
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-15 16:11 UTC by Richard Biener
Modified: 2016-03-03 23:35 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-12-16 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2011-12-15 16:11:07 UTC
I see the following FAILs with the most recent gdb installed (7.3):

FAIL: gcc.dg/guality/pr45003-2.c  -O1  line 10 a == 0x8078
FAIL: gcc.dg/guality/pr45003-2.c  -O1  line 19 a == 0xffff8078
FAIL: gcc.dg/guality/pr45003-2.c  -O2  line 10 a == 0x8078
FAIL: gcc.dg/guality/pr45003-2.c  -O2  line 19 a == 0xffff8078
FAIL: gcc.dg/guality/pr45003-2.c  -O3 -fomit-frame-pointer  line 10 a == 0x8078
FAIL: gcc.dg/guality/pr45003-2.c  -O3 -fomit-frame-pointer  line 19 a == 0xffff8078
FAIL: gcc.dg/guality/pr45003-2.c  -O3 -g  line 10 a == 0x8078
FAIL: gcc.dg/guality/pr45003-2.c  -O3 -g  line 19 a == 0xffff8078
FAIL: gcc.dg/guality/pr45003-2.c  -Os  line 10 a == 0x8078
FAIL: gcc.dg/guality/pr45003-2.c  -Os  line 19 a == 0xffff8078
FAIL: gcc.dg/guality/pr45003-2.c  -O2 -flto -fno-use-linker-plugin -flto-partition=none  line 10 a == 0x8078
FAIL: gcc.dg/guality/pr45003-2.c  -O2 -flto -fno-use-linker-plugin -flto-partition=none  line 19 a == 0xffff8078
FAIL: gcc.dg/guality/pr45003-2.c  -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  line 10 a == 0x8078
FAIL: gcc.dg/guality/pr45003-2.c  -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  line 19 a == 0xffff8078
FAIL: gcc.dg/guality/pr45003-3.c  -O1  line 10 a == -32648
FAIL: gcc.dg/guality/pr45003-3.c  -O1  line 19 a == 0x8078
FAIL: gcc.dg/guality/pr45003-3.c  -O2  line 10 a == -32648
FAIL: gcc.dg/guality/pr45003-3.c  -O2  line 19 a == 0x8078
FAIL: gcc.dg/guality/pr45003-3.c  -O3 -fomit-frame-pointer  line 10 a == -32648
FAIL: gcc.dg/guality/pr45003-3.c  -O3 -fomit-frame-pointer  line 19 a == 0x8078
FAIL: gcc.dg/guality/pr45003-3.c  -O3 -g  line 10 a == -32648
FAIL: gcc.dg/guality/pr45003-3.c  -O3 -g  line 19 a == 0x8078
FAIL: gcc.dg/guality/pr45003-3.c  -Os  line 10 a == -32648
FAIL: gcc.dg/guality/pr45003-3.c  -Os  line 19 a == 0x8078
FAIL: gcc.dg/guality/pr45003-3.c  -O2 -flto -fno-use-linker-plugin -flto-partition=none  line 10 a == -32648
FAIL: gcc.dg/guality/pr45003-3.c  -O2 -flto -fno-use-linker-plugin -flto-partition=none  line 19 a == 0x8078
FAIL: gcc.dg/guality/pr45003-3.c  -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  line 10 a == -32648
FAIL: gcc.dg/guality/pr45003-3.c  -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects  line 19 a == 0x8078

they pass for the -m32 multilib though.  No other gdb version tested.
Comment 1 Jakub Jelinek 2011-12-16 09:08:09 UTC
This got "broken" by my ENTRY_VALUE patches, and apparently even Alex'
"Keep static VTA locs in cselib tables only" patch doesn't cure it.

We have:
(debug_insn 6 3 7 2 (var_location:HI D#2 (mem:HI (reg/v/f:DI 5 di [orig:62 p ] [62]) [0 *p_1(D)+0 S2 A16])) pr45003-3.c:8 -1
     (nil))

(debug_insn 7 6 8 2 (var_location:HI D#1 (debug_expr:HI D#2)) pr45003-3.c:8 -1
     (nil))

(debug_insn 8 7 9 2 (var_location:SI a (sign_extend:SI (debug_expr:HI D#1))) pr45003-3.c:8 -1
     (nil))

(insn:TI 9 8 10 2 (set (reg:SI 5 di [orig:60 D.1725 ] [60])
        (zero_extend:SI (mem:HI (reg/v/f:DI 5 di [orig:62 p ] [62]) [2 *p_1(D)+0 S2 A16]))) pr45003-3.c:9 117 {*zero_extendhisi2_movzwl}
     (nil))

The PR45003 improvement noted during var-tracking the reverse operation of
(zero_extend:SI (mem:HI (di))))
i.e. that the value of D#2 (and D#1) can be computed as (subreg:HI (reg:SI di))
after insn 9.  Thus before ENTRY_VALUE changes, we'd see that the p pointer value isn't live after that insn anywhere and the only way to compute it would be to go back, see that (mem:HI (value of p on entry)) is live in (subreg:HI (reg:SI di)) and just emit the sign extension of it.
Now, with ENTRY_VALUE, even when we keep it as lowest priority alternative,
we have a place where the value of p on entry is live - (entry_value:DI rdi)
and thus we just use it and don't look further.
This testcase will work just fine with GDB 7.4 which finally supports DW_OP_GNU_entry_value (just verified that), but that wasn't the actual goal of the testcase, it is trivial to modify the testcase so that it will fail even with GDB 7.4:

--- gcc/testsuite/gcc.dg/guality/pr45003-3.c.jj	2010-11-19 20:56:33.000000000 +0100
+++ gcc/testsuite/gcc.dg/guality/pr45003-3.c	2011-12-16 10:01:36.170231171 +0100
@@ -24,8 +24,12 @@ int
 main ()
 {
   unsigned short us = 0x8078;
-  foo (&us);
+  unsigned short *pus = &us;
+  asm volatile ("" : "+r" (pus));
+  foo (pus);
   short s = -32648;
-  bar (&s);
+  short *ps = &s;
+  asm volatile ("" : "+r" (ps));
+  bar (ps);
   return 0;
 }

Then on the call site we don't know what is the value passed to the functions, and as those values aren't needed afterwards, they aren't saved anywhere.
So, yes, entry_value should have the lowest priority of everything.

To fix this we'd need to cache during vt_emit_notes not just a single expression, but at most two, one that doesn't use any entry_value expressions and one that does.  To build the complete expressions for the notes we'd first try if we can build up an expression entirely without any entry_values, and only if it fails, supply one with entry_values.  If we did no caching, we could of course just try to expand twice and ignore entry_value in the first round, but we really can't avoid the caching, the memory consumption and compile time complexity was huge on some testcases.
Comment 2 Richard Biener 2012-01-19 12:49:40 UTC
Any updates here?  Should we simply XFAIL the tests?
Comment 3 Jakub Jelinek 2012-01-19 12:56:53 UTC
Then it would XPASS with latest gdb.
With the gdb 7.4.50.20120103-8.fc17 I'm only seeing lots of guality XPASSes on x86_64 and no FAILs and on i686 again lots of XPASSes and just a single
FAIL: gcc.dg/guality/vla-1.c  -Os  line 17 sizeof (a) == 6
fail.  We definitely need to do something about this, but perhaps it can wait for 4.8.  Alex, do you think you could look at this?  Thanks.
Comment 4 Richard Biener 2012-02-27 10:34:31 UTC
Thus, P2.  We still should consider XFAILing the tests to make the testsuite
clean.
Comment 5 Alexandre Oliva 2012-02-28 05:48:42 UTC
On it (at last!)
Comment 6 Richard Biener 2012-03-22 08:27:17 UTC
GCC 4.7.0 is being released, adjusting target milestone.
Comment 7 Alexandre Oliva 2012-04-13 15:56:00 UTC
Author: aoliva
Date: Fri Apr 13 15:55:52 2012
New Revision: 186420

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186420
Log:
PR debug/51570
* var-tracking.c (expand_depth): New type.
(onepart_aux, expand_loc_callback_data): Change depth type to it.
(loc_exp_dep_alloc): Adjust initializer.
(update_depth): Use new type.  Add entryvals.
(vt_expand_var_loc_chain): Take note of expansions with
ENTRY_VALUEs, but don't accept them right away.  Run an optional
second pass accepting the minimum ENTRY_VALUE count found in the
first pass.
(vt_expand_loc_callback, INIT_ELCD): Adjust.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/var-tracking.c
Comment 8 Alexandre Oliva 2012-04-18 00:22:23 UTC
Fixed in the trunk.  Letting the dust settle before backporting.
Comment 9 Richard Biener 2012-06-14 08:41:26 UTC
GCC 4.7.1 is being released, adjusting target milestone.
Comment 10 Jakub Jelinek 2012-09-20 10:20:25 UTC
GCC 4.7.2 has been released.
Comment 11 Alexandre Oliva 2012-11-08 03:06:09 UTC
Not backporting.  Fixed.