From patchwork Tue Nov 12 23:09:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Law X-Patchwork-Id: 290796 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5BF092C0082 for ; Wed, 13 Nov 2013 10:11:38 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=AOE3KorZu1vTMje1NqkN7c3qkDWEWNRqmWz6DMzV3Eux+Q D7NvcXTTNhZ5+fwD222JJ8tEF1/dHN4aCcFkfTWCqv84MmVOk5eTJNApcX9T67xy eO2VByWKMSFrNb3ci736q57YBi6bFJxmUGTWqlqXXNiVzqF5bbFsH7uP9gFNc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=Z7HnypyMM3fc5BQ5RfqqKldC7xA=; b=Zv+3sSWEN+OudDCd9FfD iZBWfcVz2h1dF8B2/nsMMiVUFE25h7lPTQ2KAvl7xmQbGd6yll3TKyH9CXcJk7EK lH7ezxEZDzqzB1niTOS8iehaXu2NbO60t+WSLrMsj+9JQgpECoK7UvOhtJzg5AiK V9JqDKy6bmpg+o3/LebTL5s= Received: (qmail 6309 invoked by alias); 12 Nov 2013 23:10:43 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 6278 invoked by uid 89); 12 Nov 2013 23:10:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Nov 2013 23:09:11 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rACN93bU005601 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 12 Nov 2013 18:09:04 -0500 Received: from stumpy.slc.redhat.com (ovpn-113-161.phx2.redhat.com [10.3.113.161]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rACN93R7003146 for ; Tue, 12 Nov 2013 18:09:03 -0500 Message-ID: <5282B50F.90003@redhat.com> Date: Tue, 12 Nov 2013 16:09:03 -0700 From: Jeff Law User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: gcc-patches Subject: [PATCH] Ensure isolated *0 load does not get removed by DCE X-IsSubscribed: yes As Marc noted, DCE will remove the isolated *0 which defeats the purpose of the most recent patch. This marks any isolated null pointer dereferences as volatile which ensures they don't go away. This also fixes a comment and tests that the dereferences survive until the optimized dump. Bootstrapped and regression tested on x86_64-unknown-linux-gnu. Installed on the trunk. Jeff * gimple-ssa-isolate-paths.c (check_loadstore): Mark discovered memory references as volatile. (insert_trap_and_remove_trailing_statements): Fix comment. * gcc.dg/tree-ssa/isolate-1.c: Update expected output. * gcc.dg/tree-ssa/isolate-5.c: Verify the load survives through the SSA optimizers. diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c index 48ab604..2d8f176 100644 --- a/gcc/gimple-ssa-isolate-paths.c +++ b/gcc/gimple-ssa-isolate-paths.c @@ -51,7 +51,12 @@ check_loadstore (gimple stmt ATTRIBUTE_UNUSED, tree op, void *data) { if ((TREE_CODE (op) == MEM_REF || TREE_CODE (op) == TARGET_MEM_REF) && operand_equal_p (TREE_OPERAND (op, 0), (tree)data, 0)) - return true; + { + TREE_THIS_VOLATILE (op) = 1; + TREE_SIDE_EFFECTS (op) = 1; + update_stmt (stmt); + return true; + } return false; } @@ -64,7 +69,7 @@ insert_trap_and_remove_trailing_statements (gimple_stmt_iterator *si_p, tree op) code that wishes to catch the signal can do so. If the dereference is a load, then there's nothing to do as the - LHS will be a throw-away SSA_NAME and the LHS is the NULL dereference. + LHS will be a throw-away SSA_NAME and the RHS is the NULL dereference. If the dereference is a store and we can easily transform the RHS, then simplify the RHS to enable more DCE. */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/isolate-1.c b/gcc/testsuite/gcc.dg/tree-ssa/isolate-1.c index 33745ba..f1f3101 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/isolate-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/isolate-1.c @@ -50,7 +50,7 @@ d_type (struct d_info *di) and finally that we set the RHS of the store to zero. */ /* { dg-final { scan-tree-dump-times "__builtin_trap" 1 "isolate-paths"} } */ /* { dg-final { scan-tree-dump-times "->type = 42" 1 "isolate-paths"} } */ -/* { dg-final { scan-tree-dump-times "->type = 0" 1 "isolate-paths"} } */ +/* { dg-final { scan-tree-dump-times "->type ={v} 0" 1 "isolate-paths"} } */ /* { dg-final { scan-tree-dump-times "->zzz" 1 "isolate-paths"} } */ /* { dg-final { cleanup-tree-dump "isolate-paths" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/isolate-5.c b/gcc/testsuite/gcc.dg/tree-ssa/isolate-5.c index a70871e..ee587d2 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/isolate-5.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/isolate-5.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-isolate-paths" } */ +/* { dg-options "-O2 -fdump-tree-isolate-paths -fdump-tree-optimized" } */ struct demangle_component @@ -51,9 +51,11 @@ d_type (struct d_info *di) We leave the 0->type in the IL, so expect to see ->type twice. */ /* { dg-final { scan-tree-dump-times "__builtin_trap" 1 "isolate-paths"} } */ /* { dg-final { scan-tree-dump-times "->type" 2 "isolate-paths"} } */ +/* { dg-final { scan-tree-dump-times "->type" 1 "optimized"} } */ +/* { dg-final { scan-tree-dump-times "\\.type" 1 "optimized"} } */ /* { dg-final { scan-tree-dump-times "->zzz" 1 "isolate-paths"} } */ /* { dg-final { cleanup-tree-dump "isolate-paths" } } */ - +/* { dg-final { cleanup-tree-dump "optimized-paths" } } */