From patchwork Mon Mar 20 19:15:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 741144 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 3vn5JZ1nxhz9s76 for ; Tue, 21 Mar 2017 06:15:57 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="iLQgN+Xq"; dkim-atps=neutral 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:date:mime-version:content-type :content-transfer-encoding:message-id; q=dns; s=default; b=lYE0S cX1Rup9Ds/b8W3dP3qZzLceRQ94jOmqXWXKEz63DiHxO6vcU7TznoXhXBNdIOFZr bUt1H0eGpeVOOc7sv++fqFwz28lE9p4VnUVlPxT0XRCDjLmEHXG4bZTF2L7nisat GAoZPcW7g+ef5KjpVCSUzlJGKPuU7giYWu+wxg= 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:date:mime-version:content-type :content-transfer-encoding:message-id; s=default; bh=aoAXYgsidXl 9lK0raXKgg3Id1gw=; b=iLQgN+XqVXY+9Abn7093nEIOorKy+zj7pQNQe5iXeNL /9BJ1mvXvHp/RQfoPOhVpASsQuLUwDi3WWirGIL9a+tNCsYMgkgzJGA7BgRhx55E 6emqaQ0qtMgc+IbLg5Dk1tMqjerXUliqLo+rrMKNBb/FplUblUuOB3JjgMIUIUdE = Received: (qmail 38299 invoked by alias); 20 Mar 2017 19:15:43 -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 38280 invoked by uid 89); 20 Mar 2017 19:15:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=U*rguenth, wholesale X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 20 Mar 2017 19:15:41 +0000 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2KJDTo5082754 for ; Mon, 20 Mar 2017 15:15:40 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 29ambmt0xw-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 20 Mar 2017 15:15:40 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 20 Mar 2017 13:15:38 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 20 Mar 2017 13:15:37 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v2KJFasR16580966; Mon, 20 Mar 2017 12:15:36 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 775246A03C; Mon, 20 Mar 2017 13:15:36 -0600 (MDT) Received: from bigmac.rchland.ibm.com (unknown [9.10.86.201]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 492CC6A04A; Mon, 20 Mar 2017 13:15:36 -0600 (MDT) To: GCC Patches Cc: Richard Biener From: Bill Schmidt Subject: [PATCH v2] Fix PR79908 Date: Mon, 20 Mar 2017 14:15:35 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17032019-0016-0000-0000-000006688B22 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006818; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000206; SDB=6.00836475; UDB=6.00411115; IPR=6.00614243; BA=6.00005224; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014729; XFM=3.00000013; UTC=2017-03-20 19:15:38 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17032019-0017-0000-0000-000038514877 Message-Id: <84021880-52c1-38ad-ea08-29448b60b570@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-20_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703200163 X-IsSubscribed: yes Hi, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79908 shows a case where pass_stdarg ICEs attempting to gimplify a COMPLEX_EXPR with side effects as an lvalue. This occurs when the LHS of a VA_ARG has been cast away. This patch, credit to Richard Biener, uses force_gimple_operand to instantiate the necessary side effects rather than gimplify_expr using is_gimple_lvalue. The test case is taken wholesale from the bug report. Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no regressions. Is this ok for trunk? Thanks, Bill [gcc] 2017-03-20 Bill Schmidt Richard Biener PR tree-optimization/79908 * tree-stdarg.c (expand_ifn_va_arg_1): For a VA_ARG whose LHS has been cast away, use force_gimple_operand to construct the side effects. [gcc/testsuite] 2017-03-20 Bill Schmidt Richard Biener PR tree-optimization/79908 * gcc.dg/torture/pr79908.c: New file. Index: gcc/testsuite/gcc.dg/torture/pr79908.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr79908.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/pr79908.c (working copy) @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +/* Used to fail in the stdarg pass before fix for PR79908. */ + +typedef __builtin_va_list __gnuc_va_list; +typedef __gnuc_va_list va_list; + +void testva (int n, ...) +{ + va_list ap; + _Complex int i = __builtin_va_arg (ap, _Complex int); +} Index: gcc/tree-stdarg.c =================================================================== --- gcc/tree-stdarg.c (revision 246286) +++ gcc/tree-stdarg.c (working copy) @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple-iterator.h" #include "gimple-walk.h" #include "gimplify.h" +#include "gimplify-me.h" #include "tree-into-ssa.h" #include "tree-cfg.h" #include "tree-stdarg.h" @@ -1058,12 +1059,16 @@ expand_ifn_va_arg_1 (function *fun) gimplify_assign (lhs, expr, &pre); } else - gimplify_expr (&expr, &pre, &post, is_gimple_lvalue, fb_lvalue); + { + gimple_seq tmp_seq; + force_gimple_operand (expr, &tmp_seq, false, NULL_TREE); + gimple_seq_add_seq_without_update (&pre, tmp_seq); + } input_location = saved_location; pop_gimplify_context (NULL); - gimple_seq_add_seq (&pre, post); + gimple_seq_add_seq_without_update (&pre, post); update_modified_stmts (pre); /* Add the sequence after IFN_VA_ARG. This splits the bb right @@ -1072,11 +1077,10 @@ expand_ifn_va_arg_1 (function *fun) gimple_find_sub_bbs (pre, &i); /* Remove the IFN_VA_ARG gimple_call. It's the last stmt in the - bb. */ + bb if we added any stmts. */ unlink_stmt_vdef (stmt); release_ssa_name_fn (fun, gimple_vdef (stmt)); gsi_remove (&i, true); - gcc_assert (gsi_end_p (i)); /* We're walking here into the bbs which contain the expansion of IFN_VA_ARG, and will not contain another IFN_VA_ARG that needs