From patchwork Fri Mar 24 09:22:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 66838 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1ECFA385084B for ; Fri, 24 Mar 2023 09:24:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1ECFA385084B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679649862; bh=O/1xbcXVLWVg4T2UXUUV5ZTPJQ99ImCZ7NDJpv7CPjI=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=aD95q7R+0G+VgfQuEvNX75ippWYaZVO9s+9LuZ/mayItjeaJqD2qCxA0Y35iEZVa1 KAvg0DdnOg2P+yg6odp+axmWQhxJGJsrQCe7LTtilPyu5SCxW2RDB7ZWKSZGt9VXU0 Rb4A0BAvItNw+0Jx99iNv/HtgM6a9/89Kfz+rkhY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 276923858D28 for ; Fri, 24 Mar 2023 09:23:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 276923858D28 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-632-mtaziVJfMrCHe-fI9LUMLQ-1; Fri, 24 Mar 2023 05:23:52 -0400 X-MC-Unique: mtaziVJfMrCHe-fI9LUMLQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22F2E85A5B1; Fri, 24 Mar 2023 09:23:47 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4A9BE40CE2D4; Fri, 24 Mar 2023 09:23:40 +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 32O9N6WV3027072 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Mar 2023 10:23:30 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 32O9Mwm43027071; Fri, 24 Mar 2023 10:22:58 +0100 Date: Fri, 24 Mar 2023 10:22:58 +0100 To: Ian Lance Taylor Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] go: Fix up go.test/test/fixedbugs/bug207.go failure [PR109258] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.3 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! The PR109086 r13-6690 inline_string_cmp change to if (diff != result) emit_move_insn (result, diff); regressed FAIL: go.test/test/fixedbugs/bug207.go, -O2 -g (internal compiler error: in emit_move_insn, at expr.cc:4224) The problem is the Go FE doesn't mark __builtin_memcmp as pure as other FEs, so we ended up with __builtin_memcmp (whatever, whateverelse, somesize); in the IL before expansion and the expansion ICEd on it. As the builtin calls a library function which is pure or is inline expanded as such, not marking it pure is an unnecessary pessimization from the FE side, keeping such dead calls in the IL if they aren't needed will not help anything. The following patch fixes that. Initially I've added just DECL_PURE_P to it, but that unfortunately broke bootstrap, for __builtin_memcmp there is also __builtin_memcmp_eq registered by the middle-end code if not registered earlier and that one is registered with the usual flags (pure, nothrow, leaf), so if __builtin_memcmp from FE was just pure, it would appear in the IL as that it can raise exceptions and when folded into __builtin_memcmp_eq all of sudden it couldn't and we'd ICE in verification. I think tons of functions should have builtin_nothrow as well, but changing that wasn't necessary for this fix. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-03-24 Jakub Jelinek PR middle-end/109258 * go-gcc.cc (Gcc_backend): Add new static data members builtin_pure and builtin_nothrow. (Gcc_backend::Gcc_backend): Pass builtin_pure | builtin_nothrow for BUILT_IN_MEMCMP. (Gcc_backend::define_builtin): Handle builtin_pure and builtin_nothrow in flags. Jakub --- gcc/go/go-gcc.cc.jj 2023-01-18 12:22:10.396234744 +0100 +++ gcc/go/go-gcc.cc 2023-03-23 23:48:11.120064331 +0100 @@ -543,6 +543,8 @@ private: static const int builtin_const = 1 << 0; static const int builtin_noreturn = 1 << 1; static const int builtin_novops = 1 << 2; + static const int builtin_pure = 1 << 3; + static const int builtin_nothrow = 1 << 4; void define_builtin(built_in_function bcode, const char* name, const char* libname, @@ -601,7 +603,7 @@ Gcc_backend::Gcc_backend() const_ptr_type_node, size_type_node, NULL_TREE), - 0); + builtin_pure | builtin_nothrow); // We use __builtin_memmove for copying data. this->define_builtin(BUILT_IN_MEMMOVE, "__builtin_memmove", "memmove", @@ -3596,6 +3598,10 @@ Gcc_backend::define_builtin(built_in_fun libname, NULL_TREE); if ((flags & builtin_const) != 0) TREE_READONLY(decl) = 1; + if ((flags & builtin_pure) != 0) + DECL_PURE_P(decl) = 1; + if ((flags & builtin_nothrow) != 0) + TREE_NOTHROW (decl) = 1; if ((flags & builtin_noreturn) != 0) TREE_THIS_VOLATILE(decl) = 1; if ((flags & builtin_novops) != 0) @@ -3608,6 +3614,10 @@ Gcc_backend::define_builtin(built_in_fun NULL, NULL_TREE); if ((flags & builtin_const) != 0) TREE_READONLY(decl) = 1; + if ((flags & builtin_pure) != 0) + DECL_PURE_P(decl) = 1; + if ((flags & builtin_nothrow) != 0) + TREE_NOTHROW (decl) = 1; if ((flags & builtin_noreturn) != 0) TREE_THIS_VOLATILE(decl) = 1; if ((flags & builtin_novops) != 0)