From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 0963B3857C41 for ; Mon, 24 Aug 2020 21:37:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0963B3857C41 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-304-6f8NqFJnM7a7tm7bvq4_zw-1; Mon, 24 Aug 2020 17:37:08 -0400 X-MC-Unique: 6f8NqFJnM7a7tm7bvq4_zw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0A38510ABDA5; Mon, 24 Aug 2020 21:37:08 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-113-174.ams2.redhat.com [10.36.113.174]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A99B95D9E4; Mon, 24 Aug 2020 21:37:07 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id 07OLb437006717; Mon, 24 Aug 2020 23:37:05 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 07OLb4R4006716; Mon, 24 Aug 2020 23:37:04 +0200 Date: Mon, 24 Aug 2020 23:37:03 +0200 From: Jakub Jelinek To: Richard Biener , Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] gimple: Ignore *0 = {CLOBBER} in path isolation [PR96722] Message-ID: <20200824213703.GS2363@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2020 21:37:12 -0000 Hi! 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. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2020-08-24 Jakub Jelinek 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. --- gcc/gimple.c.jj 2020-08-03 22:54:51.417531677 +0200 +++ gcc/gimple.c 2020-08-24 13:23:22.082312349 +0200 @@ -2917,8 +2917,8 @@ check_loadstore (gimple *, tree op, tree 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 (gimp 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, --- gcc/testsuite/g++.dg/opt/pr96722.C.jj 2020-08-24 13:24:45.357132323 +0200 +++ gcc/testsuite/g++.dg/opt/pr96722.C 2020-08-24 13:25:06.224836626 +0200 @@ -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); +} Jakub