[Bug tree-optimization/65818] [6 Regression] libiberty/vprintf-support.c:41:1: ICE: in expand_i fn_va_arg_1, at tree-stdarg.c:1095

2015-04-28 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65818

--- Comment #14 from vries at gcc dot gnu.org ---
Author: vries
Date: Tue Apr 28 06:05:14 2015
New Revision: 222509

URL: https://gcc.gnu.org/viewcvs?rev=222509root=gccview=rev
Log:
Evaluate side-effects in expand_ifn_va_arg_1

2015-04-28  Tom de Vries  t...@codesourcery.com

PR tree-optimization/65818
* tree-stdarg.c (expand_ifn_va_arg_1): Ensure that side-effects are
evaluated.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/tree-stdarg.c


[Bug tree-optimization/65818] [6 Regression] libiberty/vprintf-support.c:41:1: ICE: in expand_i fn_va_arg_1, at tree-stdarg.c:1095

2015-04-28 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65818

vries at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #15 from vries at gcc dot gnu.org ---
patch committed, marking resolved fixed


[Bug tree-optimization/65818] [6 Regression] libiberty/vprintf-support.c:41:1: ICE: in expand_i fn_va_arg_1, at tree-stdarg.c:1095

2015-04-26 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65818

--- Comment #13 from vries at gcc dot gnu.org ---
*** Bug 65824 has been marked as a duplicate of this bug. ***


[Bug tree-optimization/65818] [6 Regression] libiberty/vprintf-support.c:41:1: ICE: in expand_i fn_va_arg_1, at tree-stdarg.c:1095

2015-04-25 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65818

vries at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||patch

--- Comment #12 from vries at gcc dot gnu.org ---
https://gcc.gnu.org/ml/gcc-patches/2015-04/msg01543.html


[Bug tree-optimization/65818] [6 Regression] libiberty/vprintf-support.c:41:1: ICE: in expand_i fn_va_arg_1, at tree-stdarg.c:1095

2015-04-24 Thread dave.anglin at bell dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65818

