From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 94F453858282 for ; Fri, 17 May 2024 08:11:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 94F453858282 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 94F453858282 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715933488; cv=none; b=OS1bYeYwASNMmer7oLHwd3Cb8VBxvPgTdMgxVh4oSyN83rCUeqL/wZYeQAI9d2PQ7XcB+mI4BaXBZM8PnwHBobmW4+oEGDvhKMAJ3T4G/qQyZWe3FG0AAtyK0jyFO5etcifqGATSqvTT9f20Ke//HRVlG4FK0MWVYxAKrWx9YJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715933488; c=relaxed/simple; bh=wY/7DRF/F41BjOHYkRzytpp282XjQ4AiMoQ/U/6TiTI=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version:Message-Id; b=F1HzAZ7Pd0AOCBoVIYUhLcIcGi41NpEWLiQWVGIZ+vWFJyYQB/7n95oXpQCsu6OroHnst3kNQFeULYCEy+zYnVlGFkj8lpCJumvesrUGZvIg0a++m//zb3fI+4KiC3MiOt8u9xNCXMCgCk4EJ45gcHAVXvJk6wcAcYmpMAu0LxM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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 650F35D136 for ; Fri, 17 May 2024 08:11:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715933472; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=pemzReZ9GZVwCYC6XHv97IvGe2npvyClUWQmv8rjp0I=; b=LPYN5j9+GOfCInbPm0epPlrwnA3OFZUQeAjiIl7P2BglSp0ZA9F6KV6ffp4ce2a2jtCia5 EwH/O71DCgDsjZ7KQUcf51Qaj2a3crxSYCab9HCOYjJTl9LHzxUFQvUeolsAjJmmovfRYE jda5vhefNIQH0heGG9nXFkitMZz11LM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715933472; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=pemzReZ9GZVwCYC6XHv97IvGe2npvyClUWQmv8rjp0I=; b=TxJsArq3k2p2Bs2hczaCvic7bot3A+uYdRRS73nLV3PbbOf5RwZ8w9XM1bFo/eO+m2PSZ1 vsDKzLACUkD1FRCg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=LPYN5j9+; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=TxJsArq3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1715933472; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=pemzReZ9GZVwCYC6XHv97IvGe2npvyClUWQmv8rjp0I=; b=LPYN5j9+GOfCInbPm0epPlrwnA3OFZUQeAjiIl7P2BglSp0ZA9F6KV6ffp4ce2a2jtCia5 EwH/O71DCgDsjZ7KQUcf51Qaj2a3crxSYCab9HCOYjJTl9LHzxUFQvUeolsAjJmmovfRYE jda5vhefNIQH0heGG9nXFkitMZz11LM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1715933472; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=pemzReZ9GZVwCYC6XHv97IvGe2npvyClUWQmv8rjp0I=; b=TxJsArq3k2p2Bs2hczaCvic7bot3A+uYdRRS73nLV3PbbOf5RwZ8w9XM1bFo/eO+m2PSZ1 vsDKzLACUkD1FRCg== 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 4C64413942 for ; Fri, 17 May 2024 08:11:12 +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 ehNUDyARR2YeLwAAD6G6ig (envelope-from ) for ; Fri, 17 May 2024 08:11:12 +0000 Date: Fri, 17 May 2024 10:11:11 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Add missing check for const_pool in the escaped solutions MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20240517081112.4C64413942@imap1.dmz-prg2.suse.org> X-Spam-Score: -5.51 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 650F35D136 X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-5.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; DWL_DNSWL_LOW(-1.00)[suse.de:dkim]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; PREVIOUSLY_DELIVERED(0.00)[gcc-patches@gcc.gnu.org]; MISSING_XM_UA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Spam-Status: No, score=-11.6 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: The ptr-vs-ptr compare folding using points-to info was missing a check for const_pool being included in the escaped solution. The following fixes that, fixing the observed execute FAIL of experimental/functional/searchers.cc Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. * tree-ssa-alias.h (pt_solution_includes_const_pool): Declare. * tree-ssa-alias.cc (ptrs_compare_unequal): Use pt_solution_includes_const_pool. * tree-ssa-structalias.cc (pt_solution_includes_const_pool): New. * gcc.dg/torture/20240517-1.c: New testcase. --- gcc/testsuite/gcc.dg/torture/20240517-1.c | 26 +++++++++++++++++++++++ gcc/tree-ssa-alias.cc | 3 ++- gcc/tree-ssa-alias.h | 1 + gcc/tree-ssa-structalias.cc | 11 ++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/20240517-1.c diff --git a/gcc/testsuite/gcc.dg/torture/20240517-1.c b/gcc/testsuite/gcc.dg/torture/20240517-1.c new file mode 100644 index 00000000000..ab83d3ca6fb --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/20240517-1.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ +/* { dg-additional-options "-fmerge-all-constants" } */ + +char *p; + +char * __attribute__((noipa)) +foo () { return p+1; } + +volatile int z; + +int main() +{ + /* ESCAPED = CONST_POOL */ + p = "Hello"; + /* PT = ESCAPED */ + char *x = foo (); + char *y; + /* y PT = CONST_POOL */ + if (z) + y = "Baz"; + else + y = "Hello" + 1; + if (y != x) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc index 6d31fc83691..9f5f69bcfad 100644 --- a/gcc/tree-ssa-alias.cc +++ b/gcc/tree-ssa-alias.cc @@ -501,7 +501,8 @@ ptrs_compare_unequal (tree ptr1, tree ptr2) || pi2->pt.vars_contains_interposable) return false; if ((!pi1->pt.null || !pi2->pt.null) - && (!pi1->pt.const_pool || !pi2->pt.const_pool)) + && (!pt_solution_includes_const_pool (&pi1->pt) + || !pt_solution_includes_const_pool (&pi2->pt))) return !pt_solutions_intersect (&pi1->pt, &pi2->pt); } } diff --git a/gcc/tree-ssa-alias.h b/gcc/tree-ssa-alias.h index e29dff58375..5cd64e72295 100644 --- a/gcc/tree-ssa-alias.h +++ b/gcc/tree-ssa-alias.h @@ -178,6 +178,7 @@ extern bool pt_solution_empty_p (const pt_solution *); extern bool pt_solution_singleton_or_null_p (struct pt_solution *, unsigned *); extern bool pt_solution_includes_global (struct pt_solution *, bool); extern bool pt_solution_includes (struct pt_solution *, const_tree); +extern bool pt_solution_includes_const_pool (struct pt_solution *); extern bool pt_solutions_intersect (struct pt_solution *, struct pt_solution *); extern void pt_solution_reset (struct pt_solution *); extern void pt_solution_set (struct pt_solution *, bitmap, bool); diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc index 0c6085b1766..61fb3610a17 100644 --- a/gcc/tree-ssa-structalias.cc +++ b/gcc/tree-ssa-structalias.cc @@ -7080,6 +7080,17 @@ pt_solution_includes (struct pt_solution *pt, const_tree decl) return res; } +/* Return true if the points-to solution *PT contains a reference to a + constant pool entry. */ + +bool +pt_solution_includes_const_pool (struct pt_solution *pt) +{ + return (pt->const_pool + || (pt->escaped && (!cfun || cfun->gimple_df->escaped.const_pool)) + || (pt->ipa_escaped && ipa_escaped_pt.const_pool)); +} + /* Return true if both points-to solutions PT1 and PT2 have a non-empty intersection. */ -- 2.35.3