From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125842 invoked by alias); 12 Mar 2018 12:31:25 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 125805 invoked by uid 89); 12 Mar 2018 12:31:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,KAM_NUMSUBJECT,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Mar 2018 12:31:17 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E78D4AEEE for ; Mon, 12 Mar 2018 12:31:14 +0000 (UTC) Date: Mon, 12 Mar 2018 12:31:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR84803 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SW-Source: 2018-03/txt/msg00521.txt.bz2 The following fixes PR84803 where we have a memory reference data-reference analysis thought it's not worth handling. This properly guards the access. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2018-03-12 Richard Biener PR tree-optimization/84803 * tree-if-conv.c (ifcvt_memrefs_wont_trap): Don't do anything for refs DR analysis didn't process. * gcc.dg/torture/pr84803.c: New testcase. Index: gcc/tree-if-conv.c =================================================================== --- gcc/tree-if-conv.c (revision 258445) +++ gcc/tree-if-conv.c (working copy) @@ -864,6 +864,11 @@ base_object_writable (tree ref) static bool ifcvt_memrefs_wont_trap (gimple *stmt, vec drs) { + /* If DR didn't see a reference here we can't use it to tell + whether the ref traps or not. */ + if (gimple_uid (stmt) == 0) + return false; + data_reference_p *master_dr, *base_master_dr; data_reference_p a = drs[gimple_uid (stmt) - 1]; Index: gcc/testsuite/gcc.dg/torture/pr84803.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr84803.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/pr84803.c (working copy) @@ -0,0 +1,30 @@ +/* { dg-do compile } */ + +long a; +long *b; +void c (); +void d (); +void +e (long f) +{ + if (a) + *b = f; +} +void +g () +{ + c (g, e); +} +void +c (int f, int h ()) +{ + d (f, h, ""); +} +void +d (int f, int h (), char *i, char *k) +{ + int j; + d (f, h, i + 1, k); + while (--j) + h (*i); +}