On Thu, Feb 14, 2019 at 3:09 AM Jakub Jelinek <ja...@redhat.com> wrote:
>
> Hi!
>
> The following patch adds testcase coverage to make sure
> -f{,no-}sanitize{,-recover}= options are all passed to the compiler backend
> from the driver.
>
> All these tests were broken by the earlier option handling patch from H.J.:
> https://gcc.gnu.org/ml/gcc-patches/2019-02/msg00492.html
> and as nothing in the testsuite revealed the patch broke this, I think we
> want to cover this in the testsuite.
>
> Tested on x86_64-linux with
> make check-gcc check-c++-all RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} 
> ubsan.exp=opts*'
> with current trunk (all tests PASS) and with trunk patched with the above
> patch (all tests FAIL).  Ok for trunk?
>
> 2019-02-14  Jakub Jelinek  <ja...@redhat.com>
>
>         * c-c++-common/ubsan/opts-1.c: New test.
>         * c-c++-common/ubsan/opts-2.c: New test.
>         * c-c++-common/ubsan/opts-3.c: New test.
>         * c-c++-common/ubsan/opts-4.c: New test.

I got

UNRESOLVED: c-c++-common/ubsan/opts-1.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-times
optimized "__ubsan_handle_divrem_overflow" 2
UNRESOLVED: c-c++-common/ubsan/opts-1.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-times
optimized "__ubsan_handle_shift_out_of_bounds" 1
UNRESOLVED: c-c++-common/ubsan/opts-2.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-times
optimized "__ubsan_handle_divrem_overflow" 2
UNRESOLVED: c-c++-common/ubsan/opts-2.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-not
optimized "__ubsan_handle_shift_out_of_bounds"
UNRESOLVED: c-c++-common/ubsan/opts-3.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-times
optimized "__ubsan_handle_divrem_overflow" 1
UNRESOLVED: c-c++-common/ubsan/opts-3.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-not
optimized "__ubsan_handle_shift_out_of_bounds"
UNRESOLVED: c-c++-common/ubsan/opts-4.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-times
optimized "__ubsan_handle_divrem_overflow_abort" 1
UNRESOLVED: c-c++-common/ubsan/opts-4.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-times
optimized "__ubsan_handle_shift_out_of_bounds_abort" 1
UNRESOLVED: c-c++-common/ubsan/opts-4.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-times
optimized "__ubsan_handle_type_mismatch_v1" 1
UNRESOLVED: c-c++-common/ubsan/opts-4.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-not
optimized "__ubsan_handle_type_mismatch_v1_abort"
UNRESOLVED: c-c++-common/ubsan/opts-1.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-times
optimized "__ubsan_handle_divrem_overflow" 2
UNRESOLVED: c-c++-common/ubsan/opts-1.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-times
optimized "__ubsan_handle_shift_out_of_bounds" 1
UNRESOLVED: c-c++-common/ubsan/opts-2.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-times
optimized "__ubsan_handle_divrem_overflow" 2
UNRESOLVED: c-c++-common/ubsan/opts-2.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-not
optimized "__ubsan_handle_shift_out_of_bounds"
UNRESOLVED: c-c++-common/ubsan/opts-3.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-times
optimized "__ubsan_handle_divrem_overflow" 1
UNRESOLVED: c-c++-common/ubsan/opts-3.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-not
optimized "__ubsan_handle_shift_out_of_bounds"
UNRESOLVED: c-c++-common/ubsan/opts-4.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-times
optimized "__ubsan_handle_divrem_overflow_abort" 1
UNRESOLVED: c-c++-common/ubsan/opts-4.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-times
optimized "__ubsan_handle_shift_out_of_bounds_abort" 1
UNRESOLVED: c-c++-common/ubsan/opts-4.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-times
optimized "__ubsan_handle_type_mismatch_v1" 1
UNRESOLVED: c-c++-common/ubsan/opts-4.c   -O2 -flto
-fuse-linker-plugin -fno-fat-lto-objects   scan-tree-dump-not
optimized "__ubsan_handle_type_mismatch_v1_abort"

since  -flto suppresses -fdump-tree-optimized.

