From patchwork Fri Jan 27 09:02:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 49117 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp728456wrn; Fri, 27 Jan 2023 01:02:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXvFPnRDRSbtB6rcRlrVwT7TzJH0RgNfrZcrFVXmd7ldgKuh4f25e/K9I4pvGI/PEHrOktmF X-Received: by 2002:a05:6402:174d:b0:494:eb9:54c4 with SMTP id v13-20020a056402174d00b004940eb954c4mr35734166edx.19.1674810175149; Fri, 27 Jan 2023 01:02:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674810175; cv=none; d=google.com; s=arc-20160816; b=ZXqUsxZfnlKW1hytOEnM37VZsG0bu6WctKwDZbrmyI0fi+7OGvdXxTv+qSTwKvJCPI rMwd8JNGUB2UgyX0bOnm8FJyru7FVz++A2z47m4KS6g1Zom9V+244aoMQx2iR8bDM72v sdY2DRYDqXlmvqUPIRRfWmDtVF0NzNKUJXDCRsRtwAsH2Ib0MxoAG6DmjCk7D0/GNNVu 980GhFSQtOOF9eYk8b0Tebx8JyKV5HWRkONxG+3aAJPI1P7q4rEyKY/q72rDsAhHiT6N WBx8A/NUK2AjIH6AFNzjr41WdgHRR0yz/t+dQwx/GCEzdp/SI0Jq4JViBG3s4uRpDL0D gvaw== 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=yQyo9Fm1OhIH0kywNrminVFhX2VDT0fEDzxL8ekosj4=; b=yc5/QMz55Odg364viIiNqJZR4vVWPkWTeEkg3ot5Nd1bqtwIzwKC/kcIxXuIZNzVcU KQ5DY4JngxVJzKeKgJDl+2wH92UnJueUEVZGG7nZUrah051mnfSy994qywVPFtsYaMaw FpQuxhxG9j0GjyOLevUo6YgBehkV9/D3A+g3z3ecjLvdqP5Qdk/rZWl00uiZSiSbdp7y FEn88E093MLzFcIyvy6rfpXMKgywLE1NZKwvpHa3+ShighuAquyXC0JVTPnWZJROQYu2 eQI2hrpZPZM79is5zWlMgTixLfYCb2PacnbwOpUXBMq9y4Qp0sCEiuycaOp1a4pVAo/6 EAyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=lfVZ+6aD; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id en7-20020a056402528700b0047f3dfa596asi4661790edb.162.2023.01.27.01.02.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 01:02:55 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=lfVZ+6aD; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 DFA943858422 for ; Fri, 27 Jan 2023 09:02:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFA943858422 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674810173; bh=yQyo9Fm1OhIH0kywNrminVFhX2VDT0fEDzxL8ekosj4=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=lfVZ+6aDzWJXxGwfame6X+lZ7Wz6VYV+coDyneq3MFEnt3K2JY6tqDz30s0OqGvez LnOKxg+XqNLYMqvyYGcC+oNrvhtTJJZy5l5KtLMOmJL8KJxWCd889BKW4cwhCel2vC HnLgCo+HE+VCzc8vL30SZIl7bbVsuYgtW1sCDHGg= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id EB5CA3858D20 for ; Fri, 27 Jan 2023 09:02:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EB5CA3858D20 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-361-sslXe9xaOfy8_L0un8IbDw-1; Fri, 27 Jan 2023 04:02:05 -0500 X-MC-Unique: sslXe9xaOfy8_L0un8IbDw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CD653857F82; Fri, 27 Jan 2023 09:02:04 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F31E40C945A; Fri, 27 Jan 2023 09:02:04 +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 30R921rV681301 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 27 Jan 2023 10:02:02 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 30R920cx681300; Fri, 27 Jan 2023 10:02:00 +0100 Date: Fri, 27 Jan 2023 10:02:00 +0100 To: Jan Hubicka , Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] cgraph: Adjust verify_corresponds_to_fndecl [PR106061] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 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 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?1756165754325782825?= X-GMAIL-MSGID: =?utf-8?q?1756165754325782825?= Hi! IPA passes redirect some calls in what it determines to be unreachable code to builtin_decl_unreachable. But that function returns sometimes builtin_decl_explicit (BUILT_IN_UNREACHABLE) (which was what GCC 12 and earlier did always), or builtin_decl_explicit (BUILT_IN_TRAP) (e.g. for -funreachable-traps, -O0, -Og). Now the cgraph verification code has a code to verify cgraph edges and has there an exception for these redirections to BUILT_IN_UNREACHABLE, but doesn't have for BUILT_IN_TRAP, so e.g. the following testcase ICEs during that verification. The following patch just adds BUILT_IN_TRAP to those exceptions. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-01-27 Jakub Jelinek PR ipa/106061 * cgraph.cc (cgraph_edge::verify_corresponds_to_fndecl): Allow redirection of calls to __builtin_trap in addition to redirection to __builtin_unreachable. * gcc.dg/pr106061.c: New test. Jakub --- gcc/cgraph.cc.jj 2023-01-19 09:58:50.000000000 +0100 +++ gcc/cgraph.cc 2023-01-26 15:30:50.422759246 +0100 @@ -3248,9 +3248,11 @@ cgraph_edge::verify_corresponds_to_fndec node = node->ultimate_alias_target (); /* Optimizers can redirect unreachable calls or calls triggering undefined - behavior to builtin_unreachable. */ + behavior to __builtin_unreachable or __builtin_trap. */ - if (fndecl_built_in_p (callee->decl, BUILT_IN_UNREACHABLE)) + if (fndecl_built_in_p (callee->decl, BUILT_IN_NORMAL) + && (DECL_FUNCTION_CODE (callee->decl) == BUILT_IN_UNREACHABLE + || DECL_FUNCTION_CODE (callee->decl) == BUILT_IN_TRAP)) return false; if (callee->former_clone_of != node->decl --- gcc/testsuite/gcc.dg/pr106061.c.jj 2023-01-26 15:40:06.002721103 +0100 +++ gcc/testsuite/gcc.dg/pr106061.c 2023-01-26 15:41:32.553468886 +0100 @@ -0,0 +1,18 @@ +/* PR ipa/106061 */ +/* { dg-do compile } */ +/* { dg-options "-Og" } */ + +extern void foo (void); + +inline void +bar (int x) +{ + if (x) + foo (); +} + +void +baz (void) +{ + bar (0); +}