From patchwork Fri Nov 11 13:44:40 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: 81829 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1274037qge; Fri, 11 Nov 2016 05:45:10 -0800 (PST) X-Received: by 10.98.73.203 with SMTP id r72mr7222112pfi.75.1478871910157; Fri, 11 Nov 2016 05:45:10 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id h132si10231771pgc.330.2016.11.11.05.45.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Nov 2016 05:45:10 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-441098-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-441098-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-441098-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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=FVIHxpS3YfS/6JSo3 h+ShVVULwGvzmZx2aLzLOPqJWKXXtG/Xc3zzbxFC4Us6Y46REgGTKvSM51cP2yl0 hicd1Xa713fu1ZlBFp0kckFN0zEa/D3n7q7rUKPKDFi4DIGZAscDccbRsCXZXhcT 5q8zOHDS4vtuJK+WkF0Is/zzoE= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=5uDgB01emAmTCmUuBA6wwo4 ARds=; b=wwT9EilDovVJHTHsmGBOxXwzrVwjjRGVmG2o8MJu3pzPnIUj8SqJ/ak jZsDZwBK+Y9JZBLjyYOQP/CkZIPPVoq01MjXv3Sexp5MHKGVX8mE3UUNSbVdoWV6 rBz1uGQUy7lheVhH0C7FpZ2PbOqzVNKdb7Y6BeEuiZZey943uSxE= Received: (qmail 105310 invoked by alias); 11 Nov 2016 13:44:54 -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 105292 invoked by uid 89); 11 Nov 2016 13:44:53 -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=20161111 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; Fri, 11 Nov 2016 13:44:43 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0DF53AC34; Fri, 11 Nov 2016 13:44:41 +0000 (UTC) Subject: [PATCH] Fix PR sanitizer/78270 (part 2) To: Jakub Jelinek References: <475cb650-8a3d-8395-9f93-da12e8e841a1@suse.cz> <20161109132900.GA3541@tucnak.redhat.com> <6339c6f2-fa0e-d63e-fe2a-f7ca9d7ae924@suse.cz> <4a129694-400b-9899-de79-4f0f07ed6311@suse.cz> <20161110110729.GF3541@tucnak.redhat.com> Cc: GCC Patches From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: Date: Fri, 11 Nov 2016 14:44:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161110110729.GF3541@tucnak.redhat.com> X-IsSubscribed: yes Hello. Due to a stupid mistake I did, following patch is needed for the test-case to properly save previous gimplify_ctxp->live_switch_vars. Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. I was able to run asan bootstrap on x86_64-linux-gnu and kernel build with allyesconfig works fine. Ready to be installed? Martin >From 53dd3c035283863a25a24feb90bf359295999bca Mon Sep 17 00:00:00 2001 From: marxin Date: Fri, 11 Nov 2016 11:21:29 +0100 Subject: [PATCH] Fix PR sanitizer/78270 (part 2) gcc/ChangeLog: 2016-11-11 Martin Liska PR sanitizer/78270 * gimplify.c (gimplify_switch_expr): Always save previous gimplify_ctxp->live_switch_vars. gcc/testsuite/ChangeLog: 2016-11-11 Martin Liska PR sanitizer/78270 * gcc.dg/asan/pr78270-2.c: New test. --- gcc/gimplify.c | 8 ++++---- gcc/testsuite/gcc.dg/asan/pr78270-2.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/asan/pr78270-2.c diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 16573dd..c23888b 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2255,11 +2255,11 @@ gimplify_switch_expr (tree *expr_p, gimple_seq *pre_p) gimplify_ctxp->case_labels.create (8); /* Do not create live_switch_vars if SWITCH_BODY is not a BIND_EXPR. */ + saved_live_switch_vars = gimplify_ctxp->live_switch_vars; if (TREE_CODE (SWITCH_BODY (switch_expr)) == BIND_EXPR) - { - saved_live_switch_vars = gimplify_ctxp->live_switch_vars; - gimplify_ctxp->live_switch_vars = new hash_set (4); - } + gimplify_ctxp->live_switch_vars = new hash_set (4); + else + gimplify_ctxp->live_switch_vars = NULL; bool old_in_switch_expr = gimplify_ctxp->in_switch_expr; gimplify_ctxp->in_switch_expr = true; diff --git a/gcc/testsuite/gcc.dg/asan/pr78270-2.c b/gcc/testsuite/gcc.dg/asan/pr78270-2.c new file mode 100644 index 0000000..d1f5d26 --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr78270-2.c @@ -0,0 +1,17 @@ +// { dg-do compile } +// { dg-additional-options "-Wno-switch-unreachable" } + +int a; +void +fn1 () +{ + switch (a) + { + char b; + case 8: + &b; + switch (0) + ; + } +} + -- 2.10.1