Indu Bhagat <indu.bha...@oracle.com> writes:
>>> [...]
>>> diff --git a/gcc/opts.cc b/gcc/opts.cc
>>> index 86c6691ecec4..00db662c32ef 100644
>>> --- a/gcc/opts.cc
>>> +++ b/gcc/opts.cc
>>> [...]
>>> @@ -2780,6 +2788,13 @@ common_handle_option (struct gcc_options *opts,
>>>       SET_OPTION_IF_UNSET (opts, opts_set,
>>>                            param_hwasan_instrument_allocas, 0);
>>>     }
>>> +      /* Memtag sanitizer implies HWASAN but with tags always generated by 
>>> the
>>> +    hardware randomly.  */
>>> +      if (opts->x_flag_sanitize & SANITIZE_MEMTAG)
>>> +   {
>>> +     SET_OPTION_IF_UNSET (opts, opts_set,
>>> +                          param_hwasan_random_frame_tag, 1);
>>> +   }
>> 
>> Does this have any effect in practice?  The default seems to be 1,
>> so I would expect this to be a nop.  The pattern elsewhere in the
>> sanitiser code seems to be to use SET_OPTION_IF_UNSET only to turn
>> features off.
>> 
>
> You're right.  This can be removed.
>
> I recall now that what I wanted to achieve was to render users' usage of 
> "--param hwasan-random-frame-tag=0" non-consequential when memtag 
> sanitizer is in effect.
>
> Looks like I need to handle in finish_options ().  Something like:
>
>    if ((opts->x_flag_sanitize & SANITIZE_MEMTAG_STACK)
>        && opts->x_param_hwasan_random_frame_tag == 0)
>      {
>         warning_at (loc, OPT_fsanitize_,
>                     "%<--param hwasan-random-frame-tag=0%> is not 
> supported with"
>                     "%<-fsanitize=memtag-stack%>");
>         opts->x_param_hwasan_random_frame_tag = 1;
>      }

LGTM, although there's a missing space in the string continuation.

Richard

Reply via email to