Bug 43670 - [4.5/4.6 Regression] "-fcompare-debug failure (length)" with -O -ftree-vrp
Summary: [4.5/4.6 Regression] "-fcompare-debug failure (length)" with -O -ftree-vrp
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Jakub Jelinek
URL:
Keywords: compare-debug-failure
Depends on:
Blocks:
 
Reported: 2010-04-06 23:55 UTC by Zdenek Sojka
Modified: 2022-01-18 23:30 UTC (History)
2 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: i686-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-04-07 17:00:43


Attachments
reduced testcase (191 bytes, text/plain)
2010-04-07 00:00 UTC, Zdenek Sojka
Details
gcc45-pr43670.patch (768 bytes, patch)
2010-04-07 17:47 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2010-04-06 23:55:19 UTC
Command line:
gcc -O -ftree-vrp -m32 -fcompare-debug 20030324-1.c

Tested revisions:
r157965 - fail
r153685 - fail

Compiler output:
$ /mnt/svn/gcc-trunk/binary-157965-lto/bin/gcc -O -ftree-vrp -m32 -fcompare-debug testcase.c
gcc: testcase.c: -fcompare-debug failure (length)
Comment 1 Zdenek Sojka 2010-04-07 00:00:31 UTC
Created attachment 20324 [details]
reduced testcase

reduced from gcc/testsuite/gcc.dg/20030324-1.c

Command line:
gcc -O -ftree-vrp -m32 -fcompare-debug pr43670.c

-g results in different code being generated
Comment 2 Jakub Jelinek 2010-04-07 16:49:20 UTC
Ugh, apparently nothing clears TREE_ADDRESSABLE on x when not -g, only with -g (x really isn't addressable in the end).  So, here -g generates better code than -g0.
Comment 3 Jakub Jelinek 2010-04-07 17:00:43 UTC
I've messed this up.  Of course it is the other way around, and it is
discover_nonconstant_array_refs that marks x TREE_ADDRESSABLE because of an occurrence in DEBUG_STMT.  Sorry for the previous premature comment.
Comment 4 Jakub Jelinek 2010-04-07 17:47:23 UTC
Created attachment 20329 [details]
gcc45-pr43670.patch

Untested fix.
Comment 5 Jakub Jelinek 2010-04-08 09:16:52 UTC
Subject: Bug 43670

Author: jakub
Date: Thu Apr  8 09:16:28 2010
New Revision: 158108

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158108
Log:
	PR debug/43670
	* cfgexpand.c (expand_debug_expr): If for non-NULL offset
	op0 is not a MEM, just return NULL instead of assertion
	failure.
	(discover_nonconstant_array_refs): Don't walk debug stmts.

	* gcc.dg/pr43670.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr43670.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cfgexpand.c
    trunk/gcc/testsuite/ChangeLog

Comment 6 Jakub Jelinek 2010-04-08 09:18:19 UTC
Subject: Bug 43670

Author: jakub
Date: Thu Apr  8 09:17:52 2010
New Revision: 158109

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158109
Log:
	PR debug/43670
	* cfgexpand.c (expand_debug_expr): If for non-NULL offset
	op0 is not a MEM, just return NULL instead of assertion
	failure.
	(discover_nonconstant_array_refs): Don't walk debug stmts.

	* gcc.dg/pr43670.c: New test.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/gcc.dg/pr43670.c
Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/cfgexpand.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog

Comment 7 Jakub Jelinek 2010-04-08 11:41:52 UTC
Fixed.