From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 20BD73858CDB for ; Fri, 12 Apr 2024 08:36:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 20BD73858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 20BD73858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712910973; cv=none; b=juQ/447ufChpwnyBrD/vXAWCgSngc0ouyj9aDek00hk0DZsC81owI6iZPdiVj38jCImZ8SbGgZmN4pH/q5BoghzfFfEhheNpjob//vOwHwWB6HtZRv89giR4YJL3DQqQkRPzrOem/k2kbleOhxsIzutM5f49RTk8A2luLTejKTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712910973; c=relaxed/simple; bh=w4ySh0iUZZQ9sndIJI3xMB2DE4BqeRFb9GWuOAEUtkI=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: Mime-Version:Subject:Date:Message-Id:To; b=BAZJEO83P07qXnROmOQ4YHJo52dLVuFz0w5lNIHEPEAruDFS2qCn1szxAtOnLmaKqw2D42NFmmP59Pr2i36qpevXybgEGrE0DklpH2GbQjzt10kO6lkKpwO5OBAyKyQ9JMHe1P8/7yuctt5Cf1TtbgqYYt0zUaDxcbnlT9jazdw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 0318A5FA3A; Fri, 12 Apr 2024 08:36:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712910970; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QToAn9rrq/bLljxDLXJvBipjzvAQafP745P/eknyKl8=; b=vHfYbNAcp0lKNDkHN+5P1RTG9i5JkyVi8nhCxyhmviboGwUql0WodGrYSZauuGfG8kJBjU uW1GWma/uzt5thNCK5a1OetZEIxQ6zCaDGDnUd2WP4wSRdsuLg/Igqn0h4lX64buu+i7LV i5niO1Up2GRZ7vHF9p1jVyPMB1IwXbg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712910970; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QToAn9rrq/bLljxDLXJvBipjzvAQafP745P/eknyKl8=; b=zcqyxa/tWqhTGXCeb8Z7dtXBNoNyoINeX6uQPXjc8Ljmgw9TdJIAoNcnpnx8N3XlYUtmzP 45bMtgklhw/jC4Bw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712910970; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QToAn9rrq/bLljxDLXJvBipjzvAQafP745P/eknyKl8=; b=vHfYbNAcp0lKNDkHN+5P1RTG9i5JkyVi8nhCxyhmviboGwUql0WodGrYSZauuGfG8kJBjU uW1GWma/uzt5thNCK5a1OetZEIxQ6zCaDGDnUd2WP4wSRdsuLg/Igqn0h4lX64buu+i7LV i5niO1Up2GRZ7vHF9p1jVyPMB1IwXbg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712910970; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QToAn9rrq/bLljxDLXJvBipjzvAQafP745P/eknyKl8=; b=zcqyxa/tWqhTGXCeb8Z7dtXBNoNyoINeX6uQPXjc8Ljmgw9TdJIAoNcnpnx8N3XlYUtmzP 45bMtgklhw/jC4Bw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E7EF81368B; Fri, 12 Apr 2024 08:36:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ykaZOHnyGGZ/AQAAD6G6ig (envelope-from ); Fri, 12 Apr 2024 08:36:09 +0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Richard Biener Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] Limit special asan/ubsan/bitint returns_twice handling to calls in bbs with abnormal pred [PR114687] Date: Fri, 12 Apr 2024 10:35:59 +0200 Message-Id: References: Cc: gcc-patches@gcc.gnu.org In-Reply-To: To: Jakub Jelinek X-Mailer: iPhone Mail (21E236) X-Spam-Score: -4.26 X-Spam-Level: X-Spamd-Result: default: False [-4.26 / 50.00]; BAYES_HAM(-2.96)[99.81%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; APPLE_IOS_MAILER_COMMON(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[] X-Spam-Status: No, score=-5.5 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: > Am 12.04.2024 um 09:50 schrieb Jakub Jelinek : >=20 > =EF=BB=BFHi! >=20 > The tree-cfg.cc verifier only diagnoses returns_twice calls preceded > by non-label/debug stmts if it is in a bb with abnormal predecessor. > The following testcase shows that if a user lies in the attributes > (a function which never returns can't be pure, and can't return > twice when it doesn't ever return at all), when we figure it out, > we can remove the abnormal edges to the "returns_twice" call and perhaps > whole .ABNORMAL_DISPATCHER etc. > edge_before_returns_twice_call then ICEs because it can't find such > an edge. >=20 > The following patch limits the special handling to calls in bbs where > the verifier requires that. >=20 > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Ok Richard=20 > 2024-04-12 Jakub Jelinek >=20 > PR sanitizer/114687 > * gimple-iterator.cc (gsi_safe_insert_before): Only use > edge_before_returns_twice_call if bb_has_abnormal_pred. > (gsi_safe_insert_seq_before): Likewise. > * gimple-lower-bitint.cc (bitint_large_huge::lower_call): Only > push to m_returns_twice_calls if bb_has_abnormal_pred. >=20 > * gcc.dg/asan/pr114687.c: New test. >=20 > --- gcc/gimple-iterator.cc.jj 2024-03-14 09:57:09.024966285 +0100 > +++ gcc/gimple-iterator.cc 2024-04-11 17:05:06.267081433 +0200 > @@ -1049,7 +1049,8 @@ gsi_safe_insert_before (gimple_stmt_iter > gimple *stmt =3D gsi_stmt (*iter); > if (stmt > && is_gimple_call (stmt) > - && (gimple_call_flags (stmt) & ECF_RETURNS_TWICE) !=3D 0) > + && (gimple_call_flags (stmt) & ECF_RETURNS_TWICE) !=3D 0 > + && bb_has_abnormal_pred (gsi_bb (*iter))) > { > edge e =3D edge_before_returns_twice_call (gsi_bb (*iter)); > basic_block new_bb =3D gsi_insert_on_edge_immediate (e, g); > @@ -1072,7 +1073,8 @@ gsi_safe_insert_seq_before (gimple_stmt_ > gimple *stmt =3D gsi_stmt (*iter); > if (stmt > && is_gimple_call (stmt) > - && (gimple_call_flags (stmt) & ECF_RETURNS_TWICE) !=3D 0) > + && (gimple_call_flags (stmt) & ECF_RETURNS_TWICE) !=3D 0 > + && bb_has_abnormal_pred (gsi_bb (*iter))) > { > edge e =3D edge_before_returns_twice_call (gsi_bb (*iter)); > gimple *f =3D gimple_seq_first_stmt (seq); > --- gcc/gimple-lower-bitint.cc.jj 2024-04-09 09:28:21.261123664 +0200 > +++ gcc/gimple-lower-bitint.cc 2024-04-11 17:06:58.033548199 +0200 > @@ -5320,7 +5320,7 @@ bitint_large_huge::lower_call (tree obj, > arg =3D make_ssa_name (TREE_TYPE (arg)); > gimple *g =3D gimple_build_assign (arg, v); > gsi_insert_before (&gsi, g, GSI_SAME_STMT); > - if (returns_twice) > + if (returns_twice && bb_has_abnormal_pred (gimple_bb (stmt))) > { > m_returns_twice_calls.safe_push (stmt); > returns_twice =3D false; > --- gcc/testsuite/gcc.dg/asan/pr114687.c.jj 2024-04-11 17:09:54.5181271= 65 +0200 > +++ gcc/testsuite/gcc.dg/asan/pr114687.c 2024-04-11 17:09:22.699563654 += 0200 > @@ -0,0 +1,22 @@ > +/* PR sanitizer/114687 */ > +/* { dg-do compile } */ > + > +int a; > +int foo (int); > + > +__attribute__((pure, returns_twice)) int > +bar (void) > +{ > + a =3D 1; > + while (a) > + a =3D 2; > + return a; > +} > + > +int > +baz (void) > +{ > + int d =3D bar (); > + foo (d); > + return 0; > +} >=20 > Jakub >=20