On Sat, Jan 22, 2022 at 1:50 AM Jakub Jelinek via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi!
>
> This is incremental patch to fix up -fsanitize-coverage= option
> handling, allow -fno-sanitize-coverage= again, allow both
> options together in one option or make
> -fsanitize-coverage=trace-pc -fsanitize-coverage=trace-cmp
> actually enable both suboptions rather than the last one.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

> 2022-01-21  Jakub Jelinek  <ja...@redhat.com>
>
>         PR sanitizer/104158
>         * common.opt (flag_sanitize_coverage): Remove Variable entry.
>         (fsanitize-coverage=): Remove RejectNegative property, add
>         Var(flag_sanitize_coverage) and EnumSet properties.
>         (trace-pc): Add Set(1) property.
>         (trace-cmp): Add Set(2) property.
>         * opts.cc (common_handle_option): Don't handle
>         OPT_fsanitize_coverage_.
>
>         * gcc.dg/spellcheck-options-24.c: New test.
>         * gcc.dg/sancov/pr104158-1.c: New test.
>         * gcc.dg/sancov/pr104158-2.c: New test.
>         * gcc.dg/sancov/pr104158-3.c: New test.
>         * gcc.dg/sancov/pr104158-4.c: New test.
>         * gcc.dg/sancov/pr104158-5.c: New test.
>         * gcc.dg/sancov/pr104158-6.c: New test.
>         * gcc.dg/sancov/pr104158-7.c: New test.
>
> --- gcc/common.opt.jj   2022-01-18 11:58:58.975990728 +0100
> +++ gcc/common.opt      2022-01-21 17:03:46.261364018 +0100
> @@ -223,10 +223,6 @@ unsigned int flag_sanitize
>  Variable
>  unsigned int flag_sanitize_recover = (SANITIZE_UNDEFINED | 
> SANITIZE_UNDEFINED_NONDEFAULT | SANITIZE_KERNEL_ADDRESS | 
> SANITIZE_KERNEL_HWADDRESS) & ~(SANITIZE_UNREACHABLE | SANITIZE_RETURN)
>
> -; What the coverage sanitizers should instrument
> -Variable
> -unsigned int flag_sanitize_coverage
> -
>  ; Flag whether a prefix has been added to dump_base_name
>  Variable
>  bool dump_base_name_prefixed = false
> @@ -1076,17 +1072,17 @@ Common Driver Joined
>  Select what to sanitize.
>
>  fsanitize-coverage=
> -Common Joined RejectNegative Enum(sanitize_coverage)
> +Common Joined Enum(sanitize_coverage) Var(flag_sanitize_coverage) EnumSet
>  Select type of coverage sanitization.
>
>  Enum
>  Name(sanitize_coverage) Type(int)
>
>  EnumValue
> -Enum(sanitize_coverage) String(trace-pc) Value(SANITIZE_COV_TRACE_PC)
> +Enum(sanitize_coverage) String(trace-pc) Value(SANITIZE_COV_TRACE_PC) Set(1)
>
>  EnumValue
> -Enum(sanitize_coverage) String(trace-cmp) Value(SANITIZE_COV_TRACE_CMP)
> +Enum(sanitize_coverage) String(trace-cmp) Value(SANITIZE_COV_TRACE_CMP) 
> Set(2)
>
>  fasan-shadow-offset=
>  Common Joined RejectNegative Var(common_deferred_options) Defer
> --- gcc/opts.cc.jj      2022-01-20 11:30:45.595577895 +0100
> +++ gcc/opts.cc 2022-01-21 19:44:56.770505499 +0100
> @@ -2621,10 +2621,6 @@ common_handle_option (struct gcc_options
>           &= ~(SANITIZE_UNDEFINED | SANITIZE_UNDEFINED_NONDEFAULT);
>        break;
>
> -    case OPT_fsanitize_coverage_:
> -      opts->x_flag_sanitize_coverage = value;
> -      break;
> -
>      case OPT_O:
>      case OPT_Os:
>      case OPT_Ofast:
> --- gcc/testsuite/gcc.dg/spellcheck-options-24.c.jj     2022-01-21 
> 20:14:19.549779106 +0100
> +++ gcc/testsuite/gcc.dg/spellcheck-options-24.c        2022-01-21 
> 20:14:38.555512955 +0100
> @@ -0,0 +1,5 @@
> +/* { dg-do compile } */
> +/* { dg-options "-fsanitize-coverage=trace-pc,tracecmp" } */
> +
> +/* { dg-error "unrecognized argument in option 
> '-fsanitize-coverage=trace-pc,tracecmp'" "" { target *-*-* } 0 } */
> +/* { dg-message "valid arguments to '-fsanitize-coverage=' are: trace-cmp 
> trace-pc; did you mean 'trace-cmp'?" "" { target *-*-* } 0 } */
> --- gcc/testsuite/gcc.dg/sancov/pr104158-1.c.jj 2022-01-21 20:08:17.878843831 
> +0100
> +++ gcc/testsuite/gcc.dg/sancov/pr104158-1.c    2022-01-21 20:03:48.824612895 
> +0100
> @@ -0,0 +1,11 @@
> +/* PR sanitizer/104158 */
> +/* { dg-do compile } */
> +/* { dg-options "-fsanitize-coverage=trace-cmp -fdump-tree-optimized" } */
> +/* { dg-final { scan-tree-dump "__sanitizer_cov_trace_cmp" "optimized" } } */
> +/* { dg-final { scan-tree-dump-not "__sanitizer_cov_trace_pc" "optimized" } 
> } */
> +
> +int
> +foo (int a, int b)
> +{
> +  return a == b;
> +}
> --- gcc/testsuite/gcc.dg/sancov/pr104158-2.c.jj 2022-01-21 20:08:17.879843817 
> +0100
> +++ gcc/testsuite/gcc.dg/sancov/pr104158-2.c    2022-01-21 20:04:18.116201478 
> +0100
> @@ -0,0 +1,11 @@
> +/* PR sanitizer/104158 */
> +/* { dg-do compile } */
> +/* { dg-options "-fsanitize-coverage=trace-pc -fdump-tree-optimized" } */
> +/* { dg-final { scan-tree-dump-not "__sanitizer_cov_trace_cmp" "optimized" } 
> } */
> +/* { dg-final { scan-tree-dump "__sanitizer_cov_trace_pc" "optimized" } } */
> +
> +int
> +foo (int a, int b)
> +{
> +  return a == b;
> +}
> --- gcc/testsuite/gcc.dg/sancov/pr104158-3.c.jj 2022-01-21 20:08:17.880843803 
> +0100
> +++ gcc/testsuite/gcc.dg/sancov/pr104158-3.c    2022-01-21 20:05:42.747016252 
> +0100
> @@ -0,0 +1,11 @@
> +/* PR sanitizer/104158 */
> +/* { dg-do compile } */
> +/* { dg-options "-fsanitize-coverage=trace-cmp,trace-pc 
> -fdump-tree-optimized" } */
> +/* { dg-final { scan-tree-dump "__sanitizer_cov_trace_cmp" "optimized" } } */
> +/* { dg-final { scan-tree-dump "__sanitizer_cov_trace_pc" "optimized" } } */
> +
> +int
> +foo (int a, int b)
> +{
> +  return a == b;
> +}
> --- gcc/testsuite/gcc.dg/sancov/pr104158-4.c.jj 2022-01-21 20:08:17.881843789 
> +0100
> +++ gcc/testsuite/gcc.dg/sancov/pr104158-4.c    2022-01-21 20:06:01.503753588 
> +0100
> @@ -0,0 +1,11 @@
> +/* PR sanitizer/104158 */
> +/* { dg-do compile } */
> +/* { dg-options "-fsanitize-coverage=trace-pc,trace-cmp 
> -fdump-tree-optimized" } */
> +/* { dg-final { scan-tree-dump "__sanitizer_cov_trace_cmp" "optimized" } } */
> +/* { dg-final { scan-tree-dump "__sanitizer_cov_trace_pc" "optimized" } } */
> +
> +int
> +foo (int a, int b)
> +{
> +  return a == b;
> +}
> --- gcc/testsuite/gcc.dg/sancov/pr104158-5.c.jj 2022-01-21 20:08:17.882843775 
> +0100
> +++ gcc/testsuite/gcc.dg/sancov/pr104158-5.c    2022-01-21 20:06:49.097087106 
> +0100
> @@ -0,0 +1,11 @@
> +/* PR sanitizer/104158 */
> +/* { dg-do compile } */
> +/* { dg-options "-fsanitize-coverage=trace-cmp -fsanitize-coverage=trace-pc 
> -fno-sanitize-coverage=trace-cmp -fdump-tree-optimized" } */
> +/* { dg-final { scan-tree-dump-not "__sanitizer_cov_trace_cmp" "optimized" } 
> } */
> +/* { dg-final { scan-tree-dump "__sanitizer_cov_trace_pc" "optimized" } } */
> +
> +int
> +foo (int a, int b)
> +{
> +  return a == b;
> +}
> --- gcc/testsuite/gcc.dg/sancov/pr104158-6.c.jj 2022-01-21 20:08:17.883843761 
> +0100
> +++ gcc/testsuite/gcc.dg/sancov/pr104158-6.c    2022-01-21 20:07:30.972500694 
> +0100
> @@ -0,0 +1,11 @@
> +/* PR sanitizer/104158 */
> +/* { dg-do compile } */
> +/* { dg-options "-fsanitize-coverage=trace-cmp -fsanitize-coverage=trace-pc 
> -fno-sanitize-coverage=trace-pc,trace-cmp -fdump-tree-optimized" } */
> +/* { dg-final { scan-tree-dump-not "__sanitizer_cov_trace_cmp" "optimized" } 
> } */
> +/* { dg-final { scan-tree-dump-not "__sanitizer_cov_trace_pc" "optimized" } 
> } */
> +
> +int
> +foo (int a, int b)
> +{
> +  return a == b;
> +}
> --- gcc/testsuite/gcc.dg/sancov/pr104158-7.c.jj 2022-01-21 20:08:17.884843747 
> +0100
> +++ gcc/testsuite/gcc.dg/sancov/pr104158-7.c    2022-01-21 20:10:18.647152626 
> +0100
> @@ -0,0 +1,5 @@
> +/* PR sanitizer/104158 */
> +/* { dg-do compile } */
> +/* { dg-options "-fsanitize-coverage=trace-cmp,trace-cmp 
> -fdump-tree-optimized" } */
> +/* { dg-error "invalid argument in option 
> '-fsanitize-coverage=trace-cmp,trace-cmp'" "" { target *-*-* } 0 } */
> +/* { dg-message "'trace-cmp' specified multiple times in the same option" "" 
> { target *-*-* } 0 } */
>
>         Jakub
>

Reply via email to