From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 991813858D20 for ; Fri, 27 Jan 2023 09:59:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 991813858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 2117721E84; Fri, 27 Jan 2023 09:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674813560; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EVjkn68p+aYvD0HgRdaGNAfk3qMgUq0ZarTSmJGjDSQ=; b=acu5QJQ96qHZD+0Jvcjc7lSC5au+JRNsxBjkSfPdSt0pVdg8EHaeOhd+L9axlji5SmHJi1 +S8D+oUZ8weZKHuSNQBSG2ebS/ga16wQNPC6UcTxnE4tuUeNlHq9lpfHOT9Lc7zDY09E3Y WKbXpiNzL+BbphYTUUyxyIe3b03gY2k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674813560; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EVjkn68p+aYvD0HgRdaGNAfk3qMgUq0ZarTSmJGjDSQ=; b=4LY8Opx04WAlCPfDbxVf3RAvKcp0Vkx5PkXmsxd8fT5angHiQLIssKLYtCZjlS6vN+InMU uT1/J0UC3vn6i5DQ== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 155102C141; Fri, 27 Jan 2023 09:59:20 +0000 (UTC) Date: Fri, 27 Jan 2023 09:59:20 +0000 (UTC) From: Richard Biener To: Jakub Jelinek cc: Jan Hubicka , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] cgraph: Adjust verify_corresponds_to_fndecl [PR106061] In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,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: On Fri, 27 Jan 2023, Jakub Jelinek wrote: > 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? OK. > 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 > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)