diff mbox series

[committed] Fix va_arg gimplification on powerpc{,spe} (PR target/84772)

Message ID 20180309222902.GI8577@tucnak
State New
Headers show
Series [committed] Fix va_arg gimplification on powerpc{,spe} (PR target/84772) | expand

Commit Message

Jakub Jelinek March 9, 2018, 10:29 p.m. UTC
Hi!

The following is a powerpcspe variant of the sparc PR39645, and rs6000
has the same code (not sure if ever used or dead after powerpcspe removal).
When gimplifying the builtin, because va_arg_tmp.N is not marked as
addressable from the beginning, we call prepare_gimple_addressable which
assigns the previous value (uninitialized in this case) into the now
addressable variable and nothing optimizes it away.  Fixed by making it
addressable from the beginning.

Bootstrapped/regtested on {x86_64,i686,powerpc64{,le}}-linux
and tested with a cross to powerpcspe-linux on the testcase, committed as
obvious to trunk.

2018-03-09  Jakub Jelinek  <jakub@redhat.com>

	PR target/84772
	* config/rs6000/rs6000.c (rs6000_gimplify_va_arg): Mark va_arg_tmp
	temporary TREE_ADDRESSABLE before gimplification of BUILT_IN_MEMCPY.
	* config/powerpcspe/powerpcspe.c (rs6000_gimplify_va_arg): Likewise.

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


	Jakub

Comments

Segher Boessenkool March 10, 2018, 10:45 p.m. UTC | #1
Hi,

On Fri, Mar 09, 2018 at 11:29:02PM +0100, Jakub Jelinek wrote:
> The following is a powerpcspe variant of the sparc PR39645, and rs6000
> has the same code (not sure if ever used or dead after powerpcspe removal).

It's not dead, this code is for the SVR4 ABI, used on most 32-bit targets
(including powerpc-linux).

Thanks for the patch,


Segher
diff mbox series

Patch

--- gcc/config/rs6000/rs6000.c.jj	2018-03-07 22:52:01.294479625 +0100
+++ gcc/config/rs6000/rs6000.c	2018-03-09 17:29:09.811949947 +0100
@@ -13537,6 +13537,7 @@  rs6000_gimplify_va_arg (tree valist, tre
 
       tree copy = build_call_expr (builtin_decl_implicit (BUILT_IN_MEMCPY),
 				   3, dest_addr, addr, size_int (rsize * 4));
+      TREE_ADDRESSABLE (tmp) = 1;
 
       gimplify_and_add (copy, pre_p);
       addr = dest_addr;
--- gcc/config/powerpcspe/powerpcspe.c.jj	2018-01-03 10:20:14.842537106 +0100
+++ gcc/config/powerpcspe/powerpcspe.c	2018-03-09 17:29:35.291959951 +0100
@@ -14254,6 +14254,7 @@  rs6000_gimplify_va_arg (tree valist, tre
 
       tree copy = build_call_expr (builtin_decl_implicit (BUILT_IN_MEMCPY),
 				   3, dest_addr, addr, size_int (rsize * 4));
+      TREE_ADDRESSABLE (tmp) = 1;
 
       gimplify_and_add (copy, pre_p);
       addr = dest_addr;
--- gcc/testsuite/gcc.dg/pr84772.c.jj	2018-03-09 17:34:56.732749975 +0100
+++ gcc/testsuite/gcc.dg/pr84772.c	2018-03-09 17:33:05.095042322 +0100
@@ -0,0 +1,13 @@ 
+/* PR target/84772 */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized" } */
+
+#include <stdarg.h>
+
+void
+foo (int *x, int y, va_list ap)
+{
+  __builtin_memset (x, 0, sizeof (int));
+  for (int i = 0; i < y; i++)
+    va_arg (ap, long double);			/* { dg-bogus "uninitialized" } */  
+}