--- Comment #9 from dave.anglin at bell dot net ---
On 2015-04-22, at 12:40 PM, vries at gcc dot gnu.org wrote:

 this patch is more conservative:
 ...
 diff --git a/gcc/gimplify.c b/gcc/gimplify.c
 index 7786e16..e23f510 100644
 --- a/gcc/gimplify.c
 +++ b/gcc/gimplify.c
 @@ -9336,7 +9336,12 @@ gimplify_va_arg_internal (tree valist, tree type,
 location_t loc,
   else
 gimplify_expr (valist, pre_p, post_p, is_gimple_min_lval, fb_lvalue);
 
 -  return targetm.gimplify_va_arg_expr (valist, type, pre_p, post_p);
 +  tree expr = targetm.gimplify_va_arg_expr (valist, type, pre_p, post_p);
 +  gcc_assert (TREE_CODE (expr) == MEM_REF);
 +  if (!is_gimple_mem_ref_addr (TREE_OPERAND (expr, 0)))
 +gimplify_expr (TREE_OPERAND (expr, 0), pre_p, post_p,
 +  is_gimple_mem_ref_addr, fb_rvalue);
 +  return expr;
 }
 
 /* Gimplify __builtin_va_arg, aka VA_ARG_EXPR, which is not really a

This patch has the following new failure:

/test/gnu/gcc/gcc/gcc/testsuite/g++.dg/pr65802.C: In function 'void fn1()':
/test/gnu/gcc/gcc/gcc/testsuite/g++.dg/pr65802.C:20:23: error: impossible
constraint in 'asm'

FAIL: g++.dg/pr65802.C  -std=gnu++98 (test for excess errors)
FAIL: g++.dg/pr65802.C  -std=gnu++11 (test for excess errors)
FAIL: g++.dg/pr65802.C  -std=gnu++14 (test for excess errors)

--
John David Anglindave.ang...@bell.net


[Bug tree-optimization/65818] [6 Regression] libiberty/vprintf-support.c:41:1: ICE: in expand_i fn_va_arg_1, at tree-stdarg.c:1095

2015-04-24 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65818

--- Comment #10 from vries at gcc dot gnu.org ---
(In reply to dave.anglin from comment #9)
 This patch has the following new failure:
 
 /test/gnu/gcc/gcc/gcc/testsuite/g++.dg/pr65802.C: In function 'void fn1()':
 /test/gnu/gcc/gcc/gcc/testsuite/g++.dg/pr65802.C:20:23: error: impossible
 constraint in 'asm'
 
 FAIL: g++.dg/pr65802.C  -std=gnu++98 (test for excess errors)
 FAIL: g++.dg/pr65802.C  -std=gnu++11 (test for excess errors)
 FAIL: g++.dg/pr65802.C  -std=gnu++14 (test for excess errors)
 

That failure was probably already present without the patch.  (see f.i.
https://gcc.gnu.org/ml/gcc-patches/2015-04/msg01482.html ).

I've rewritten the test-case in C and cleaned it up. It's now called
gcc.dg/pr65802.c.

I tested the new test-case with and without the updated patch, it passes in
both cases.


[Bug tree-optimization/65818] [6 Regression] libiberty/vprintf-support.c:41:1: ICE: in expand_i fn_va_arg_1, at tree-stdarg.c:1095

2015-04-24 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65818

--- Comment #11 from vries at gcc dot gnu.org ---
Bootstrap and reg-test on x86_64 also went ok for for the updated patch. I'll
submit.


[Bug tree-optimization/65818] [6 Regression] libiberty/vprintf-support.c:41:1: ICE: in expand_i fn_va_arg_1, at tree-stdarg.c:1095

2015-04-22 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65818

--- Comment #7 from vries at gcc dot gnu.org ---
Hmm, this patch has failures for x86_64:

- va_arg (ap, void):
  gcc.c-torture/compile/pr48767.c 
- vla:
  gcc.c-torture/execute/20020412-1.c
  gcc.dg/compat/struct-by-value-22
  gcc.dg/lto/20090706-1
  gcc.target/i386/memcpy-strategy-4.c

this patch is more conservative:
...
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 7786e16..e23f510 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -9336,7 +9336,12 @@ gimplify_va_arg_internal (tree valist, tree type,
location_t loc,
   else
 gimplify_expr (valist, pre_p, post_p, is_gimple_min_lval, fb_lvalue);

-  return targetm.gimplify_va_arg_expr (valist, type, pre_p, post_p);
+  tree expr = targetm.gimplify_va_arg_expr (valist, type, pre_p, post_p);
+  gcc_assert (TREE_CODE (expr) == MEM_REF);
+  if (!is_gimple_mem_ref_addr (TREE_OPERAND (expr, 0)))
+gimplify_expr (TREE_OPERAND (expr, 0), pre_p, post_p,
+  is_gimple_mem_ref_addr, fb_rvalue);
+  return expr;
 }

 /* Gimplify __builtin_va_arg, aka VA_ARG_EXPR, which is not really a
...

It allows at least pr48767.c, 20020412-1.c and memcpy-strategy-4.c to pass.


[Bug tree-optimization/65818] [6 Regression] libiberty/vprintf-support.c:41:1: ICE: in expand_i fn_va_arg_1, at tree-stdarg.c:1095

2015-04-22 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65818

--- Comment #3 from vries at gcc dot gnu.org ---
The code snippet:
...
 case 'f':
 case 'e':
 case 'E':
 case 'g':
 case 'G':
   (void) __builtin_va_arg(ap, double);
   total_width += 307;
   break;
...

translates to:
...
L23:
  VA_ARG (ap, 0B);
  total_width_70 = total_width_31 + 337;
  # DEBUG total_width = total_width_70
  goto bb 21 (L31);
...

at the end of hppa_gimplify_va_arg_expr, the result looks like:
...
(gdb) p *pre_p
$2 = (gimple_seq) 0x0
(gdb) p *post_p
$3 = (gimple_seq) 0x0
(gdb) call debug_generic_expr (t)
*(double *) (ap = ap + 4294967288  4294967288B)
...

Note that pre_p and post_p are empty, and t contains the side-effect of
assigning to ap.

Since ifn_va_arg has no lhs, the returned value is not assigned to any var in
expand_ifn_va_arg_1, and the side-effect is lost.

We need to further gimplify the expression to fix the error. [ I wonder whether
that's the responsibility of TARGET_GIMPLIFY_VA_ARG_EXPR. ]


[Bug tree-optimization/65818] [6 Regression] libiberty/vprintf-support.c:41:1: ICE: in expand_i fn_va_arg_1, at tree-stdarg.c:1095

2015-04-22 Thread dave.anglin at bell dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65818

--- Comment #8 from dave.anglin at bell dot net ---
On 2015-04-22 12:40 PM, vries at gcc dot gnu.org wrote:
 this patch is more conservative
Restarted test with updated patch.


[Bug tree-optimization/65818] [6 Regression] libiberty/vprintf-support.c:41:1: ICE: in expand_i fn_va_arg_1, at tree-stdarg.c:1095

2015-04-22 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65818

vries at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |vries at gcc dot gnu.org

--- Comment #4 from vries at gcc dot gnu.org ---
Created attachment 35383
  -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=35383action=edit
Tentative patch

This patch seems to fix the error:
...
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index c68bd47..5f1dd1a 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -9352,7 +9352,9 @@ gimplify_va_arg_internal (tree valist, tree type,
location_t loc,
   else
 gimplify_expr (valist, pre_p, post_p, is_gimple_min_lval, fb_lvalue);

-  return targetm.gimplify_va_arg_expr (valist, type, pre_p, post_p);
+  tree expr = targetm.gimplify_va_arg_expr (valist, type, pre_p, post_p);
+  gimplify_expr (expr, pre_p, post_p, is_gimple_val, fb_rvalue);
+  return expr;
 }

 /* Gimplify __builtin_va_arg, aka VA_ARG_EXPR, which is not really a
...

Before gimplify_expr:
...
(gdb) call debug_generic_expr (expr)
*(double *) (ap = ap + 4294967288  4294967288B)
...

And after gimplify_expr:
...
(gdb) call debug_generic_expr (expr)
D.3458
(gdb) call debug_gimple_seq (*pre_p)
ap.13 = ap;
D.3456 = ap.13 + 4294967288;
ap.14 = D.3456  4294967288B;
ap = ap.14;
ap.13 = ap;
D.3458 = MEM[(double *)ap.13];
...


[Bug tree-optimization/65818] [6 Regression] libiberty/vprintf-support.c:41:1: ICE: in expand_i fn_va_arg_1, at tree-stdarg.c:1095

2015-04-22 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65818

--- Comment #5 from vries at gcc dot gnu.org ---
Dave,

could you please test the patch on hppa?

Thanks,
- Tom


[Bug tree-optimization/65818] [6 Regression] libiberty/vprintf-support.c:41:1: ICE: in expand_i fn_va_arg_1, at tree-stdarg.c:1095

2015-04-22 Thread dave.anglin at bell dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65818

--- Comment #6 from dave.anglin at bell dot net ---
On 2015-04-22, at 3:15 AM, vries at gcc dot gnu.org wrote:

 could you please test the patch on hppa?

Started.  Thanks for the patch.

Dave
--
John David Anglindave.ang...@bell.net


[Bug tree-optimization/65818] [6 Regression] libiberty/vprintf-support.c:41:1: ICE: in expand_i fn_va_arg_1, at tree-stdarg.c:1095

2015-04-21 Thread vries at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65818

vries at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2015-04-21
 CC||vries at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #2 from vries at gcc dot gnu.org ---
Reproduced.


[Bug tree-optimization/65818] [6 Regression] libiberty/vprintf-support.c:41:1: ICE: in expand_i fn_va_arg_1, at tree-stdarg.c:1095

2015-04-21 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65818

Richard Biener rguenth at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||build
 CC||tom at codesourcery dot com
   Target Milestone|--- |6.0
Summary|libiberty/vprintf-support.c |[6 Regression]
   |:41:1: ICE: in expand_i |libiberty/vprintf-support.c
   |fn_va_arg_1, at |:41:1: ICE: in expand_i
   |tree-stdarg.c:1095  |fn_va_arg_1, at
   ||tree-stdarg.c:1095