From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674810128; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=yQyo9Fm1OhIH0kywNrminVFhX2VDT0fEDzxL8ekosj4=; b=c0q3vpW0+5EtF3IxDXZQrmZ6bK8yyoYaw5et5h6GAJNapBhZI/xqFKUX3D9YgyfXlxIxMB BCuJwsEP7IlJid37lHmIcyAF2ocdkKYdrJO5wdnrJf/nuWxV9hDdDbe+C9xQ1ftRtHlejl Uh/tu4smlmFCc9XxfDHnncxAZ2QoNtY= 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 From: Jakub Jelinek To: Jan Hubicka , Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] cgraph: Adjust verify_corresponds_to_fndecl [PR106061] Message-ID: Reply-To: Jakub Jelinek 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-Type: text/plain; charset=us-ascii 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 List-Id: 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. --- 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); +} Jakub