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 0626C3858CDA for ; Tue, 9 Apr 2024 07:40:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0626C3858CDA 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 0626C3858CDA 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=1712648409; cv=none; b=YLksUk+vNOY7MV3W1VMW1waBIzkFLzJ8EPw2poCaGKoot+IaBQRoqP8PR1P2fsHjz40zel7JLQeAoPc/Ucs5QbXTZaqJjPif36HOFiqV57zy0oZwpqEP3EShv+xFuMkzjHWHzgb1q//Ya7hicYy479AF2KQcd53qL6O1GexuCtM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712648409; c=relaxed/simple; bh=QGJRyjt4+t1eQSnmjWSnTY33smsi0V7asxTh7LrgsIY=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:Message-ID:MIME-Version; b=J6A3neRgNVIYevv3d+x0ja7uzNePR7T78VD1kV+KKCQYoK11OP0riKZjFbpxkDlYyncnwuqkigXOelPFaMmpGvoTJ9mClrmJO0s1soapQ5O27zhPyftPQJe0PjFpF/cH886pcO9OsxGd1XJxCG9U1/2thqEG9/UcbKxD8BecE/A= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.5.241] (unknown [10.168.5.241]) (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 EDFF72085D; Tue, 9 Apr 2024 07:40:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712648406; 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=YuGUgJsIhJ1OWB2Q/W3S/rBjmzLIP2dtwuo2syoVD/A=; b=GqFzedXLsE1wp7uJb8VKzavFdinYA9nKOh5zBGkyQULSxYdTcwR8egXRvd+ZgGxphD9vmx VLajhE5SNLYd6yrKwLOyjq0hNw6FqhA/jCrRycgDyb8CKIlW09mVp5DnuVu1urIilBof0r K82MjvP2twNnNeuzG1/7nIX2ogqHJa0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712648406; 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=YuGUgJsIhJ1OWB2Q/W3S/rBjmzLIP2dtwuo2syoVD/A=; b=HwdpkWiVRVpTqKjgnrF8eLYgd3KXDOaRp4vWhAcMD+MYdAg0ssvrHxgn9mlaSPL6t6744B 0APACCsKmc0xdrAw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712648406; 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=YuGUgJsIhJ1OWB2Q/W3S/rBjmzLIP2dtwuo2syoVD/A=; b=GqFzedXLsE1wp7uJb8VKzavFdinYA9nKOh5zBGkyQULSxYdTcwR8egXRvd+ZgGxphD9vmx VLajhE5SNLYd6yrKwLOyjq0hNw6FqhA/jCrRycgDyb8CKIlW09mVp5DnuVu1urIilBof0r K82MjvP2twNnNeuzG1/7nIX2ogqHJa0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712648406; 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=YuGUgJsIhJ1OWB2Q/W3S/rBjmzLIP2dtwuo2syoVD/A=; b=HwdpkWiVRVpTqKjgnrF8eLYgd3KXDOaRp4vWhAcMD+MYdAg0ssvrHxgn9mlaSPL6t6744B 0APACCsKmc0xdrAw== Date: Tue, 9 Apr 2024 09:40:05 +0200 (CEST) From: Richard Biener To: =?ISO-8859-15?Q?J=F8rgen_Kvalsvik?= cc: gcc-patches@gcc.gnu.org, hjl.tools@gmail.com, hubicka@ucw.cz, sam@gentoo.org Subject: Re: [PATCH 1/2] Add tree-inlined gconds to caller cond->expr map In-Reply-To: <20240408141815.127984-2-j@lambda.is> Message-ID: <3o96q131-p830-n76s-9913-3sn3oo176343@fhfr.qr> References: <20240408141815.127984-1-j@lambda.is> <20240408141815.127984-2-j@lambda.is> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323328-1333761927-1712648406=:8691" X-Spam-Score: -1.80 X-Spam-Level: X-Spamd-Result: default: False [-1.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; CTYPE_MIXED_BOGUS(1.00)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[multipart/mixed,text/plain]; MIME_TRACE(0.00)[0:+,1:+]; ARC_NA(0.00)[]; MISSING_XM_UA(0.00)[]; TAGGED_RCPT(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[gcc.gnu.org,gmail.com,ucw.cz,gentoo.org]; RCPT_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email] X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-1333761927-1712648406=:8691 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8BIT On Mon, 8 Apr 2024, Jørgen Kvalsvik wrote: > Properly add the condition -> expression mapping of inlined gconds from > the caller into the callee map. This is a fix for PR114599 that works > beyond fixing the segfault, as the previous fixed copied references to > the source gconds, not the deep copied ones that end up in the calle > body. > > The new tests checks this, both in the case of a calle without > conditions (which triggered the segfault), and a test that shows that > conditions are properly mapped, and not mixed. OK. Thanks, Richard. > PR middle-end/114599 > > gcc/ChangeLog: > > * tree-inline.cc (copy_bb): Copy cond_uids into callee. > (prepend_lexical_block): Remove outdated comment. > (add_local_variables): Remove bad cond_uids copy. > > gcc/testsuite/ChangeLog: > > * gcc.misc-tests/gcov-19.c: New test. > --- > gcc/testsuite/gcc.misc-tests/gcov-19.c | 37 ++++++++++++++++++++++ > gcc/tree-inline.cc | 43 ++++++++++++++------------ > 2 files changed, 61 insertions(+), 19 deletions(-) > > diff --git a/gcc/testsuite/gcc.misc-tests/gcov-19.c b/gcc/testsuite/gcc.misc-tests/gcov-19.c > index b83a38531ba..78769fa57b8 100644 > --- a/gcc/testsuite/gcc.misc-tests/gcov-19.c > +++ b/gcc/testsuite/gcc.misc-tests/gcov-19.c > @@ -1468,6 +1468,40 @@ mcdc026e (int a, int b, int c, int d, int e) > return x + y; > } > > +__attribute__((always_inline)) > +inline int > +mcdc027_inlined (int a) > +{ > + if (a) > + x = a; > + else > + x = 1; > + > + return a + 1; > +} > + > +/* Check that conditions in a function inlined into a function without > + conditionals works. */ > +void > +mcdc027a (int a) /* conditions(1/2) false(0) */ > + /* conditions(end) */ > +{ > + mcdc027_inlined (a); > +} > + > +/* Check that conditions in a function inlined into a function with > + conditionals works and that the conditions are not mixed up. */ > +void > +mcdc027b (int a) /* conditions(1/2) false(0) */ > + /* conditions(end) */ > +{ > + int v = mcdc027_inlined (a); > + > + if (v > 10) /* conditions(1/2) true(0) */ > + /* condiitions(end) */ > + x = 10; > +} > + > int main () > { > mcdc001a (0, 1); > @@ -1721,6 +1755,9 @@ int main () > mcdc026e (1, 1, 1, 0, 1); > mcdc026e (1, 1, 0, 0, 1); > mcdc026e (1, 1, 1, 1, 1); > + > + mcdc027a (1); > + mcdc027b (1); > } > > /* { dg-final { run-gcov conditions { --conditions gcov-19.c } } } */ > diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc > index b18917707cc..5f852885e7f 100644 > --- a/gcc/tree-inline.cc > +++ b/gcc/tree-inline.cc > @@ -2049,6 +2049,17 @@ copy_bb (copy_body_data *id, basic_block bb, > > copy_gsi = gsi_start_bb (copy_basic_block); > > + unsigned min_cond_uid = 0; > + if (id->src_cfun->cond_uids) > + { > + if (!cfun->cond_uids) > + cfun->cond_uids = new hash_map (); > + > + for (auto itr : *id->src_cfun->cond_uids) > + if (itr.second >= min_cond_uid) > + min_cond_uid = itr.second + 1; > + } > + > for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) > { > gimple_seq stmts; > @@ -2076,6 +2087,18 @@ copy_bb (copy_body_data *id, basic_block bb, > if (gimple_nop_p (stmt)) > continue; > > + /* If -fcondition-coverage is used, register the inlined conditions > + in the cond->expression mapping of the caller. The expression tag > + is shifted conditions from the two bodies are not mixed. */ > + if (id->src_cfun->cond_uids && is_a (orig_stmt)) > + { > + gcond *orig_cond = as_a (orig_stmt); > + gcond *cond = as_a (stmt); > + unsigned *v = id->src_cfun->cond_uids->get (orig_cond); > + if (v) > + cfun->cond_uids->put (cond, *v + min_cond_uid); > + } > + > gimple_duplicate_stmt_histograms (cfun, stmt, id->src_cfun, > orig_stmt); > > @@ -4659,8 +4682,7 @@ prepend_lexical_block (tree current_block, tree new_block) > BLOCK_SUPERCONTEXT (new_block) = current_block; > } > > -/* Add local variables from CALLEE to CALLER. If set for condition coverage, > - copy basic condition -> expression mapping to CALLER. */ > +/* Add local variables from CALLEE to CALLER. */ > > static inline void > add_local_variables (struct function *callee, struct function *caller, > @@ -4690,23 +4712,6 @@ add_local_variables (struct function *callee, struct function *caller, > } > add_local_decl (caller, new_var); > } > - > - /* If -fcondition-coverage is used and the caller has conditions, copy the > - mapping into the caller but and the end so the caller and callee > - expressions aren't mixed. */ > - if (callee->cond_uids) > - { > - if (!caller->cond_uids) > - caller->cond_uids = new hash_map (); > - > - unsigned dst_max_uid = 0; > - for (auto itr : *callee->cond_uids) > - if (itr.second >= dst_max_uid) > - dst_max_uid = itr.second + 1; > - > - for (auto itr : *callee->cond_uids) > - caller->cond_uids->put (itr.first, itr.second + dst_max_uid); > - } > } > > /* Add to BINDINGS a debug stmt resetting SRCVAR if inlining might > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg) --8323328-1333761927-1712648406=:8691--