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 548133858D28 for ; Wed, 12 Apr 2023 08:20:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 548133858D28 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=1681287627; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ud9URdpqyZUKpNfSEpOt22GaVaw1l0rDmHShf8Bl2WU=; b=Gfsu6nP7nvXJdwcyBKq1niM+d1XnqwNXvP669z4nWOap/+KlGrw9khttXRKY3eUsS5xPla bzop3SdD/pBHlzOdqd/aYnMJA0NdMz8i7o+FWXeVQHK+lz4oK4dRs3E/gmkoEM5CvkWOQB 7BYamVMio+asSh5YcAZaAEpEn/jUAnc= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-669-MJ9u8MW4MmixapJxtX5mOA-1; Wed, 12 Apr 2023 04:20:26 -0400 X-MC-Unique: MJ9u8MW4MmixapJxtX5mOA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3D9AA29AB3E7; Wed, 12 Apr 2023 08:20:26 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 029D92027043; Wed, 12 Apr 2023 08:20:25 +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 33C8KITZ1627632 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 12 Apr 2023 10:20:18 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 33C8KIa41627631; Wed, 12 Apr 2023 10:20:18 +0200 Date: Wed, 12 Apr 2023 10:20:17 +0200 From: Jakub Jelinek To: Andrew MacLeod Cc: gcc-patches , Richard Biener , "hernandez, aldy" Subject: Re: [PATCH] PR tree-optimization/109462 - Don't use ANY PHI equivalences in range-on-entry. Message-ID: Reply-To: Jakub Jelinek References: <951d67a7-5eb7-35e5-5e68-ddd6e3d05e3f@redhat.com> MIME-Version: 1.0 In-Reply-To: <951d67a7-5eb7-35e5-5e68-ddd6e3d05e3f@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.7 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: On Tue, Apr 11, 2023 at 07:52:29PM -0400, Andrew MacLeod wrote: > This bootstraps on x86_64-pc-linux-gnu  with that single regression, which I > have XFAILed for now.  OK for trunk? Yes. >   Once Jakub verifies it actually fixes > the execution problem.   we have no executable test . yet. I have verified this fix both on the original clang testcase, and on a self-contained testcase I've reduced overnight and this morning. Ok to commit it to trunk incrementally after your commit? BTW, I've wondered if it is just this uninitialized phi arg problem or if I could reproduce it also if the phi arg was initialized but had the same range as the current iteration is known to have due to a comparison (even when the actual value is from the previous loop's iteration). In the test below, that would be Result.c = r_paren; before while (!TheLexer.LexFromRawLexer (I)) loop. But it wasn't miscompiled in that case. 2023-04-12 Jakub Jelinek PR tree-optimization/109462 * g++.dg/opt/pr109462.C: New test. --- gcc/testsuite/g++.dg/opt/pr109462.C.jj 2023-04-12 09:58:23.085603031 +0200 +++ gcc/testsuite/g++.dg/opt/pr109462.C 2023-04-12 09:54:22.472079711 +0200 @@ -0,0 +1,94 @@ +// PR tree-optimization/109462 +// { dg-do run { target c++11 } } +// { dg-options "-O2" } + +struct A { + A (const char *); + A (const char *, int); + bool empty (); + int size (); + bool equals (A); + A trim (char); + A trim (); +}; +[[gnu::noipa]] A::A (const char *) {} +[[gnu::noipa]] A::A (const char *, int) { __builtin_abort (); } +[[gnu::noipa]] bool A::empty () { __builtin_abort (); } +[[gnu::noipa]] int A::size () { __builtin_abort (); } +[[gnu::noipa]] bool A::equals (A) { return true; } +[[gnu::noipa]] A A::trim (char) { __builtin_abort (); } +[[gnu::noipa]] A A::trim () { __builtin_abort (); } + +enum B { raw_identifier = 6, l_paren = 21, r_paren = 22 }; +[[gnu::noipa]] bool isAnyIdentifier (B) { return true; } +[[gnu::noipa]] bool isStringLiteral (B) { __builtin_abort (); } + +struct C { + B c; + B getKind () { return c; } + bool is (B x) { return c == x; } + unsigned getLength () { __builtin_abort (); } + A getRawIdentifier () { + A x (""); + c == raw_identifier ? void () : __builtin_abort (); + return x; + } + const char *getLiteralData (); +}; +[[gnu::noipa]] const char *C::getLiteralData () { __builtin_abort (); } + +struct D { + D (); + bool LexFromRawLexer (C &); +}; +[[gnu::noipa]] D::D () {} +[[gnu::noipa]] bool D::LexFromRawLexer (C &t) { + static int cnt; + C tok[] = { { raw_identifier }, { l_paren }, { raw_identifier }, { r_paren } }; + t = tok[cnt++]; + return false; +} + +bool ok = false; +[[gnu::noipa]] void reportEmptyContextError () +{ + ok = true; +} + +[[gnu::noipa]] void +VisitObjCMessageExpr () +{ + D TheLexer; + C I; + C Result; + int p_count = 0; + while (!TheLexer.LexFromRawLexer (I)) { + if (I.getKind () == l_paren) + ++p_count; + if (I.getKind () == r_paren) { + if (p_count == 1) + break; + --p_count; + } + Result = I; + } + if (isAnyIdentifier (Result.getKind ())) { + if (Result.getRawIdentifier ().equals ("nil")) { + reportEmptyContextError (); + return; + } + } + if (!isStringLiteral (Result.getKind ())) + return; + A Comment = A (Result.getLiteralData (), Result.getLength ()).trim ('"'); + if ((Comment.trim ().size () == 0 && Comment.size () > 0) || Comment.empty ()) + reportEmptyContextError (); +} + +int +main () +{ + VisitObjCMessageExpr (); + if (!ok) + __builtin_abort (); +} Jakub