diff mbox

[CHKP] Don't try to optimize bounds returned by strchr

Message ID 20141202134000.GD2963@msticlxl57.ims.intel.com
State New
Headers show

Commit Message

Ilya Enkovich Dec. 2, 2014, 1:40 p.m. UTC
Hi,

For strchr calls bounds of the first argument are considered as returned which is wrong because NULL may be returned.  This patch fixes that.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  OK for trunk?

Thanks,
Ilya
--
2014-12-02  Ilya Enkovich  <ilya.enkovich@intel.com>

	* tree-chkp.c (chkp_build_returned_bound): Don't predict
	return bounds for strchr calls.

Comments

Jeff Law Dec. 5, 2014, 10:55 p.m. UTC | #1
On 12/02/14 06:40, Ilya Enkovich wrote:
> Hi,
>
> For strchr calls bounds of the first argument are considered as returned which is wrong because NULL may be returned.  This patch fixes that.  Bootstrapped and tested on x86_64-unknown-linux-gnu.  OK for trunk?
>
> Thanks,
> Ilya
> --
> 2014-12-02  Ilya Enkovich  <ilya.enkovich@intel.com>
>
> 	* tree-chkp.c (chkp_build_returned_bound): Don't predict
> 	return bounds for strchr calls.
OK.

Do you have a testcase you could add to the suite?

Jeff
Ilya Enkovich Dec. 8, 2014, 10:05 a.m. UTC | #2
2014-12-06 1:55 GMT+03:00 Jeff Law <law@redhat.com>:
> On 12/02/14 06:40, Ilya Enkovich wrote:
>>
>> Hi,
>>
>> For strchr calls bounds of the first argument are considered as returned
>> which is wrong because NULL may be returned.  This patch fixes that.
>> Bootstrapped and tested on x86_64-unknown-linux-gnu.  OK for trunk?
>>
>> Thanks,
>> Ilya
>> --
>> 2014-12-02  Ilya Enkovich  <ilya.enkovich@intel.com>
>>
>>         * tree-chkp.c (chkp_build_returned_bound): Don't predict
>>         return bounds for strchr calls.
>
> OK.
>
> Do you have a testcase you could add to the suite?

I cannot add a nice test for bounds returned by strchr for NULL until
it is wrapped (which will happen eventually).

Thanks,
Ilya


>
> Jeff
>
diff mbox

Patch

diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index f7def51..1d91aa6 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -2163,8 +2163,7 @@  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)
-	   || gimple_call_builtin_p (call, BUILT_IN_STRCHR))
+  else if (gimple_call_return_flags (call) & ERF_RETURNS_ARG)
     {
       gimple_stmt_iterator iter = gsi_for_stmt (call);
       unsigned int retarg = 0, argno;