H.J.
> --- gcc/testsuite/c-c++-common/ubsan/opts-1.c.jj        2019-02-14 
> 11:31:33.144895232 +0100
> +++ gcc/testsuite/c-c++-common/ubsan/opts-1.c   2019-02-14 11:33:23.049077585 
> +0100
> @@ -0,0 +1,22 @@
> +/* { dg-do compile } */
> +/* { dg-options "-fsanitize=undefined -fsanitize=shift 
> -fsanitize=float-divide-by-zero -fdump-tree-optimized" } */
> +/* { dg-final { scan-tree-dump-times "__ubsan_handle_divrem_overflow" 2 
> "optimized" } } */
> +/* { dg-final { scan-tree-dump-times "__ubsan_handle_shift_out_of_bounds" 1 
> "optimized" } } */
> +
> +int
> +foo (int x, int y)
> +{
> +  return x / y;
> +}
> +
> +int
> +bar (int x, int y)
> +{
> +  return x << y;
> +}
> +
> +float
> +baz (float x, float y)
> +{
> +  return x / y;
> +}
> --- gcc/testsuite/c-c++-common/ubsan/opts-2.c.jj        2019-02-14 
> 11:33:29.806965829 +0100
> +++ gcc/testsuite/c-c++-common/ubsan/opts-2.c   2019-02-14 11:34:03.169414166 
> +0100
> @@ -0,0 +1,22 @@
> +/* { dg-do compile } */
> +/* { dg-options "-fsanitize=undefined -fno-sanitize=shift 
> -fsanitize=float-divide-by-zero -fdump-tree-optimized" } */
> +/* { dg-final { scan-tree-dump-times "__ubsan_handle_divrem_overflow" 2 
> "optimized" } } */
> +/* { dg-final { scan-tree-dump-not "__ubsan_handle_shift_out_of_bounds" 
> "optimized" } } */
> +
> +int
> +foo (int x, int y)
> +{
> +  return x / y;
> +}
> +
> +int
> +bar (int x, int y)
> +{
> +  return x << y;
> +}
> +
> +float
> +baz (float x, float y)
> +{
> +  return x / y;
> +}
> --- gcc/testsuite/c-c++-common/ubsan/opts-3.c.jj        2019-02-14 
> 11:34:10.538292322 +0100
> +++ gcc/testsuite/c-c++-common/ubsan/opts-3.c   2019-02-14 11:34:35.512879358 
> +0100
> @@ -0,0 +1,22 @@
> +/* { dg-do compile } */
> +/* { dg-options "-fsanitize=undefined -fno-sanitize=shift 
> -fno-sanitize=float-divide-by-zero -fdump-tree-optimized" } */
> +/* { dg-final { scan-tree-dump-times "__ubsan_handle_divrem_overflow" 1 
> "optimized" } } */
> +/* { dg-final { scan-tree-dump-not "__ubsan_handle_shift_out_of_bounds" 
> "optimized" } } */
> +
> +int
> +foo (int x, int y)
> +{
> +  return x / y;
> +}
> +
> +int
> +bar (int x, int y)
> +{
> +  return x << y;
> +}
> +
> +float
> +baz (float x, float y)
> +{
> +  return x / y;
> +}
> --- gcc/testsuite/c-c++-common/ubsan/opts-4.c.jj        2019-02-14 
> 11:40:35.771922337 +0100
> +++ gcc/testsuite/c-c++-common/ubsan/opts-4.c   2019-02-14 11:40:29.220030674 
> +0100
> @@ -0,0 +1,26 @@
> +/* { dg-do compile } */
> +/* { dg-options "-fsanitize=undefined 
> -fno-sanitize-recover=integer-divide-by-zero -fno-sanitize-recover=shift 
> -fdump-tree-optimized" } */
> +/* { dg-final { scan-tree-dump-times "__ubsan_handle_divrem_overflow_abort" 
> 1 "optimized" } } */
> +/* { dg-final { scan-tree-dump-times 
> "__ubsan_handle_shift_out_of_bounds_abort" 1 "optimized" } } */
> +/* { dg-final { scan-tree-dump-times "__ubsan_handle_type_mismatch_v1" 1 
> "optimized" } } */
> +/* { dg-final { scan-tree-dump-not "__ubsan_handle_type_mismatch_v1_abort" 
> "optimized" } } */
> +
> +int
> +foo (int x, int y)
> +{
> +  return x / y;
> +}
> +
> +int
> +bar (int x, int y)
> +{
> +  return x << y;
> +}
> +
> +enum E { E0, E1, E2, E3 };
> +
> +enum E
> +baz (enum E *x)
> +{
> +  return *x;
> +}
>
>         Jakub



-- 
H.J.

Reply via email to