* [Bug tree-optimization/51990] ICE in copy_reference_ops_from_ref
2012-01-25 8:45 [Bug tree-optimization/51990] New: ICE in copy_reference_ops_from_ref vries at gcc dot gnu.org
@ 2012-01-25 8:55 ` vries at gcc dot gnu.org
2012-01-25 9:43 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2012-01-25 8:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51990
--- Comment #1 from vries at gcc dot gnu.org 2012-01-25 08:39:23 UTC ---
tentative fix:
Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c (revision 183325)
+++ gcc/tree-ssa-sccvn.c (working copy)
@@ -624,6 +624,10 @@ copy_reference_ops_from_ref (tree ref, V
switch (temp.opcode)
{
+ case WITH_SIZE_EXPR:
+ temp.op0 = TREE_OPERAND (ref, 1);
+ temp.off = 0;
+ break;
case MEM_REF:
/* The base address gets its own vn_reference_op_s structure. */
temp.op0 = TREE_OPERAND (ref, 1);
@@ -740,6 +744,7 @@ copy_reference_ops_from_ref (tree ref, V
VEC_safe_push (vn_reference_op_s, heap, *result, &temp);
if (REFERENCE_CLASS_P (ref)
+ || TREE_CODE (ref) == WITH_SIZE_EXPR
|| (TREE_CODE (ref) == ADDR_EXPR
&& !is_gimple_min_invariant (ref)))
ref = TREE_OPERAND (ref, 0);
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/51990] ICE in copy_reference_ops_from_ref
2012-01-25 8:45 [Bug tree-optimization/51990] New: ICE in copy_reference_ops_from_ref vries at gcc dot gnu.org
2012-01-25 8:55 ` [Bug tree-optimization/51990] " vries at gcc dot gnu.org
@ 2012-01-25 9:43 ` pinskia at gcc dot gnu.org
2012-01-25 10:27 ` vries at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-01-25 9:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51990
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |http://gcc.gnu.org/bugzilla
| |/show_bug.cgi?id=37428
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-01-25 08:49:28 UTC ---
This extension is not even documented, see PR 37428 for more info.
I want to say this example is invalid as the function foo does not have enough
info about the size of struct s.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/51990] ICE in copy_reference_ops_from_ref
2012-01-25 8:45 [Bug tree-optimization/51990] New: ICE in copy_reference_ops_from_ref vries at gcc dot gnu.org
2012-01-25 8:55 ` [Bug tree-optimization/51990] " vries at gcc dot gnu.org
2012-01-25 9:43 ` pinskia at gcc dot gnu.org
@ 2012-01-25 10:27 ` vries at gcc dot gnu.org
2012-01-25 10:46 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2012-01-25 10:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51990
--- Comment #3 from vries at gcc dot gnu.org 2012-01-25 10:15:53 UTC ---
(In reply to comment #2)
> This extension is not even documented, see PR 37428 for more info.
>
There are at least these 3 examples in the testsuite that use this extension:
gcc.c-torture/compile/20030224-1.c
gcc.c-torture/execute/20020412-1.c
gcc.dg/lto/20090706-1_0.c
These 3 tests fail (in unmodified form) with my patch for PR51879 (see PR51879
comment 7) on this ICE.
> I want to say this example is invalid as the function foo does not have enough
> info about the size of struct s.
If the example is indeed valid, it would be nice if the compiler at least
warned about that.
Either way, the last 2 tests listed above use (int, ...) as prototype. IIUC,
using that prototype would remove your concern about invalidity. Using that
prototype instead, I get the same ICE:
...
int
zzz (char *s1, char *s2, int len, int *q)
{
int z = 5;
unsigned int i, b;
struct s { char a[z]; };
struct s x;
extern int foo (int, ...) __attribute__((pure));
for (i = 0; i < len; i++)
s1[i] = s2[i];
b = z & 0x3;
len += (b == 0 ? 0 : 1) + z;
*q = len;
return foo (z, x, x);
}
...
I suppose another way to achieve the same is to use a nested function:
...
__attribute__((pure,noinline)) int foo (struct s s1, struct s s2)
{
return 0;
}
...
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/51990] ICE in copy_reference_ops_from_ref
2012-01-25 8:45 [Bug tree-optimization/51990] New: ICE in copy_reference_ops_from_ref vries at gcc dot gnu.org
` (2 preceding siblings ...)
2012-01-25 10:27 ` vries at gcc dot gnu.org
@ 2012-01-25 10:46 ` rguenth at gcc dot gnu.org
2012-01-25 12:10 ` vries at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-01-25 10:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51990
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-01-25
Ever Confirmed|0 |1
--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-25 10:39:12 UTC ---
(In reply to comment #1)
> tentative fix:
>
> Index: gcc/tree-ssa-sccvn.c
> ===================================================================
> --- gcc/tree-ssa-sccvn.c (revision 183325)
> +++ gcc/tree-ssa-sccvn.c (working copy)
> @@ -624,6 +624,10 @@ copy_reference_ops_from_ref (tree ref, V
>
> switch (temp.opcode)
> {
> + case WITH_SIZE_EXPR:
> + temp.op0 = TREE_OPERAND (ref, 1);
> + temp.off = 0;
> + break;
> case MEM_REF:
> /* The base address gets its own vn_reference_op_s structure. */
> temp.op0 = TREE_OPERAND (ref, 1);
> @@ -740,6 +744,7 @@ copy_reference_ops_from_ref (tree ref, V
> VEC_safe_push (vn_reference_op_s, heap, *result, &temp);
>
> if (REFERENCE_CLASS_P (ref)
> + || TREE_CODE (ref) == WITH_SIZE_EXPR
> || (TREE_CODE (ref) == ADDR_EXPR
> && !is_gimple_min_invariant (ref)))
> ref = TREE_OPERAND (ref, 0);
I think there are a lot of bugs lurking in the compiler with respect to
not handling WITH_SIZE_EXPR (which incidentially isn't a handled-component,
nor tcc_reference ...). You btw. also need to handle re-materializing
them in create_component_ref_by_pieces_1.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/51990] ICE in copy_reference_ops_from_ref
2012-01-25 8:45 [Bug tree-optimization/51990] New: ICE in copy_reference_ops_from_ref vries at gcc dot gnu.org
` (3 preceding siblings ...)
2012-01-25 10:46 ` rguenth at gcc dot gnu.org
@ 2012-01-25 12:10 ` vries at gcc dot gnu.org
2012-01-25 12:29 ` vries at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2012-01-25 12:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51990
vries at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |UNCONFIRMED
Ever Confirmed|1 |0
--- Comment #5 from vries at gcc dot gnu.org 2012-01-25 11:41:50 UTC ---
(In reply to comment #4)
> (In reply to comment #1)
> I think there are a lot of bugs lurking in the compiler with respect to
> not handling WITH_SIZE_EXPR (which incidentially isn't a handled-component,
> nor tcc_reference ...). You btw. also need to handle re-materializing
> them in create_component_ref_by_pieces_1.
Indeed. Using the proposed patch and this example:
...
int y;
extern int foo (int, ...) __attribute__((pure));
int
zzz (char *s1, char *s2, int len, int *q, int c)
{
int z = 5;
unsigned int i, b;
struct s { char a[z]; };
struct s x;
int y_tmp = 5;
for (i = 0; i < len; i++)
s1[i] = s2[i];
b = z & 0x3;
len += (b == 0 ? 0 : 1) + z;
*q = len;
if (c)
y_tmp = foo (z, x, x) + 4;
z = foo (z, x, x) + 4;
y = y_tmp;
return z;
}
...
I hit this ICE:
...
test2.c: In function ‘zzz’:
test2.c:5:1: internal compiler error: in create_component_ref_by_pieces_1, at
tree-ssa-pre.c:2925
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
...
tentative patch:
...
Index: tree-ssa-pre.c
===================================================================
--- tree-ssa-pre.c (revision 183325)
+++ tree-ssa-pre.c (working copy)
@@ -2780,6 +2780,7 @@ create_component_ref_by_pieces_1 (basic_
case REALPART_EXPR:
case IMAGPART_EXPR:
case VIEW_CONVERT_EXPR:
+ case WITH_SIZE_EXPR:
{
tree folded;
tree genop0 = create_component_ref_by_pieces_1 (block, ref,
@@ -2787,8 +2788,12 @@ create_component_ref_by_pieces_1 (basic_
stmts, domstmt);
if (!genop0)
return NULL_TREE;
- folded = fold_build1 (currop->opcode, currop->type,
- genop0);
+
+ folded
+ = (currop->opcode == WITH_SIZE_EXPR
+ ? fold_build2 (currop->opcode, currop->type, genop0, currop->op0)
+ : fold_build1 (currop->opcode, currop->type, genop0));
+
return folded;
}
break;
...
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/51990] ICE in copy_reference_ops_from_ref
2012-01-25 8:45 [Bug tree-optimization/51990] New: ICE in copy_reference_ops_from_ref vries at gcc dot gnu.org
` (4 preceding siblings ...)
2012-01-25 12:10 ` vries at gcc dot gnu.org
@ 2012-01-25 12:29 ` vries at gcc dot gnu.org
2012-01-27 10:49 ` vries at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2012-01-25 12:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51990
vries at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
AssignedTo|unassigned at gcc dot |vries at gcc dot gnu.org
|gnu.org |
Ever Confirmed|0 |1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/51990] ICE in copy_reference_ops_from_ref
2012-01-25 8:45 [Bug tree-optimization/51990] New: ICE in copy_reference_ops_from_ref vries at gcc dot gnu.org
` (5 preceding siblings ...)
2012-01-25 12:29 ` vries at gcc dot gnu.org
@ 2012-01-27 10:49 ` vries at gcc dot gnu.org
2012-01-27 10:51 ` vries at gcc dot gnu.org
2012-01-28 16:49 ` vries at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2012-01-27 10:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51990
--- Comment #6 from vries at gcc dot gnu.org 2012-01-27 10:38:32 UTC ---
Author: vries
Date: Fri Jan 27 10:38:27 2012
New Revision: 183614
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183614
Log:
2012-01-27 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/51990
* tree-ssa-sccvn.c (copy_reference_ops_from_ref): Handle WITH_SIZE_EXPR.
* tree-ssa-pre.c (create_component_ref_by_pieces_1): Same.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/tree-ssa-pre.c
trunk/gcc/tree-ssa-sccvn.c
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/51990] ICE in copy_reference_ops_from_ref
2012-01-25 8:45 [Bug tree-optimization/51990] New: ICE in copy_reference_ops_from_ref vries at gcc dot gnu.org
` (6 preceding siblings ...)
2012-01-27 10:49 ` vries at gcc dot gnu.org
@ 2012-01-27 10:51 ` vries at gcc dot gnu.org
2012-01-28 16:49 ` vries at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2012-01-27 10:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51990
--- Comment #7 from vries at gcc dot gnu.org 2012-01-27 10:38:38 UTC ---
Author: vries
Date: Fri Jan 27 10:38:34 2012
New Revision: 183615
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183615
Log:
2012-01-27 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/51990
* gcc.dg/pr51990.c: New test.
* gcc.dg/pr51990-2.c: Same.
Added:
trunk/gcc/testsuite/gcc.dg/pr51990-2.c
trunk/gcc/testsuite/gcc.dg/pr51990.c
Modified:
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/51990] ICE in copy_reference_ops_from_ref
2012-01-25 8:45 [Bug tree-optimization/51990] New: ICE in copy_reference_ops_from_ref vries at gcc dot gnu.org
` (7 preceding siblings ...)
2012-01-27 10:51 ` vries at gcc dot gnu.org
@ 2012-01-28 16:49 ` vries at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: vries at gcc dot gnu.org @ 2012-01-28 16:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51990
vries at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.7.0
--- Comment #8 from vries at gcc dot gnu.org 2012-01-28 15:18:58 UTC ---
Patch and test-case committed, resolving to fixed.
^ permalink raw reply [flat|nested] 10+ messages in thread