Message ID | ZFtow4ihR8drfg7g@tucnak |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> 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 <ouuuleilei@gmail.com> (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 <ouuuleilei@gmail.com>; 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 <gcc-patches@gcc.gnu.org>; 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 <rguenther@suse.de> Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] ipa-prop: Fix ipa_get_callee_param_type for calls with argument type mismatches Message-ID: <ZFtow4ihR8drfg7g@tucnak> 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-Type: text/plain; charset=us-ascii 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jakub Jelinek <jakub@redhat.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765500258572570502?= X-GMAIL-MSGID: =?utf-8?q?1765500258572570502?= |
Series |
ipa-prop: Fix ipa_get_callee_param_type for calls with argument type mismatches
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Jakub Jelinek
May 10, 2023, 9:49 a.m. UTC
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 <jakub@redhat.com> PR fortran/109788 * ipa-prop.cc (ipa_get_callee_param_type): Don't return TREE_VALUE (t) if t is void_list_node. Jakub
Comments
On Wed, 10 May 2023, Jakub Jelinek wrote: > 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? OK. Thanks, Richard. > 2023-05-10 Jakub Jelinek <jakub@redhat.com> > > PR fortran/109788 > * ipa-prop.cc (ipa_get_callee_param_type): Don't return TREE_VALUE (t) > if t is void_list_node. > > --- 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; > > 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;