public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <rguenther@suse.de>
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH] Avoid weird -Wpsabi warnings from NRV (PR target/80310)
Date: Tue, 04 Apr 2017 19:29:00 -0000	[thread overview]
Message-ID: <20170404192919.GM17461@tucnak> (raw)

Hi!

When I've implemented vector -fsanitize=signed-integer-overflow,
we've started to emit weirdo warnings on e.g. the following testcase.

There is really no call with return value that changes ABI
based on ISA options, there is just an internal fn call that is expanded
completely inline (UBSAN_CHECK_*), but as the NRV pass calls
aggregate_value_p even on those internal functions, we get the warning.

The following patch keeps doing that for internal functions that have
corresponding optab, those typically have a library counterpart, but
for others that really don't have one and are always expanded inline
avoids calling aggregate_value_p, we really can't NRV optimize those
internal fns anyway.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 

2017-04-04  Jakub Jelinek  <jakub@redhat.com>

	PR target/80310
	* tree-nvr.c: Include internal-fn.h.
	(pass_return_slot::execute): Ignore internal calls without
	direct optab.

	* c-c++-common/ubsan/pr80310.c: New test.

--- gcc/tree-nrv.c.jj	2017-01-01 12:45:39.000000000 +0100
+++ gcc/tree-nrv.c	2017-04-04 15:51:54.864211786 +0200
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3.
 #include "tree-pretty-print.h"
 #include "gimple-iterator.h"
 #include "gimple-walk.h"
+#include "internal-fn.h"
 
 /* This file implements return value optimizations for functions which
    return aggregate types.
@@ -377,6 +378,12 @@ pass_return_slot::execute (function *fun
 	  if (stmt
 	      && gimple_call_lhs (stmt)
 	      && !gimple_call_return_slot_opt_p (stmt)
+	      /* Ignore internal functions without direct optabs,
+		 those are expanded specially and aggregate_value_p
+		 on their result might result in undesirable warnings
+		 with some backends.  */
+	      && (!gimple_call_internal_p (stmt)
+		  || direct_internal_fn_p (gimple_call_internal_fn (stmt)))
 	      && aggregate_value_p (TREE_TYPE (gimple_call_lhs (stmt)),
 				    gimple_call_fndecl (stmt)))
 	    {
--- gcc/testsuite/c-c++-common/ubsan/pr80310.c.jj	2017-04-04 16:13:35.108407423 +0200
+++ gcc/testsuite/c-c++-common/ubsan/pr80310.c	2017-04-04 16:12:24.000000000 +0200
@@ -0,0 +1,12 @@
+/* PR target/80310 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fsanitize=signed-integer-overflow" } */
+/* { dg-additional-options "-mno-avx" { target i?86-*-* x86_64-*-* } } */
+
+typedef int V __attribute__((vector_size (32)));
+
+void
+foo (V *a, V *b, V *c)
+{
+  *a = *b + *c;		/* { dg-bogus "AVX vector return without AVX enabled changes the ABI" "" { target i?86-*-* x86_64-*-* } } */
+}

	Jakub

             reply	other threads:[~2017-04-04 19:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04 19:29 Jakub Jelinek [this message]
2017-04-04 20:38 ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170404192919.GM17461@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).