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: 74445 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp486177vqo; Fri, 24 Mar 2023 02:24:38 -0700 (PDT) X-Google-Smtp-Source: AK7set+pX0NBf05ZRC1tSmVjUh1hI0PGe6t5ZSIsthX1oN74AfrRsqT5tcY/46WgolHBNAOpzRrZ X-Received: by 2002:a05:6402:944:b0:4ad:f811:e267 with SMTP id h4-20020a056402094400b004adf811e267mr8488497edz.12.1679649878618; Fri, 24 Mar 2023 02:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679649878; cv=none; d=google.com; s=arc-20160816; b=UJqlGLs8jOlZhkl/XRafPxskrPcAUtmRkRJcSsXID8SmOirWAUrPBR9q6PYZULQ8Zk 7wwLN2BrIcf/LuO9f0nyJDTZ7ZaYhJ+mozBdBxkTFk0c48m1DNj2WQ8tnzH1gZncr4RO HKtOCs1rogoVk695ShiIewB8rZCoxBMox3eEoP1mVkGUV0dns82EC6WMoJF0FpcETBPA IBR3nXOs0BmWDk/qT59yRtxyb15c801Q48KK/8Tzc4yV0X6wwjgBLC2nNyIrrpVqNXnS BC9MINjA5M69YWcHpLf0wbWVUl7PSR2lMXeYau/VoGYenEtPUyNad+LS4gTppLomJzjA 6cTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=O/1xbcXVLWVg4T2UXUUV5ZTPJQ99ImCZ7NDJpv7CPjI=; b=lU0evcET0t/5JiAXWyxcveFiMr4e4iZcwFWQ7CMLWPQyga7NoX6BalsZF8VFeLS6Iv 2l5kmPc+OX8wxdqMZ15z3VziSoGT1uXJeUOfloUileStU9KVp9sTswzzdyk3PJ7DCfpt 44qQ+xNxL2/e6VR+UaukvxTdJkGx1krkWX44iKb5NOiazxjlXwUyMwivCrNjdali/C+O RujH71zujWsHG3Zhhaq9nlo081bp2ZMGi/qCVwoevBWstK7ojiYQ2uDLs3Yh8Ah1x2i4 XbWBlhn6aGSqbkLttgbRL1OnMKfu3zgM2vnxnMwQimcTGCJ/aQWX5rnNTmVp58hi2Kb+ HSEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Fu6b3Xzo; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id i5-20020a50fc05000000b004fcd1adbb05si19018666edr.210.2023.03.24.02.24.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 02:24:38 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Fu6b3Xzo; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 45261384F00E for ; Fri, 24 Mar 2023 09:24:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45261384F00E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679649877; 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=Fu6b3Xzot7mt/KDZEzFefAdieZan+tdOjwY6knT4604opbhyiAeBIydv1DRFQTjJ1 PbcHrCFJBkI4RDuO/wFy9sar3gweOpQwubyl6dlG9baSEAcva/Y5GWEGwiNmlvvL6H ukVSlbrJD7CwF4xna9/29yC+YBsPoj5vFT8PYIaM= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761240551543473899?= X-GMAIL-MSGID: =?utf-8?q?1761240551543473899?= 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)