From patchwork Thu Dec 22 13:08:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 88861 Delivered-To: patch@linaro.org Received: by 10.182.112.6 with SMTP id im6csp3232208obb; Thu, 22 Dec 2016 05:09:02 -0800 (PST) X-Received: by 10.99.146.76 with SMTP id s12mr16924954pgn.8.1482412142484; Thu, 22 Dec 2016 05:09:02 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id y6si14426242pge.231.2016.12.22.05.09.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Dec 2016 05:09:02 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-444972-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-444972-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-444972-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=QqBkc6FH4N7nYuwltHEeheExyQ8g9RsYj+2ya4xpSWtOlivXrq 69bnorNRrjVlN2rRyAfCt/3IXB3jZzwCOdDI28/EIMayrdX2L9e2J8sq7kMnIVfG EpVbXa2Uz8QxGX057AE6Oywe1UyrqKtyTiQ1LKpFdt18akrd82RG3BeWQ= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=kvqpy7HLpweb+2AOcMvPjkt3GT0=; b=F2ezyLtvK00k1daGMzD5 mcqYrbWwxwvKjEvDhUM0U7KlAWq2s7+YuBKYN4KpF9fEiUGwR34h2BzPdmMu1opg I63U6CtKoYErmOHfCwKYmJ5mXIVtoHlPGZ6y8h0+BgxHXInr35H6klytUpBcwC7x 6CvCIVpRs6zK06UnyPZcDP8= Received: (qmail 91777 invoked by alias); 22 Dec 2016 13:08:49 -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 91767 invoked by uid 89); 22 Dec 2016 13:08:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS 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; Thu, 22 Dec 2016 13:08:38 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 388E5AC0D; Thu, 22 Dec 2016 13:08:36 +0000 (UTC) To: GCC Patches Cc: Jakub Jelinek From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: [PATCH] Fix tree-optimization/78886. Message-ID: <3a623200-044e-37da-4a14-d6ee0a286863@suse.cz> Date: Thu, 22 Dec 2016 14:08:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 X-IsSubscribed: yes Patch is pre-approved by Jakub. I guess the same patch can be install to both release branches after it finishes regression tests, right? Thanks, Martin >From b0efc394e047ebc25386f8cb99f595b8d4c7f83a Mon Sep 17 00:00:00 2001 From: marxin Date: Wed, 21 Dec 2016 16:21:45 +0100 Subject: [PATCH] Fix tree-optimization/78886. gcc/testsuite/ChangeLog: 2016-12-22 Martin Liska PR tree-optimization/78886 * gcc.dg/tree-ssa/pr78886.c: New test. gcc/ChangeLog: 2016-12-22 Martin Liska PR tree-optimization/78886 * tree-ssa-strlen.c (handle_builtin_malloc): Return when LHS is equal to NULL. --- gcc/testsuite/gcc.dg/tree-ssa/pr78886.c | 10 ++++++++++ gcc/tree-ssa-strlen.c | 3 +++ 2 files changed, 13 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr78886.c diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr78886.c b/gcc/testsuite/gcc.dg/tree-ssa/pr78886.c new file mode 100644 index 00000000000..97799301547 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr78886.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +void *malloc(unsigned long x); + +void foo(void) +{ + volatile int i; + malloc(1); + i; +} diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index 67075f07e29..4a05725ca7c 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -1869,6 +1869,9 @@ handle_builtin_malloc (enum built_in_function bcode, gimple_stmt_iterator *gsi) { gimple *stmt = gsi_stmt (*gsi); tree lhs = gimple_call_lhs (stmt); + if (lhs == NULL_TREE) + return; + gcc_assert (get_stridx (lhs) == 0); int idx = new_stridx (lhs); tree length = NULL_TREE; -- 2.11.0