Bug 23402 - [4.1 Regression] error: statement makes a memory store, but has no V_MAY_DEFS nor V_MUST_DEFS
Summary: [4.1 Regression] error: statement makes a memory store, but has no V_MAY_DEFS...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.1.0
Assignee: Andrew Pinski
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: alias, ice-on-valid-code, patch
Depends on:
Blocks:
 
Reported: 2005-08-15 15:26 UTC by Adrian Bunk
Modified: 2005-08-17 01:56 UTC (History)
5 users (show)

See Also:
Host:
Target: i686-pc-linux-gnu
Build:
Known to work: 4.0.1
Known to fail:
Last reconfirmed: 2005-08-15 17:18:44


Attachments
preprocessed file (100.87 KB, application/x-gzip)
2005-08-15 15:28 UTC, Adrian Bunk
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Bunk 2005-08-15 15:26:56 UTC
This is a compile error when trying to compile the file kernel/audit.c from the
Linux kernel 2.6.13-rc5-mm1 with a current CVS HEAD gcc.

I've removed many of the compiler flags that were present at the original
compilation. What triggers this problem is switching from -O0 (no problem) to
-O1 (see below).

<--  snip  -->

...
$  /TMP/test/gcc/install/bin/gcc -m32 -Wp,-MD,kernel/.audit.o.d  -nostdinc
-isystem /TMP/test/gcc/install/lib/gcc/i686-pc-linux-gnu/4.1.0/include
-D__KERNEL__ -Iinclude -O1  -save-temps  -Iinclude/asm-i386/mach-default
-Wno-pointer-sign    -DKBUILD_BASENAME=audit -DKBUILD_MODNAME=audit -c -o
kernel/audit.o kernel/audit.c
kernel/audit.c: In function 'audit_init':
kernel/audit.c:518: error: statement makes a memory store, but has no V_MAY_DEFS
nor V_MUST_DEFS
#   VUSE <D.23048_10>;
audit_skb_queue.lock = D.23048;
kernel/audit.c:518: internal compiler error: verify_ssa failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

<--  snip  -->
Comment 1 Adrian Bunk 2005-08-15 15:28:28 UTC
Created attachment 9498 [details]
preprocessed file
Comment 2 Andrew Pinski 2005-08-15 15:45:47 UTC
Reducing.
Comment 3 Andrew Pinski 2005-08-15 17:18:44 UTC
Confirmed, reduced testcase:
typedef struct {} raw_spinlock_t;
typedef struct {
  raw_spinlock_t raw_lock;
} spinlock_t;
struct sk_buff_head {
  int i;
  spinlock_t lock;
};
struct sk_buff_head audit_skb_queue;
void audit_init(void)
{
  struct sk_buff_head *list = &audit_skb_queue;
  audit_skb_queue.lock = (spinlock_t) { .raw_lock = { } };
}

Taking the address is required even though it is dead.
Comment 4 Andrew Pinski 2005-08-15 17:24:06 UTC
If I disable structural alias analysis (-fno-tree-salias) the testcase works.
Comment 5 Daniel Berlin 2005-08-15 17:28:55 UTC
Subject: Re:  [4.1 Regression] error:
	statement makes a memory store, but has no V_MAY_DEFS nor V_MUST_DEFS



On Mon, 2005-08-15 at 17:24 +0000, pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org
> 2005-08-15 17:24 -------
> If I disable structural alias analysis (-fno-tree-salias) the testcase
> works.
> 

Ugh.
We dealt with this once.  After discussing with RTH or diego (i forget
who) about what to do here, we decided the best solution is to not
generate these stores into the IL in the first place, rather than hack
up all the code around it to allow zero sized stores.

After all, what is the store of the zero sized field supposed to
represent?




Comment 6 Andrew Pinski 2005-08-15 17:32:11 UTC
This is related to PR 21839 which was fixed by not gimplifying the store but it looks like it did not fix 
fully not gimplifing the store.
Comment 7 Andrew Pinski 2005-08-15 17:36:21 UTC
Here is another testcase:
typedef struct {} spinlock_t;
struct sk_buff_head {
  int i;
  spinlock_t lock;
};
struct sk_buff_head audit_skb_queue;
void audit_init(void)
{
  struct sk_buff_head *list = &audit_skb_queue;
  spinlock_t a = {};
  audit_skb_queue.lock = a;
}

The gimplifier is emitting the "audit_skb_queue.lock = a;" which is what is causing the issue.
Comment 8 Andrew Pinski 2005-08-15 22:37:58 UTC
I have a fix which I am testing.
Comment 9 Andrew Pinski 2005-08-16 17:15:09 UTC
Patch posted here: <http://gcc.gnu.org/ml/gcc-patches/2005-08/msg00985.html>.
Comment 10 CVS Commits 2005-08-17 01:55:23 UTC
Subject: Bug 23402

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pinskia@gcc.gnu.org	2005-08-17 01:55:05

Modified files:
	gcc            : ChangeLog gimplify.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.c-torture/compile: zero-strct-3.c 
	                                     zero-strct-4.c 

Log message:
	2005-08-16  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR tree-opt/23402
	* gcc.c-torture/compile/zero-strct-3.c: New test.
	* gcc.c-torture/compile/zero-strct-4.c: New test.
	
	2005-08-16  Andrew Pinski  <pinskia@physics.uc.edu>
	
	PR tree-opt/23402
	* gimplify.c (zero_sized_type): New function.
	(gimplify_modify_expr_rhs): If we have a zero sized type,
	replace the statement with an empty statement.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9753&r2=2.9754
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gimplify.c.diff?cvsroot=gcc&r1=2.146&r2=2.147
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5932&r2=1.5933
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/zero-strct-3.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/zero-strct-4.c.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 11 Andrew Pinski 2005-08-17 01:56:33 UTC
Fixed.