From patchwork Tue Apr 3 09:39:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 894484 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-475725-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="L+6JHBgO"; dkim-atps=neutral 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 40FkbD1fKqz9s1p for ; Tue, 3 Apr 2018 19:40:04 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=LcL7pxRUQe9OC2bFFdKtNBDzAOfP6NLLMjk7GdRQnb3Djw6Cdz BMEF3cQvOiRcrM2WNLndfcdBF8YxWqA+RhlCzJl0wse8QdHUkH7OrN4JzWJhq0Hn bNcV3wDYiUBUc3xz1MnV12sZvpS41Q+0DwmwEiRL3dOkc97kmFIOXxc3M= 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:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=Bz9GUjn4hWLUgbml5bVgZJYRvYc=; b=L+6JHBgOslbvCi+0CW/l TQ71iwzLzNpm3r94+XwLL+nuiP4qWsUAwYgh1wNR3KWP6XCuEsHswRZqK1A9Ttao kUTk0ObUwJ+mQCHl0tefiTypEmdnUedbd62lUfSJ4hP7W1qORE2lfqc+5WXmBFE1 IS8m98/6mPlH8CA7SZTk+KQ= Received: (qmail 95037 invoked by alias); 3 Apr 2018 09:39:57 -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 95006 invoked by uid 89); 3 Apr 2018 09:39:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=H*F:D*cz, Hx-languages-length:1891, H*UA:https, unsuitable 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; Tue, 03 Apr 2018 09:39:54 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 2A9CFAEDC for ; Tue, 3 Apr 2018 09:39:52 +0000 (UTC) From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PR 84947] Bits propagation only for int and ptr types User-Agent: Notmuch/0.26 (https://notmuchmail.org) Emacs/25.3.1 (x86_64-suse-linux-gnu) Date: Tue, 03 Apr 2018 11:39:51 +0200 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi, PR 84947 shows that when we LTO calls with type-mismatches, we can end up doing undefined shifts because we try to work with precision of types which do not have any. Fixed basically in the same way as Martin proposed in Bugzilla, the patch below also updates the comment and dump message to reflect that there is another reason to bail out early. LTO-bootstrapped and tested on x86_64-linux, OK for trunk? Thanks, Martin 2018-03-29 Martin Liska Martin Jambor PR ipa/84947 * ipa-cp.c (propagate_bits_across_jump_function): Bail out if param_type is not an integral or pointer type. --- gcc/ipa-cp.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index ee41a8d55b7..ec216010f2f 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -1811,14 +1811,16 @@ propagate_bits_across_jump_function (cgraph_edge *cs, int idx, struct ipa_node_params *callee_info = IPA_NODE_REF (callee); 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) + /* For K&R C programs, ipa_get_type() could return NULL_TREE. Avoid the + transform for these cases. Similarly, we can have bad type mismatches + with LTO, avoid doing anything with those too. */ + 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, - cs->callee->name ()); + fprintf (dump_file, "Setting dest_lattice to bottom, because type of " + "param %i of %s is NULL or unsuitable for bits propagation\n", + idx, cs->callee->name ()); return dest_lattice->set_to_bottom (); }