From patchwork Sun Dec 14 20:46:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 42213 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A0E8121772 for ; Sun, 14 Dec 2014 20:46:52 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id p9sf6490190lbv.5 for ; Sun, 14 Dec 2014 12:46:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:mime-version:date:message-id:subject:from:to :content-type:x-original-sender:x-original-authentication-results; bh=u2TXhwLH0JhSvZW0dKUJUirfquCUnVMfdF3otgZeFrA=; b=EqdHy+OBPxEWqLSSpOft+fDp8YNEqX7CXE0lddZOIhBQASSIZYZ/B8jl0iNfbVh6WU wrjKijzHdNH502Ki74Cqhl9wSGBoKa2fzOBvj6YHbQENZxz0oniG6/O+fNseeu1daZBQ b+2ZoplM6fEbvMA2PeZSdSAjJG26pDoMX8PTAkNwjJ2BA7TFWceNzLpjSgXgpLqj14TM kn67AR+BFSHGxQHAQ+Kj5ZXkHDs2rMLfA85MKzCLRPSTVbDn32yhpyvdU1lny1N0ETfl pxX3kaLKe6DixI4NeBMyUoQr12P782kOCi86k+kcspov/3FRbSjMMywyi9GYd3uWFNtP KTSA== X-Gm-Message-State: ALoCoQkXrnwnoi2hk/1XGUTRl1oF5rSqMRJUOAw/sc2pTkqYbu5TB1bc+1pk4IVwhfc2zFalO+sM X-Received: by 10.112.142.36 with SMTP id rt4mr4120480lbb.3.1418590011615; Sun, 14 Dec 2014 12:46:51 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.67 with SMTP id 3ls680405las.61.gmail; Sun, 14 Dec 2014 12:46:51 -0800 (PST) X-Received: by 10.152.7.229 with SMTP id m5mr27158995laa.80.1418590011468; Sun, 14 Dec 2014 12:46:51 -0800 (PST) Received: from mail-la0-x236.google.com (mail-la0-x236.google.com. [2a00:1450:4010:c03::236]) by mx.google.com with ESMTPS id v7si8491404lag.130.2014.12.14.12.46.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 14 Dec 2014 12:46:51 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::236 as permitted sender) client-ip=2a00:1450:4010:c03::236; Received: by mail-la0-f54.google.com with SMTP id pv20so8239941lab.41 for ; Sun, 14 Dec 2014 12:46:51 -0800 (PST) X-Received: by 10.112.136.69 with SMTP id py5mr13224188lbb.56.1418590011205; Sun, 14 Dec 2014 12:46:51 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp540004lbb; Sun, 14 Dec 2014 12:46:49 -0800 (PST) X-Received: by 10.68.189.105 with SMTP id gh9mr11299972pbc.142.1418590009005; Sun, 14 Dec 2014 12:46:49 -0800 (PST) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id dc4si11107809pbb.101.2014.12.14.12.46.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Dec 2014 12:46:48 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-387363-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 21701 invoked by alias); 14 Dec 2014 20:46:32 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 21586 invoked by uid 89); 14 Dec 2014 20:46:31 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-lb0-f179.google.com Received: from mail-lb0-f179.google.com (HELO mail-lb0-f179.google.com) (209.85.217.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 14 Dec 2014 20:46:30 +0000 Received: by mail-lb0-f179.google.com with SMTP id z11so8154502lbi.10 for ; Sun, 14 Dec 2014 12:46:27 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.112.157.104 with SMTP id wl8mr13489408lbb.96.1418589986890; Sun, 14 Dec 2014 12:46:26 -0800 (PST) Received: by 10.25.211.16 with HTTP; Sun, 14 Dec 2014 12:46:26 -0800 (PST) Date: Mon, 15 Dec 2014 02:16:26 +0530 Message-ID: Subject: [match-and-simplify] set simplify::capture_max to 0 if pattern contains no captures From: Prathamesh Kulkarni To: rguenther@suse.de, gcc-patches@gcc.gnu.org X-IsSubscribed: yes X-Original-Sender: prathamesh.kulkarni@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::236 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 Caused segfault for pattern containing no captures at: info.safe_grow_cleared(capture_max + 1); in capture_info::capture_info artificial test-case: (define_predicates integer_zerop) (simplify (bit_not integer_zerop) { build_zero_cst (type); }) * genmatch.c (simplify::simplify): Set simplify::capture_max to 0 if pattern contains no captures. Thanks, Prathamesh Index: gcc/genmatch.c =================================================================== --- gcc/genmatch.c (revision 218664) +++ gcc/genmatch.c (working copy) @@ -576,7 +576,7 @@ : match (match_), match_location (match_location_), result (result_), result_location (result_location_), ifexpr_vec (ifexpr_vec_), for_vec (for_vec_), - capture_ids (capture_ids_), capture_max (capture_ids_->elements () - 1) {} + capture_ids (capture_ids_), capture_max (capture_ids_->elements () ? capture_ids_->elements () - 1 : 0) {} /* The expression that is matched against the GENERIC or GIMPLE IL. */ operand *match;