From patchwork Mon Jul 14 11:09:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 369580 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3338F140096 for ; Mon, 14 Jul 2014 21:12:14 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:in-reply-to:message-id:references :mime-version:content-type; q=dns; s=default; b=iH9Pg+qYTwialR2o Fm+Nm8efywNwjb/riAwWBxWec+mQal/4C7nFk521bXFCMQ2E9O1ALTP2ocmfaABq y/c+5PdOIsO0aFC9yIYOckxlYAUkGRef2XN2t14OKDsQlEFXJ3qnyHm54hM7Rqb9 8HirNDxvxvFyVa5RT8szy2HUfic= 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:date :from:to:cc:subject:in-reply-to:message-id:references :mime-version:content-type; s=default; bh=aLQB3OdpxrL+buEd7+ZRls pshrI=; b=aQV5FlqBkgJeCZ8t0ZG5StUFdFvIYiVmf0+Mf4M3qfafSd/bYNNxMr bczICj3moPAMgqlh1xKz7tN8kj7Ygq6PjT/Ajkt9F7PkBW8PLyDpY4GPGNXPSzM5 3iw40N2KqZUUqf1tHJ2fvqbTj0AXrEcE4W7U/DJW2NviZB3juv290= Received: (qmail 5840 invoked by alias); 14 Jul 2014 11:12:07 -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 5824 invoked by uid 89); 14 Jul 2014 11:12:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Mon, 14 Jul 2014 11:12:04 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9EAABAB5D; Mon, 14 Jul 2014 11:12:01 +0000 (UTC) Date: Mon, 14 Jul 2014 13:09:15 +0200 (CEST) From: Richard Biener To: Jakub Jelinek cc: Jeff Law , gcc-patches@gcc.gnu.org Subject: Re: [PATCH][RFC] Fix PR61473, inline small memcpy/memmove during tree opts In-Reply-To: Message-ID: References: <539A0E6B.3080905@redhat.com> <20140627115658.GB31640@tucnak.redhat.com> <20140710151259.GL31640@tucnak.redhat.com> <20140711134201.GW31640@tucnak.redhat.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 On Mon, 14 Jul 2014, Richard Biener wrote: > On Fri, 11 Jul 2014, Jakub Jelinek wrote: > > > On Fri, Jul 11, 2014 at 03:36:15PM +0200, Richard Biener wrote: > > > *************** c_strlen (tree src, int only_value) > > > *** 606,612 **** > > > > > > /* If the offset is known to be out of bounds, warn, and call strlen at > > > runtime. */ > > > ! if (offset < 0 || offset > max) > > > { > > > /* Suppress multiple warnings for propagated constant strings. */ > > > if (! TREE_NO_WARNING (src)) > > > --- 610,617 ---- > > > > > > /* If the offset is known to be out of bounds, warn, and call strlen at > > > runtime. */ > > > ! if (only_value != 2 > > > ! && (offset < 0 || offset > max)) > > > { > > > /* Suppress multiple warnings for propagated constant strings. */ > > > if (! TREE_NO_WARNING (src)) > > > > This looks wrong. I'd say you only want to disable the warning for > > only_value != 2, but still return NULL_TREE, otherwise the strlen call will > > be out of bounds in the compiler. So move only_value != 2 down to the > > second if ? > > Hmm, yeah. Probably doesn't matter for this use but I'm testing the > obvious fix. Fixed like so, bootstrapped and tested on x86_64-unknown-linux-gnu. Richard. 2014-07-14 Richard Biener * builtins.c (c_strlen): Make only_value == 2 really only affect warning generation. Index: gcc/builtins.c =================================================================== --- gcc/builtins.c (revision 212513) +++ gcc/builtins.c (working copy) @@ -610,11 +610,11 @@ c_strlen (tree src, int only_value) /* If the offset is known to be out of bounds, warn, and call strlen at runtime. */ - if (only_value != 2 - && (offset < 0 || offset > max)) + if (offset < 0 || offset > max) { /* Suppress multiple warnings for propagated constant strings. */ - if (! TREE_NO_WARNING (src)) + if (only_value != 2 + && !TREE_NO_WARNING (src)) { warning_at (loc, 0, "offset outside bounds of constant string"); TREE_NO_WARNING (src) = 1;