From patchwork Thu Dec 1 10:07:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 85996 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp616978qgi; Thu, 1 Dec 2016 02:08:24 -0800 (PST) X-Received: by 10.98.133.9 with SMTP id u9mr37783832pfd.137.1480586904801; Thu, 01 Dec 2016 02:08:24 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 76si68775109pfo.238.2016.12.01.02.08.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Dec 2016 02:08:24 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-443167-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-443167-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-443167-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=nlKwX4jHG/WRzant9k7G3OF5ID5OHNxLzLn/CSiz2OwFYx c0yAp2EcbELH/z+TyjpbgJNyu51mse96F+MM5gwpbxLGi3O/UfJtxKZX2ZxNFZub FodvpLCcHp9okdviBZY8mamK6R5sqzS8Ah4JU7vM8iO83zIqkVS1SZeR3+Soo= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=JHTwIKAi/MY9S5DpgKQlRxzm69o=; b=KRbd2P2nG6rS8nh/hpoH HR+elykRrA4SGU7QCjKjs48+/ImUUtPh2cCTfUvdVR792iBDFuBTbcCOayoNAqrc 6/2C1tcQ2YwSl7/BywbWYeRpIy2tGOahdT7KVLkbluBVuUuxMg3kNKskkwsb86U8 FaOtl7CiaW2pNZmjJjpMddA= Received: (qmail 21692 invoked by alias); 1 Dec 2016 10:08:09 -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 21657 invoked by uid 89); 1 Dec 2016 10:08:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=parms, sk:pratham, U*prathamesh.kulkarni, prathameshkulkarnilinaroorg X-HELO: mail-io0-f170.google.com Received: from mail-io0-f170.google.com (HELO mail-io0-f170.google.com) (209.85.223.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 01 Dec 2016 10:07:58 +0000 Received: by mail-io0-f170.google.com with SMTP id m5so274649187ioe.3 for ; Thu, 01 Dec 2016 02:07:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ZZvOvhNvWqJ5Ec+Uhf4BA8lgR2W/2wwnf/+tVjbPx3w=; b=DiJRep40eibqWpZ4syMEExbRmcYBh0WgVAhrCOtLNrdGk8DOnBC28Doo6beHtIocJi mg4Iu0cyNBTfTc7GNMtsEwlk9STj+FbUZWmVe5oeVks/3R5h6QE4QWpw5WI1N8sEcobC yZLSJmvz+ytXfMyYO2ijqg64l8bUIidNjYm25O6/58fI8dNXapqhQEdppybVUO6hU1Av d5Tt+N3eSNchnuJ0Tq47WgkEM6GZmcatSGu2h88XCxFkWCgpqDxWg4nyUPcHKSpGqAfb HL+w8t0hKA7Ab3AKLGYf1IUnoRuoPNn1Xd0lqe3gUV+iWrSEWM1AMp0jV1VyFGyQCA2E 7kHg== X-Gm-Message-State: AKaTC01mty7JE+y+bAWOxWJ2lbGTVKlrCADCTTy/O2JdJEuoGkjYYZipS+gM7uuNJXwmJfI6F/53ihL/OIBzmDRD X-Received: by 10.107.55.136 with SMTP id e130mr30218541ioa.76.1480586876132; Thu, 01 Dec 2016 02:07:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.47.92 with HTTP; Thu, 1 Dec 2016 02:07:55 -0800 (PST) From: Prathamesh Kulkarni Date: Thu, 1 Dec 2016 15:37:55 +0530 Message-ID: Subject: PR78599 To: gcc Patches , Jan Hubicka , Martin Jambor X-IsSubscribed: yes Hi, As mentioned in PR, the issue seems to be that in propagate_bits_accross_jump_functions(), ipa_get_type() returns record_type during WPA and hence we pass invalid precision to ipcp_bits_lattice::meet_with (value, mask, precision) which eventually leads to runtime error. The attached patch tries to fix that, by bailing out if type of param is not integral or pointer type. This happens for the edge from deque_test -> _Z4copyIPd1BEvT_S2_T0_.isra.0/9. However I am not sure how ipcp_bits_lattice::meet_with (value, mask, precision) gets called for this case. In ipa_compute_jump_functions_for_edge(), we set jfunc->bits.known to true only if parm's type satisfies INTEGRAL_TYPE_P or POINTER_TYPE_P. And ipcp_bits_lattice::meet_with (value, mask, precision) is called only if jfunc->bits.known is set to true. So I suppose it shouldn't really happen that ipcp_bits_lattice::meet_with(value, mask, precision) gets called when callee parameter's type is record_type, since the corresponding argument's type would also need to be record_type and jfunc->bits.known would be set to false. Without -flto, parm_type is reference_type so that satisfies POINTER_TYPE_P, but with -flto it's appearing to be record_type. Is this possibly the same issue of TYPE_ARG_TYPES returning bogus types during WPA ? I verified the attached patch fixes the runtime error with ubsan-built gcc. Bootstrap+tested on x86_64-unknown-linux-gnu. Cross-tested on arm*-*-*, aarch64*-*-*. LTO bootstrap on x86_64-unknown-linux-gnu in progress. Is it OK to commit if it succeeds ? Thanks, Prathamesh 2016-12-01 Prathamesh Kulkarni PR ipa/78599 * ipa-cp.c (propagate_bits_accross_jump_function): Check if parm_type is integral or pointer type. diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 2ec671f..28eb74c 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -1770,12 +1770,15 @@ propagate_bits_accross_jump_function (cgraph_edge *cs, int idx, ipa_jump_func *j tree parm_type = ipa_get_type (callee_info, idx); /* For K&R C programs, ipa_get_type() could return NULL_TREE. - Avoid the transform for these cases. */ - if (!parm_type) + Avoid the transform for these cases or if parm type is not + integral or pointer type. */ + if (!parm_type + || !(INTEGRAL_TYPE_P (parm_type) || POINTER_TYPE_P (parm_type))) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Setting dest_lattice to bottom, because" - " param %i type is NULL for %s\n", idx, + " param %i type is %s for %s\n", idx, + (parm_type == NULL) ? "NULL" : "non-integral", cs->callee->name ()); return dest_lattice->set_to_bottom ();