From patchwork Wed May 10 09:49:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 92006 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3492575vqo; Wed, 10 May 2023 02:50:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ722RmlxMTDQkR6UHagyXaE4x1vp30mzdOYDqcK979BRIgRNLwYkroLDEBwuZ77RrKW4xGq X-Received: by 2002:a17:907:70e:b0:965:6199:cf60 with SMTP id xb14-20020a170907070e00b009656199cf60mr14759190ejb.42.1683712252014; Wed, 10 May 2023 02:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683712252; cv=none; d=google.com; s=arc-20160816; b=GgJuweh6dm7feGojIVjUmed9nCJ38oxXYS4+sDzOfEt1fhlwml16GI6Ndi99f8p4kY NnMkHEK/LGARA5c7h+rGHVLd5kykX7jCnaNfgVnAN+bpvudSFYy16OV8UK19uDvbieIE 7waMpuinf7NFZCdAiCuh2SxLTnOs4SpJpyb6DGOhLnffDi3BuPNQfw3mvXVVBZdr3ZzQ FHWiOFy6P9zUPG0AA1OWHZ5lEYQyJhlOgOW1QzwQmzofrLFFpyfhPxazwmHhVInB9vzl W0qIiOy31FCVNt5bTC8dEVbKugMk4fTZQuNHd+Zqjqwh4lwNtx4La6UzTfbFQHAsMxgl IfpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=PXo6FCZ5sBtPMyVH7zO0lroJEsayrh2KERQIycnj+dk=; b=HhtOQ4T+UpByQ7quzk3qlLGFZvPjJmsGDjhj+T1GA8mHZ053CROAEYbhHxRpOEgKUB oPODqSwtFwu8VhunpORVdCudLHg4lh/l0tdE33iTbGjO61U6ZQ1xe0zSjHcx0m9b5HZ/ NzUHuTWWp0RRk/kPwS9gA7ixDhtZyb+F0I1ZM+hqYx6JM/HRiFWVJ3Csxoq5QVh1/+bN viXsI+7IrpcT/krGQUnZ9Fgzy4NZMQZ61eujSmJpi8ug6vsW9upOFM2ODnduQa42Vsmy sMZZBv4g+BHvu2iyzSFbV0MZCG2w216ED9TXmpcbPhFHJprFE9RFRuO1TMy0MnhJO2Ky MD0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=FJTOrKYh; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id h7-20020a1709067cc700b009602b562920si3590279ejp.794.2023.05.10.02.50.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 02:50:51 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=FJTOrKYh; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E71F33857023 for ; Wed, 10 May 2023 09:50:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E71F33857023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683712250; bh=PXo6FCZ5sBtPMyVH7zO0lroJEsayrh2KERQIycnj+dk=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=FJTOrKYhlu6KTBGJ1WCGLqF3J3aI6bfblJgQEUahoiJVfcV9FuGdghY6jzZrkOsaD Sm6j0kd5kNeTCkVarBGJuYcvzTqK7LBl3HgssmmqZ/eDu/Z96+bUGgh4XLm2RgFA8f 9Izu7bT9+aMY8BOPfMKs43eiILy2SjuFX6Rmkv8U= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 097183858C66 for ; Wed, 10 May 2023 09:50:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 097183858C66 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-652-4luKSYD_MWiIVqXlhihJPQ-1; Wed, 10 May 2023 05:50:00 -0400 X-MC-Unique: 4luKSYD_MWiIVqXlhihJPQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0CBDF101A531; Wed, 10 May 2023 09:50:00 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.156]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BAB5B48FB11; Wed, 10 May 2023 09:49:59 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 34A9nu4s3914073 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 10 May 2023 11:49:57 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 34A9nu543914070; Wed, 10 May 2023 11:49:56 +0200 Date: Wed, 10 May 2023 11:49:55 +0200 To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] ipa-prop: Fix ipa_get_callee_param_type for calls with argument type mismatches Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765500258572570502?= X-GMAIL-MSGID: =?utf-8?q?1765500258572570502?= Hi! The PR contains a testcase where the Fortran FE creates FUNCTION_TYPE which doesn't really match the passed in arguments (FUNCTION_TYPE has 5 arguments, call has 6). Now, I think that is a Fortran FE bug that should be fixed there, but I think with function pointers one can create something similar (of course invalid) in C/C++ too,so IMHO IPA should be also more careful. The ipa_get_callee_param_type function can return NULL if something goes wrong and it does e.g. if asked for 7th argument type on a function with just 5 arguments and similar. But, if a function isn't varargs, when asked for 6th argument type on a function with just 5 arguments it actually returns void_type_node because the argument list is in that case terminated with void_list_node. The following patch makes sure we don't treat void_list_node as something holding another argument. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-05-10 Jakub Jelinek PR fortran/109788 * ipa-prop.cc (ipa_get_callee_param_type): Don't return TREE_VALUE (t) if t is void_list_node. Jakub --- gcc/ipa-prop.cc.jj 2023-05-01 09:59:46.485296735 +0200 +++ gcc/ipa-prop.cc 2023-05-09 15:07:44.975578250 +0200 @@ -2147,7 +2147,7 @@ ipa_get_callee_param_type (struct cgraph break; t = TREE_CHAIN (t); } - if (t) + if (t && t != void_list_node) return TREE_VALUE (t); if (!e->callee) return NULL;