[PATCH 2/5] Get bounds for a PARM_DECL (PR ipa/79761).

Richard Biener richard.guenther@gmail.com
Wed Mar 8 11:01:00 GMT 2017


On Tue, Mar 7, 2017 at 5:07 PM, Martin Liška <mliska@suse.cz> wrote:
> On 03/07/2017 03:57 PM, Richard Biener wrote:
>> On Thu, Mar 2, 2017 at 6:06 PM, marxin <mliska@suse.cz> wrote:
>>> gcc/ChangeLog:
>>>
>>> 2017-03-06  Martin Liska  <mliska@suse.cz>
>>>
>>>         PR ipa/79761
>>>         * tree-chkp.c (chkp_get_bound_for_parm): Get bounds for a param.
>>>         (chkp_find_bounds_1): Remove gcc_unreachable.
>>>
>>> gcc/testsuite/ChangeLog:
>>>
>>> 2017-03-06  Martin Liska  <mliska@suse.cz>
>>>
>>>         PR ipa/79761
>>>         * g++.dg/pr79761.C: New test.
>>> ---
>>>  gcc/testsuite/g++.dg/pr79761.C | 34 ++++++++++++++++++++++++++++++++++
>>>  gcc/tree-chkp.c                |  3 +--
>>>  2 files changed, 35 insertions(+), 2 deletions(-)
>>>  create mode 100644 gcc/testsuite/g++.dg/pr79761.C
>>>
>>> diff --git a/gcc/testsuite/g++.dg/pr79761.C b/gcc/testsuite/g++.dg/pr79761.C
>>> new file mode 100644
>>> index 00000000000..b1f92d2b036
>>> --- /dev/null
>>> +++ b/gcc/testsuite/g++.dg/pr79761.C
>>> @@ -0,0 +1,34 @@
>>> +/* { dg-do compile { target { ! x32 } } } */
>>> +/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */
>>> +
>>> +struct Foo
>>> +{
>>> +  Foo() : a(1), b(1), c('a') {}
>>> +  int a;
>>> +  int b;
>>> +  char c;
>>> +};
>>> +
>>> +static Foo copy_foo(Foo) __attribute__((noinline, noclone));
>>> +
>>> +static Foo copy_foo(Foo A)
>>> +{
>>> +  return A;
>>> +}
>>> +
>>> +struct Bar : Foo
>>> +{
>>> +  Bar(Foo t) : Foo(copy_foo(t)) {}
>>> +};
>>> +
>>> +Foo F;
>>> +
>>> +int main (void)
>>> +{
>>> +  Bar B (F);
>>> +
>>> +  if (B.a != 1 || B.b != 1 || B.c != 'a')
>>> +    __builtin_abort ();
>>> +
>>> +  return 0;
>>> +}
>>> diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
>>> index 3d497f51ed8..d5683b1b9cf 100644
>>> --- a/gcc/tree-chkp.c
>>> +++ b/gcc/tree-chkp.c
>>> @@ -2353,7 +2353,7 @@ chkp_get_next_bounds_parm (tree parm)
>>>  static tree
>>>  chkp_get_bound_for_parm (tree parm)
>>>  {
>>> -  tree decl = SSA_NAME_VAR (parm);
>>> +  tree decl = TREE_CODE (parm) == PARM_DECL ? parm : SSA_NAME_VAR (parm);
>>>    tree bounds;
>>>
>>>    gcc_assert (TREE_CODE (decl) == PARM_DECL);
>>> @@ -3602,7 +3602,6 @@ chkp_find_bounds_1 (tree ptr, tree ptr_src, gimple_stmt_iterator *iter)
>>>        break;
>>>
>>>      case PARM_DECL:
>>> -      gcc_unreachable ();
>>>        bounds = chkp_get_bound_for_parm (ptr_src);
>>
>> But this is just useless work ... just do
>>
>>       case PARM_DECL:
>>          /* Handled above but failed.  */
>>          break;
>
> Ok, let's return invalid bounds. Please see updated patch.

Ok.

> Martin
>
>>
>> the SSA_NAME case is similarly redundantly calling chkp_get_registered_bounds.
>>
>> Richard.
>>
>>>        break;
>>>
>>> --
>>> 2.11.1
>>>
>>>
>



More information about the Gcc-patches mailing list