From 0bf927521ce1e84b41a9bc9e0ef0add63bd3a9a3 Mon Sep 17 00:00:00 2001 From: jakub Date: Mon, 23 Mar 2015 20:03:50 +0000 Subject: [PATCH] PR target/65523 * tree-chkp.c (chkp_build_returned_bound): Ignore ERF_RETURNS_ARG calls if they have fewer than needed arguments. * gcc.target/i386/pr65523.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@221606 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.target/i386/pr65523.c | 11 +++++++++++ gcc/tree-chkp.c | 8 ++++---- 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr65523.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2df46f5..97c0afd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-03-23 Jakub Jelinek + + PR target/65523 + * tree-chkp.c (chkp_build_returned_bound): Ignore + ERF_RETURNS_ARG calls if they have fewer than needed arguments. + 2015-03-23 Oleg Endo PR target/65505 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b612abc..b9f8dc2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2015-03-23 Jakub Jelinek + PR target/65523 + * gcc.target/i386/pr65523.c: New test. + PR ipa/65475 * g++.dg/lto/pr65475_0.C: Use dg-lto-options instead of dg-options. diff --git a/gcc/testsuite/gcc.target/i386/pr65523.c b/gcc/testsuite/gcc.target/i386/pr65523.c new file mode 100644 index 0000000..5a25f50 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr65523.c @@ -0,0 +1,11 @@ +/* PR target/65523 */ +/* { dg-do compile } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + +void *memmove (); + +void * +bar () +{ + return memmove (); +} diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index d2df4ba..977c460 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -2153,6 +2153,7 @@ chkp_build_returned_bound (gcall *call) tree bounds; gimple stmt; tree fndecl = gimple_call_fndecl (call); + unsigned int retflags; /* To avoid fixing alloca expands in targets we handle it separately. */ @@ -2196,12 +2197,11 @@ chkp_build_returned_bound (gcall *call) } /* Do not use retbnd when returned bounds are equal to some of passed bounds. */ - else if (gimple_call_return_flags (call) & ERF_RETURNS_ARG) + else if (((retflags = gimple_call_return_flags (call)) & ERF_RETURNS_ARG) + && (retflags & ERF_RETURN_ARG_MASK) < gimple_call_num_args (call)) { gimple_stmt_iterator iter = gsi_for_stmt (call); - unsigned int retarg = 0, argno; - if (gimple_call_return_flags (call) & ERF_RETURNS_ARG) - retarg = gimple_call_return_flags (call) & ERF_RETURN_ARG_MASK; + unsigned int retarg = retflags & ERF_RETURN_ARG_MASK, argno; if (gimple_call_with_bounds_p (call)) { for (argno = 0; argno < gimple_call_num_args (call); argno++) -- 2.7.4