From patchwork Sat Oct 16 12:47:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 46300 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9323E3857C6C for ; Sat, 16 Oct 2021 12:48:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9323E3857C6C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1634388502; bh=U1YXDul9b3d5e4grIzdMTMd+wpjur4HzZKlkKgSC7ik=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=lgX8fCgzxuakaOhX3cPkwuGisEuuUcElo1QhmgN8Toe6XqY30t2eUgyVDCsShd1kD RmGtR4z4UCagWgfLWEwBaAOW8BHIG8ffRaDeUNXW+qFXWmmQ/qoNci4OX2LH1n5bWR 8AN+4ab/F/Si1TfyQCeqD46ey4ysFpLen3CmBMcI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 605353858418 for ; Sat, 16 Oct 2021 12:47:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 605353858418 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id A192C280FE8; Sat, 16 Oct 2021 14:47:51 +0200 (CEST) Date: Sat, 16 Oct 2021 14:47:51 +0200 To: gcc-patches@gcc.gnu.org Subject: Fix wrong code in ldist-strlen-1.c Message-ID: <20211016124751.GB52572@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-Patchwork-Original-From: Jan Hubicka via Gcc-patches From: Jan Hubicka Reply-To: Jan Hubicka Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, while updating compute_points_to_sets I missed that the code not only sets the nonlocal/escaped flags but also initializes pt. With my previous change if uses_global_memory is false pt is not updated correctly which may lead to wrong code. This is fixed by the following patch I comitted to avoid strange misoptimizations. Bootstrapped/regtested x86_64-linux and also tested with LTO. Honza gcc/ChangeLog: PR tree-optimization/102720 * tree-ssa-structalias.c (compute_points_to_sets): Fix producing of call used and clobbered sets. diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 6f12a66ee0d..2e6513bb72a 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -7541,17 +7541,18 @@ compute_points_to_sets (void) determine_global_memory_access (stmt, NULL, &reads_global_memory, &uses_global_memory); - if (!uses_global_memory) - ; - else if ((vi = lookup_call_use_vi (stmt)) != NULL) + if ((vi = lookup_call_use_vi (stmt)) != NULL) { *pt = find_what_var_points_to (cfun->decl, vi); /* Escaped (and thus nonlocal) variables are always implicitly used by calls. */ /* ??? ESCAPED can be empty even though NONLOCAL always escaped. */ - pt->nonlocal = uses_global_memory; - pt->escaped = uses_global_memory; + if (uses_global_memory) + { + pt->nonlocal = uses_global_memory; + pt->escaped = uses_global_memory; + } } else if (uses_global_memory) { @@ -7572,17 +7573,18 @@ compute_points_to_sets (void) determine_global_memory_access (stmt, &writes_global_memory, NULL, NULL); - if (!writes_global_memory) - ; - else if ((vi = lookup_call_clobber_vi (stmt)) != NULL) + if ((vi = lookup_call_clobber_vi (stmt)) != NULL) { *pt = find_what_var_points_to (cfun->decl, vi); /* Escaped (and thus nonlocal) variables are always implicitly clobbered by calls. */ /* ??? ESCAPED can be empty even though NONLOCAL always escaped. */ - pt->nonlocal = writes_global_memory; - pt->escaped = writes_global_memory; + if (writes_global_memory) + { + pt->nonlocal = writes_global_memory; + pt->escaped = writes_global_memory; + } } else if (writes_global_memory) {