public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom de Vries <Tom_deVries@mentor.com>
To: Renlin Li <renlin.li@foss.arm.com>,
	"gcc-patches@gcc.gnu.org"	<gcc-patches@gcc.gnu.org>,
	Martin Sebor <msebor@gmail.com>,	<richard.sandiford@arm.com>
Subject: Re: [PATCH][Testsuite] Use user defined memmove in gcc.c-torture/execute/builtins/memops-asm-lib.c
Date: Sun, 06 Aug 2017 08:45:00 -0000	[thread overview]
Message-ID: <e351605d-58c8-0fcb-7ebc-dfc268f16781@mentor.com> (raw)
In-Reply-To: <594CDD3A.9090902@foss.arm.com>

[-- Attachment #1: Type: text/plain, Size: 899 bytes --]

On 06/23/2017 11:19 AM, Renlin Li wrote:
> +__attribute__ ((used))
> +void
> +my_memmove (void *d, const void *s, size_t n)
> +{
> +  char *dst = (char *) d;
> +  const char *src = (const char *) s;
> +  if (src >= dst)
> +    while (n--)
> +      *dst++ = *src++;
> +  else
> +    {
> +      dst += n;
> +      src += n;
> +      while (n--)
> +	*--dst = *--src;
> +    }
> +}
> +

The memops-asm.c testcase fails for nvptx because of a mismatch between 
function definition and function declaration for my_memmove in the 
generated nvptx code.

man memmove show us that memmove returns a 'void *', not 'void':
...
        void *memmove(void *dest, const void *src, size_t n);
...

and that it returns its first argument (well, the formulation could be 
improved):
...
RETURN VALUE
        The memmove() function returns a pointer to dest.
...


Fixed in attached patch.

Committed.

Thanks,
- Tom

[-- Attachment #2: 0001-Fix-my_memmove-in-gcc.c-torture-execute-builtins-memops-asm-lib.c.patch --]
[-- Type: text/x-patch, Size: 1047 bytes --]

Fix my_memmove in gcc.c-torture/execute/builtins/memops-asm-lib.c

2017-08-06  Tom de Vries  <tom@codesourcery.com>

	* gcc.c-torture/execute/builtins/memops-asm-lib.c (my_memmove):  Fix return
	type.  Add missing return.

---
 gcc/testsuite/gcc.c-torture/execute/builtins/memops-asm-lib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.c-torture/execute/builtins/memops-asm-lib.c b/gcc/testsuite/gcc.c-torture/execute/builtins/memops-asm-lib.c
index 25d4a40..3baf7a6 100644
--- a/gcc/testsuite/gcc.c-torture/execute/builtins/memops-asm-lib.c
+++ b/gcc/testsuite/gcc.c-torture/execute/builtins/memops-asm-lib.c
@@ -38,7 +38,7 @@ my_bcopy (const void *s, void *d, size_t n)
 }
 
 __attribute__ ((used))
-void
+void *
 my_memmove (void *d, const void *s, size_t n)
 {
   char *dst = (char *) d;
@@ -53,6 +53,8 @@ my_memmove (void *d, const void *s, size_t n)
       while (n--)
 	*--dst = *--src;
     }
+
+  return d;
 }
 
 /* LTO code is at the present to able to track that asm alias my_bcopy on builtin

      parent reply	other threads:[~2017-08-06  8:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-23  9:20 Renlin Li
2017-06-23 15:27 ` Martin Sebor
2017-06-23 16:10   ` Renlin Li
2017-06-23 17:11 ` Jeff Law
2017-08-06  8:45 ` Tom de Vries [this message]

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=e351605d-58c8-0fcb-7ebc-dfc268f16781@mentor.com \
    --to=tom_devries@mentor.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=msebor@gmail.com \
    --cc=renlin.li@foss.arm.com \
    --cc=richard.sandiford@arm.com \
    /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).