aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-08-25 13:49:40 +0200
committerJakub Jelinek <jakub@redhat.com>2020-08-25 13:49:40 +0200
commita5b15fcb954ba63d58f0daa700281aba33b5f24a (patch)
tree981c1d7a4dbd26ef6e327e9e4e6daec6ab0c18f4 /gcc
parentf982a6ec9b6d98f5f37114b1d7455c54ce5056b8 (diff)
downloadgcc-a5b15fcb954ba63d58f0daa700281aba33b5f24a.zip
gcc-a5b15fcb954ba63d58f0daa700281aba33b5f24a.tar.gz
gcc-a5b15fcb954ba63d58f0daa700281aba33b5f24a.tar.bz2
gimple: Ignore *0 = {CLOBBER} in path isolation [PR96722]
Clobbers of MEM_REF with NULL address are just fancy nops, something we just ignore and don't emit any code for it (ditto for other clobbers), they just mark end of life on something, so we shouldn't infer from those that there is some UB. 2020-08-25 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/96722 * gimple.c (infer_nonnull_range): Formatting fix. (infer_nonnull_range_by_dereference): Return false for clobber stmts. * g++.dg/opt/pr96722.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gimple.c7
-rw-r--r--gcc/testsuite/g++.dg/opt/pr96722.C20
2 files changed, 24 insertions, 3 deletions
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 41f7cf3..bf863f6 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -2917,8 +2917,8 @@ check_loadstore (gimple *, tree op, tree, void *data)
bool
infer_nonnull_range (gimple *stmt, tree op)
{
- return infer_nonnull_range_by_dereference (stmt, op)
- || infer_nonnull_range_by_attribute (stmt, op);
+ return (infer_nonnull_range_by_dereference (stmt, op)
+ || infer_nonnull_range_by_attribute (stmt, op));
}
/* Return true if OP can be inferred to be non-NULL after STMT
@@ -2930,7 +2930,8 @@ infer_nonnull_range_by_dereference (gimple *stmt, tree op)
non-NULL if -fdelete-null-pointer-checks is enabled. */
if (!flag_delete_null_pointer_checks
|| !POINTER_TYPE_P (TREE_TYPE (op))
- || gimple_code (stmt) == GIMPLE_ASM)
+ || gimple_code (stmt) == GIMPLE_ASM
+ || gimple_clobber_p (stmt))
return false;
if (walk_stmt_load_store_ops (stmt, (void *)op,
diff --git a/gcc/testsuite/g++.dg/opt/pr96722.C b/gcc/testsuite/g++.dg/opt/pr96722.C
new file mode 100644
index 0000000..408dfee
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr96722.C
@@ -0,0 +1,20 @@
+// PR tree-optimization/96722
+// { dg-do run }
+// { dg-options "-O2" }
+
+struct S { int s; ~S () {} };
+
+void
+foo (S *a)
+{
+ if (a)
+ return;
+ a->~S ();
+}
+
+int
+main ()
+{
+ S s;
+ foo (&s);
+}