From 467d8d51f1304b955136060db0a34e1f80f098bb Mon Sep 17 00:00:00 2001 From: Sandra Loosemore Date: Mon, 4 May 2015 15:55:06 -0400 Subject: [PATCH] common.opt (fdelete-null-pointer-checks): Init to -1. 2015-05-04 Sandra Loosemore gcc/ * common.opt (fdelete-null-pointer-checks): Init to -1. * config/nios2/elf.h (SUBTARGET_OVERRIDE_OPTIONS): Define to override flag_delete_null_pointer_checks default. * doc/invoke.texi (-fdelete-null-pointer-checks): Clarify behavior re address zero. Better document target-specific behavior. (-fisolate-errneous-paths-dereference): Mention relationship to -fdelete-null-pointer-checks. gcc/testsuite/ * lib/target-supports.exp (check_effective_target_keeps_null_pointer_checks): Clarify that this is for targets that disable -fdelete-null-pointer-checks, not default it to off. * gcc.dg/ipa/ipa-pta-14.c: Make dependence on -fdelete-null-pointer-checks explicit. * gcc.dg/tree-ssa/20030730-1.c: Likewise. * gcc.dg/tree-ssa/20030730-2.c: Likewise. * gcc.dg/tree-ssa/isolate-1.c: Likewise. * gcc.dg/tree-ssa/isolate-2.c: Likewise. * gcc.dg/tree-ssa/isolate-3.c: Likewise. * gcc.dg/tree-ssa/isolate-4.c: Likewise. * gcc.dg/tree-ssa/isolate-5.c: Likewise. * gcc.dg/tree-ssa/nonzero-1.c: Likewise. * gcc.dg/tree-ssa/pr20318.c: Likewise. * gcc.dg/tree-ssa/pr20701.c: Likewise. * gcc.dg/tree-ssa/pr20702.c: Likewise. * gcc.dg/tree-ssa/pr21086.c: Likewise. * gcc.dg/tree-ssa/pr21090.c: Likewise. * gcc.dg/tree-ssa/pr58480.c: Likewise. * gcc.dg/tree-ssa/pta-escape-1.c: Likewise. * gcc.dg/tree-ssa/pta-escape-2.c: Likewise. * gcc.dg/tree-ssa/pta-escape-3.c: Likewise. * gcc.dg/tree-ssa/ssa-vrp-thread-1.c: Likewise. * gcc.dg/tree-ssa/unreachable.c: Likewise. * gcc.dg/tree-ssa/vrp02.c: Likewise. * gcc.dg/tree-ssa/vrp07.c: Likewise. * gcc.dg/tree-ssa/vrp08.c: Likewise. * gcc.dg/tree-ssa/vrp55.c: Likewise. * g++.dg/cpp0x/static_assert9.C: Likewise. * g++.dg/tree-ssa/nonzero-1.C: Likewise. * g++.dg/tree-ssa/pr19476-1.C: Likewise. * g++.dg/tree-ssa/pr19476-2.C: Likewise. * g++.dg/tree-ssa/pr19476-5.C: Likewise. * g++.dg/tree-ssa/pr26406.C: Likewise. From-SVN: r222777 --- gcc/ChangeLog | 10 +++++ gcc/common.opt | 2 +- gcc/config/nios2/elf.h | 9 +++++ gcc/doc/invoke.texi | 14 ++++--- gcc/testsuite/ChangeLog | 38 +++++++++++++++++++ gcc/testsuite/g++.dg/cpp0x/static_assert9.C | 2 + gcc/testsuite/g++.dg/tree-ssa/nonzero-1.C | 4 +- gcc/testsuite/g++.dg/tree-ssa/pr19476-1.C | 3 +- gcc/testsuite/g++.dg/tree-ssa/pr19476-2.C | 3 +- gcc/testsuite/g++.dg/tree-ssa/pr19476-5.C | 3 +- gcc/testsuite/g++.dg/tree-ssa/pr26406.C | 3 +- gcc/testsuite/gcc.dg/ipa/ipa-pta-14.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/20030730-1.c | 4 +- gcc/testsuite/gcc.dg/tree-ssa/20030730-2.c | 4 +- gcc/testsuite/gcc.dg/tree-ssa/isolate-1.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/isolate-2.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/isolate-3.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/isolate-4.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/isolate-5.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/nonzero-1.c | 4 +- gcc/testsuite/gcc.dg/tree-ssa/pr20318.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/pr20701.c | 4 +- gcc/testsuite/gcc.dg/tree-ssa/pr20702.c | 4 +- gcc/testsuite/gcc.dg/tree-ssa/pr21086.c | 4 +- gcc/testsuite/gcc.dg/tree-ssa/pr21090.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/pr58480.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/pta-escape-1.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/pta-escape-2.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/pta-escape-3.c | 2 +- .../gcc.dg/tree-ssa/ssa-vrp-thread-1.c | 3 +- gcc/testsuite/gcc.dg/tree-ssa/unreachable.c | 2 +- gcc/testsuite/gcc.dg/tree-ssa/vrp02.c | 4 +- gcc/testsuite/gcc.dg/tree-ssa/vrp07.c | 4 +- gcc/testsuite/gcc.dg/tree-ssa/vrp08.c | 4 +- gcc/testsuite/gcc.dg/tree-ssa/vrp55.c | 2 +- gcc/testsuite/lib/target-supports.exp | 8 ++-- 36 files changed, 120 insertions(+), 46 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4837a9178af..116a6d64359 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2015-05-04 Sandra Loosemore + + * common.opt (fdelete-null-pointer-checks): Init to -1. + * config/nios2/elf.h (SUBTARGET_OVERRIDE_OPTIONS): Define to + override flag_delete_null_pointer_checks default. + * doc/invoke.texi (-fdelete-null-pointer-checks): Clarify + behavior re address zero. Better document target-specific behavior. + (-fisolate-errneous-paths-dereference): Mention relationship to + -fdelete-null-pointer-checks. + 2015-05-04 Jakub Jelinek PR tree-optimization/65984 diff --git a/gcc/common.opt b/gcc/common.opt index 380848c7087..51833c17e49 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1070,7 +1070,7 @@ Common Report Var(flag_delete_dead_exceptions) Init(0) Optimization Delete dead instructions that may throw exceptions fdelete-null-pointer-checks -Common Report Var(flag_delete_null_pointer_checks) Init(1) Optimization +Common Report Var(flag_delete_null_pointer_checks) Init(-1) Optimization Delete useless null pointer checks fdevirtualize-at-ltrans diff --git a/gcc/config/nios2/elf.h b/gcc/config/nios2/elf.h index 243596a0281..84b44d42258 100644 --- a/gcc/config/nios2/elf.h +++ b/gcc/config/nios2/elf.h @@ -50,3 +50,12 @@ /* The ELF target doesn't support the Nios II Linux ABI. */ #define TARGET_LINUX_ABI 0 +/* Default -fdelete-null-pointer-checks to off, to prevent the compiler + from treating accesses to address zero as traps. On bare-metal Nios II + targets address zero may legitimately be mapped to memory (e.g., the + hardware description may specify this as the address of the interrupt + vector). Users can override this on the command line to get the + additional optimizations it enables. */ +#define SUBTARGET_OVERRIDE_OPTIONS \ + if (flag_delete_null_pointer_checks < 0) \ + flag_delete_null_pointer_checks = 0 diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 7d2f6e58a41..972d3550ca3 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -8014,10 +8014,12 @@ Enabled by @option{-Os}. @item -fdelete-null-pointer-checks @opindex fdelete-null-pointer-checks Assume that programs cannot safely dereference null pointers, and that -no code or data element resides there. This enables simple constant +no code or data element resides at address zero. +This option enables simple constant folding optimizations at all optimization levels. In addition, other optimization passes in GCC use this flag to control global dataflow analyses that eliminate useless checks for null pointers; these assume +that a memory access to address zero always results in a trap, so that if a pointer is checked after it has already been dereferenced, it cannot be null. @@ -8025,9 +8027,10 @@ Note however that in some environments this assumption is not true. Use @option{-fno-delete-null-pointer-checks} to disable this optimization for programs that depend on that behavior. -Some targets, especially embedded ones, disable this option at all levels. -Otherwise it is enabled at all levels: @option{-O0}, @option{-O1}, -@option{-O2}, @option{-O3}, @option{-Os}. Passes that use the information +This option is enabled by default on most targets. On Nios II ELF, it +defaults to off. On AVR and CR16, this option is completely disabled. + +Passes that use the dataflow information are enabled independently at different optimization levels. @item -fdevirtualize @@ -8510,7 +8513,8 @@ This flag is enabled by default at @option{-O2} and @option{-Os}. Detect paths that trigger erroneous or undefined behavior due to dereferencing a null pointer. Isolate those paths from the main control flow and turn the statement with erroneous or undefined behavior into a trap. -This flag is enabled by default at @option{-O2} and higher. +This flag is enabled by default at @option{-O2} and higher and depends on +@option{-fdelete-null-pointer-checks} also being enabled. @item -fisolate-erroneous-paths-attribute @opindex fisolate-erroneous-paths-attribute diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9525115e9d8..3673938aab0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,41 @@ +2015-05-04 Sandra Loosemore + + * lib/target-supports.exp + (check_effective_target_keeps_null_pointer_checks): Clarify that + this is for targets that disable -fdelete-null-pointer-checks, + not default it to off. + * gcc.dg/ipa/ipa-pta-14.c: Make dependence on + -fdelete-null-pointer-checks explicit. + * gcc.dg/tree-ssa/20030730-1.c: Likewise. + * gcc.dg/tree-ssa/20030730-2.c: Likewise. + * gcc.dg/tree-ssa/isolate-1.c: Likewise. + * gcc.dg/tree-ssa/isolate-2.c: Likewise. + * gcc.dg/tree-ssa/isolate-3.c: Likewise. + * gcc.dg/tree-ssa/isolate-4.c: Likewise. + * gcc.dg/tree-ssa/isolate-5.c: Likewise. + * gcc.dg/tree-ssa/nonzero-1.c: Likewise. + * gcc.dg/tree-ssa/pr20318.c: Likewise. + * gcc.dg/tree-ssa/pr20701.c: Likewise. + * gcc.dg/tree-ssa/pr20702.c: Likewise. + * gcc.dg/tree-ssa/pr21086.c: Likewise. + * gcc.dg/tree-ssa/pr21090.c: Likewise. + * gcc.dg/tree-ssa/pr58480.c: Likewise. + * gcc.dg/tree-ssa/pta-escape-1.c: Likewise. + * gcc.dg/tree-ssa/pta-escape-2.c: Likewise. + * gcc.dg/tree-ssa/pta-escape-3.c: Likewise. + * gcc.dg/tree-ssa/ssa-vrp-thread-1.c: Likewise. + * gcc.dg/tree-ssa/unreachable.c: Likewise. + * gcc.dg/tree-ssa/vrp02.c: Likewise. + * gcc.dg/tree-ssa/vrp07.c: Likewise. + * gcc.dg/tree-ssa/vrp08.c: Likewise. + * gcc.dg/tree-ssa/vrp55.c: Likewise. + * g++.dg/cpp0x/static_assert9.C: Likewise. + * g++.dg/tree-ssa/nonzero-1.C: Likewise. + * g++.dg/tree-ssa/pr19476-1.C: Likewise. + * g++.dg/tree-ssa/pr19476-2.C: Likewise. + * g++.dg/tree-ssa/pr19476-5.C: Likewise. + * g++.dg/tree-ssa/pr26406.C: Likewise. + 2015-05-04 Jakub Jelinek PR tree-optimization/65984 diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert9.C b/gcc/testsuite/g++.dg/cpp0x/static_assert9.C index fccaa449c17..46d7f25231a 100644 --- a/gcc/testsuite/g++.dg/cpp0x/static_assert9.C +++ b/gcc/testsuite/g++.dg/cpp0x/static_assert9.C @@ -1,5 +1,7 @@ // PR c++/58837 // { dg-require-effective-target c++11 } +// { dg-skip-if "" keeps_null_pointer_checks } +// { dg-options "-fdelete-null-pointer-checks" } void f(); static_assert(f, ""); diff --git a/gcc/testsuite/g++.dg/tree-ssa/nonzero-1.C b/gcc/testsuite/g++.dg/tree-ssa/nonzero-1.C index 60da49dca37..7b422db702b 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/nonzero-1.C +++ b/gcc/testsuite/g++.dg/tree-ssa/nonzero-1.C @@ -1,5 +1,7 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-ccp1" } */ +/* { dg-options "-O2 -fdump-tree-ccp1 -fdelete-null-pointer-checks" } */ +/* { dg-skip-if "" keeps_null_pointer_checks } */ + inline void t() { } diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr19476-1.C b/gcc/testsuite/g++.dg/tree-ssa/pr19476-1.C index cbdad90d16b..837975155f7 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/pr19476-1.C +++ b/gcc/testsuite/g++.dg/tree-ssa/pr19476-1.C @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O -fdump-tree-ccp1" } */ +/* { dg-options "-O -fdump-tree-ccp1 -fdelete-null-pointer-checks" } */ +/* { dg-skip-if "" keeps_null_pointer_checks } */ // See pr19476-5.C for a version without including . #include diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr19476-2.C b/gcc/testsuite/g++.dg/tree-ssa/pr19476-2.C index 70002dbb5ea..e72a8fbfb5a 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/pr19476-2.C +++ b/gcc/testsuite/g++.dg/tree-ssa/pr19476-2.C @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fdump-tree-optimized -fdelete-null-pointer-checks" } */ +/* { dg-skip-if "" keeps_null_pointer_checks } */ #include diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr19476-5.C b/gcc/testsuite/g++.dg/tree-ssa/pr19476-5.C index bec0bb58b6c..921d7302fd8 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/pr19476-5.C +++ b/gcc/testsuite/g++.dg/tree-ssa/pr19476-5.C @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O -fdump-tree-ccp1" } */ +/* { dg-options "-O -fdump-tree-ccp1 -fdelete-null-pointer-checks" } */ +/* { dg-skip-if "" keeps_null_pointer_checks } */ // See pr19476-1.C for a version that includes . diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr26406.C b/gcc/testsuite/g++.dg/tree-ssa/pr26406.C index c2d160508a6..d70e8049f84 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/pr26406.C +++ b/gcc/testsuite/g++.dg/tree-ssa/pr26406.C @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fdump-tree-optimized -fdelete-null-pointer-checks" } */ +/* { dg-skip-if "" keeps_null_pointer_checks } */ int *f(int *b) { diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-pta-14.c b/gcc/testsuite/gcc.dg/ipa/ipa-pta-14.c index b62b08ff03a..091a375ebd0 100644 --- a/gcc/testsuite/gcc.dg/ipa/ipa-pta-14.c +++ b/gcc/testsuite/gcc.dg/ipa/ipa-pta-14.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-O2 -fipa-pta -fno-tree-fre -fno-tree-sra -fdump-ipa-pta-details" } */ +/* { dg-options "-O2 -fipa-pta -fno-tree-fre -fno-tree-sra -fdump-ipa-pta-details -fdelete-null-pointer-checks" } */ struct X { int i; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20030730-1.c b/gcc/testsuite/gcc.dg/tree-ssa/20030730-1.c index bb474ff4b1b..9f8f2746734 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/20030730-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/20030730-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-dom2" } */ +/* { dg-options "-O2 -fdump-tree-dom2 -fdelete-null-pointer-checks" } */ extern void exit (int); extern void *ggc_alloc (__SIZE_TYPE__); @@ -18,7 +18,7 @@ foo (int attr_kind, unsigned long offset) exit (0); } -/* There should be no IF conditionals, unless target has fno-delete-null-pointer-checks */ +/* There should be no IF conditionals, unless target disables -fdelete-null-pointer-checks */ /* { dg-final { scan-tree-dump-times "if " 0 "dom2" { target { ! keeps_null_pointer_checks } } } } */ /* { dg-final { scan-tree-dump "if " "dom2" { target { keeps_null_pointer_checks } } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20030730-2.c b/gcc/testsuite/gcc.dg/tree-ssa/20030730-2.c index 1768d4523d2..0be596e8e64 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/20030730-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/20030730-2.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-dom2" } */ +/* { dg-options "-O2 -fdump-tree-dom2 -fdelete-null-pointer-checks" } */ extern void exit (int); extern void *ggc_alloc (__SIZE_TYPE__); @@ -18,7 +18,7 @@ foo (int attr_kind, unsigned long offset) exit (0); } -/* There should be no IF conditionals, unless target has fno-delete-null-pointer-checks */ +/* There should be no IF conditionals, unless target disables -fdelete-null-pointer-checks */ /* { dg-final { scan-tree-dump-times "if " 0 "dom2" { target { ! keeps_null_pointer_checks } } } } */ /* { dg-final { scan-tree-dump "if " "dom2" { target { keeps_null_pointer_checks } } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/isolate-1.c b/gcc/testsuite/gcc.dg/tree-ssa/isolate-1.c index 3ed98aeb857..be67e4ed127 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/isolate-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/isolate-1.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-isolate-paths" } */ +/* { dg-options "-O2 -fdump-tree-isolate-paths -fdelete-null-pointer-checks" } */ /* { dg-skip-if "" keeps_null_pointer_checks } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/isolate-2.c b/gcc/testsuite/gcc.dg/tree-ssa/isolate-2.c index 912d98e2246..a7e7514c5fc 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/isolate-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/isolate-2.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fisolate-erroneous-paths-attribute -fdump-tree-isolate-paths -fdump-tree-phicprop1" } */ +/* { dg-options "-O2 -fdelete-null-pointer-checks -fisolate-erroneous-paths-attribute -fdump-tree-isolate-paths -fdump-tree-phicprop1" } */ /* { dg-skip-if "" keeps_null_pointer_checks } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/isolate-3.c b/gcc/testsuite/gcc.dg/tree-ssa/isolate-3.c index 8dd2f2bdc2f..0fe7e62111d 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/isolate-3.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/isolate-3.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-isolate-paths" } */ +/* { dg-options "-O2 -fdump-tree-isolate-paths -fdelete-null-pointer-checks" } */ /* { dg-skip-if "" keeps_null_pointer_checks } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/isolate-4.c b/gcc/testsuite/gcc.dg/tree-ssa/isolate-4.c index d50a2b27f47..0da4134fd06 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/isolate-4.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/isolate-4.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fisolate-erroneous-paths-attribute -fdump-tree-isolate-paths -fdump-tree-phicprop1" } */ +/* { dg-options "-O2 -fdelete-null-pointer-checks -fisolate-erroneous-paths-attribute -fdump-tree-isolate-paths -fdump-tree-phicprop1" } */ /* { dg-skip-if "" keeps_null_pointer_checks } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/isolate-5.c b/gcc/testsuite/gcc.dg/tree-ssa/isolate-5.c index 131d319ae0d..2978413cc37 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/isolate-5.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/isolate-5.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-isolate-paths -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fdelete-null-pointer-checks -fdump-tree-isolate-paths -fdump-tree-optimized" } */ /* { dg-skip-if "" keeps_null_pointer_checks } */ struct demangle_component diff --git a/gcc/testsuite/gcc.dg/tree-ssa/nonzero-1.c b/gcc/testsuite/gcc.dg/tree-ssa/nonzero-1.c index e94ad5f14ca..18ccc604838 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/nonzero-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/nonzero-1.c @@ -1,5 +1,7 @@ /* { dg-do compile } */ -/* { dg-options "-O2" } */ +/* { dg-options "-O2 -fdelete-null-pointer-checks" } */ + +/* { dg-skip-if "" keeps_null_pointer_checks } */ extern int a; /* { dg-error "declared weak after being used" } */ int t() diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr20318.c b/gcc/testsuite/gcc.dg/tree-ssa/pr20318.c index 1b302aedefa..f36184b9208 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr20318.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr20318.c @@ -1,5 +1,5 @@ /* { dg-do compile { target { ! keeps_null_pointer_checks } } } */ -/* { dg-options "-O2 -fdump-tree-original -fdump-tree-vrp1" } */ +/* { dg-options "-O2 -fdump-tree-original -fdump-tree-vrp1 -fdelete-null-pointer-checks" } */ extern int* f(int) __attribute__((returns_nonnull)); extern void eliminate (); diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr20701.c b/gcc/testsuite/gcc.dg/tree-ssa/pr20701.c index 3ddf48e6f00..c49ff7a7ba3 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr20701.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr20701.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-vrp1 -fno-early-inlining" } */ +/* { dg-options "-O2 -fdump-tree-vrp1 -fno-early-inlining -fdelete-null-pointer-checks" } */ typedef struct { int code; @@ -35,7 +35,7 @@ can_combine_p (rtx insn, rtx elt) return 0; } -/* Target with fno-delete-null-pointer-checks should not fold checks */ +/* Target disabling -fdelete-null-pointer-checks should not fold checks */ /* { dg-final { scan-tree-dump-times "Folding predicate.*to 0" 1 "vrp1" { target { ! keeps_null_pointer_checks } } } } */ /* { dg-final { scan-tree-dump-times "Folding predicate.*to 0" 0 "vrp1" { target { keeps_null_pointer_checks } } } } */ /* { dg-final { cleanup-tree-dump "vrp1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr20702.c b/gcc/testsuite/gcc.dg/tree-ssa/pr20702.c index ce62fa3f0f9..8313f1aea78 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr20702.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr20702.c @@ -4,7 +4,7 @@ immediate successors of the basic block. */ /* { dg-do compile } */ -/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-vrp1-details" } */ +/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-vrp1-details -fdelete-null-pointer-checks" } */ extern void bar (int); @@ -25,7 +25,7 @@ foo (int *p, int b) return a; } -/* Target with fno-delete-null-pointer-checks should not fold checks */ +/* Target disabling -fdelete-null-pointer-checks should not fold checks */ /* { dg-final { scan-tree-dump-times "Folding predicate" 1 "vrp1" { target { ! keeps_null_pointer_checks } } } } */ /* { dg-final { scan-tree-dump-times "Folding predicate" 0 "vrp1" { target { keeps_null_pointer_checks } } } } */ /* { dg-final { cleanup-tree-dump "vrp1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr21086.c b/gcc/testsuite/gcc.dg/tree-ssa/pr21086.c index f924d26cca2..6f96f40cbf4 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr21086.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr21086.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-vrp1 -fdump-tree-dce1" } */ +/* { dg-options "-O2 -fdump-tree-vrp1 -fdump-tree-dce1 -fdelete-null-pointer-checks" } */ int foo (int *p) @@ -15,7 +15,7 @@ foo (int *p) return 0; } -/* Target with fno-delete-null-pointer-checks should not fold checks */ +/* Target disabling -fdelete-null-pointer-checks should not fold checks */ /* { dg-final { scan-tree-dump "Folding predicate " "vrp1" { target { ! keeps_null_pointer_checks } } } } */ /* { dg-final { scan-tree-dump-times "Folding predicate " 0 "vrp1" { target { keeps_null_pointer_checks } } } } */ /* { dg-final { scan-tree-dump-not "b_. =" "dce1" { target { ! avr-*-* } } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr21090.c b/gcc/testsuite/gcc.dg/tree-ssa/pr21090.c index 40d960d49b7..30abc2034a5 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr21090.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr21090.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-vrp1" } */ +/* { dg-options "-O2 -fdump-tree-vrp1 -fdelete-null-pointer-checks" } */ int g, h; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr58480.c b/gcc/testsuite/gcc.dg/tree-ssa/pr58480.c index a42edf973cb..90e4cc0aeb3 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr58480.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr58480.c @@ -1,5 +1,5 @@ /* { dg-do compile { target { ! keeps_null_pointer_checks } } } */ -/* { dg-options "-O2 -fdump-tree-vrp1" } */ +/* { dg-options "-O2 -fdump-tree-vrp1 -fdelete-null-pointer-checks" } */ extern void eliminate (void); extern void* f1 (void *a, void *b) __attribute__((nonnull)); diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pta-escape-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pta-escape-1.c index dcfae5dd957..f02d32a479b 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pta-escape-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pta-escape-1.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-O -fdump-tree-alias-details" } */ +/* { dg-options "-O -fdump-tree-alias-details -fdelete-null-pointer-checks" } */ int *i; void __attribute__((noinline)) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pta-escape-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pta-escape-2.c index e6139591ec8..b97e515ba3d 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pta-escape-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pta-escape-2.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-O -fdump-tree-alias-details" } */ +/* { dg-options "-O -fdump-tree-alias-details -fdelete-null-pointer-checks" } */ int *i; void __attribute__((noinline)) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pta-escape-3.c b/gcc/testsuite/gcc.dg/tree-ssa/pta-escape-3.c index 870dcf6b19a..280b4b221e2 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pta-escape-3.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pta-escape-3.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-O -fdump-tree-alias-details" } */ +/* { dg-options "-O -fdump-tree-alias-details -fdelete-null-pointer-checks" } */ int *i; void __attribute__((noinline)) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-vrp-thread-1.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-vrp-thread-1.c index a4fdf89958f..4f4d9679481 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-vrp-thread-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-vrp-thread-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-vrp1-details" } */ +/* { dg-options "-O2 -fdump-tree-vrp1-details -fdelete-null-pointer-checks" } */ +/* { dg-skip-if "" keeps_null_pointer_checks } */ void oof (void); struct basic_block_def; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/unreachable.c b/gcc/testsuite/gcc.dg/tree-ssa/unreachable.c index c4caeaf6c0b..11ff47bcb07 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/unreachable.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/unreachable.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O1 -fdump-tree-optimized" } */ +/* { dg-options "-O1 -fdump-tree-optimized -fdelete-null-pointer-checks" } */ static void bad_boy() { } diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp02.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp02.c index 4373d524c25..994c1dbb9cd 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp02.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp02.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-vrp1" } */ +/* { dg-options "-O2 -fdump-tree-vrp1 -fdelete-null-pointer-checks" } */ struct A { @@ -20,7 +20,7 @@ foo (struct A *p, struct A *q) if (p) return x + p->b; } -/* Target with fno-delete-null-pointer-checks should not fold check */ +/* Target disabling -fdelete-null-pointer-checks should not fold check */ /* { dg-final { scan-tree-dump-times "Folding predicate p_.*to 1" 1 "vrp1" { target { ! keeps_null_pointer_checks } } } } */ /* { dg-final { scan-tree-dump-times "Folding predicate p_.*to 1" 0 "vrp1" { target { keeps_null_pointer_checks } } } } */ /* { dg-final { cleanup-tree-dump "vrp1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp07.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp07.c index ba813f271f7..a59a3e83bbc 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp07.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp07.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-vrp1-details" } */ +/* { dg-options "-O2 -fdump-tree-vrp1-details -fdelete-null-pointer-checks" } */ int foo (int i, int *p) @@ -30,7 +30,7 @@ foo (int i, int *p) return i; } -/* Target with fno-delete-null-pointer-checks should not fold checks */ +/* Target disabling -fdelete-null-pointer-checks should not fold checks */ /* { dg-final { scan-tree-dump-times "Folding predicate p_.*to 1" 1 "vrp1" } } */ /* { dg-final { scan-tree-dump-times "Folding predicate p_.*to 0" 1 "vrp1" { target { ! keeps_null_pointer_checks } } } } */ /* { dg-final { scan-tree-dump-times "Folding predicate p_.*to 0" 0 "vrp1" { target { keeps_null_pointer_checks } } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp08.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp08.c index b7111dbad96..9aff505357d 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp08.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp08.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fno-tree-fre -fdump-tree-vrp1-details" } */ +/* { dg-options "-O2 -fno-tree-fre -fdump-tree-vrp1-details -fdelete-null-pointer-checks" } */ /* Compile with -fno-tree-fre -O2 to prevent CSEing *p. */ int @@ -18,7 +18,7 @@ foo (int a, int *p) return a; } -/* Target with fno-delete-null-pointer-checks should not fold checks */ +/* Target disabling -fdelete-null-pointer-checks should not fold checks */ /* { dg-final { scan-tree-dump-times "Folding predicate p_.*to 1" 1 "vrp1" { target { ! keeps_null_pointer_checks } } } } */ /* { dg-final { scan-tree-dump-times "PREDICATE: p_.* ne_expr 0" 1 "vrp1" { target { ! keeps_null_pointer_checks } } } } */ /* { dg-final { scan-tree-dump-times "Folding predicate p_.*to 1" 0 "vrp1" { target { keeps_null_pointer_checks } } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp55.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp55.c index 7d1825f24fd..d4014abf22b 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp55.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp55.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-vrp1-blocks-vops-details" } */ +/* { dg-options "-O2 -fdump-tree-vrp1-blocks-vops-details -fdelete-null-pointer-checks" } */ void arf (void); diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index c5d0ffe06e2..d68b48bad21 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -458,9 +458,11 @@ proc check_effective_target_trampolines { } { } # Return 1 if according to target_info struct and explicit target list -# target is supposed to keep null pointer checks. This could be due to -# use of option fno-delete-null-pointer-checks or hardwired in target. - +# target disables -fdelete-null-pointer-checks. Targets should return 0 +# if they simply default to -fno-delete-null-pointer-checks but obey +# -fdelete-null-pointer-checks when passed explicitly (and tests that +# depend on this option should do that). + proc check_effective_target_keeps_null_pointer_checks { } { if [target_info exists keeps_null_pointer_checks] { return 1 -- 2.30.2