public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/redhat/heads/gcc-8-branch)] gimple: Ignore *0 = {CLOBBER} in path isolation [PR96722]
@ 2020-09-17 17:24 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-09-17 17:24 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0068612243adf41fe75e4033021607e2bfeba1db

commit 0068612243adf41fe75e4033021607e2bfeba1db
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Aug 25 13:49:40 2020 +0200

    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.
    
    (cherry picked from commit a5b15fcb954ba63d58f0daa700281aba33b5f24a)

Diff:
---
 gcc/gimple.c                       |  7 ++++---
 gcc/testsuite/g++.dg/opt/pr96722.C | 20 ++++++++++++++++++++
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/gcc/gimple.c b/gcc/gimple.c
index 9dc4911a36e..18fc2f86a69 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -2782,8 +2782,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
@@ -2795,7 +2795,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 00000000000..408dfeea8a0
--- /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);
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-17 17:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 17:24 [gcc(refs/vendors/redhat/heads/gcc-8-branch)] gimple: Ignore *0 = {CLOBBER} in path isolation [PR96722] Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).