From patchwork Wed Feb 22 11:25:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 60471 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp518693wrd; Wed, 22 Feb 2023 03:25:51 -0800 (PST) X-Google-Smtp-Source: AK7set9JYXKtN0dlNNu7f2StEeduqpPaLN77MPpY6zS3XMGXhm4xnNDr086YYF7tswTOBtG90zET X-Received: by 2002:a17:907:e92:b0:883:b1b4:e798 with SMTP id ho18-20020a1709070e9200b00883b1b4e798mr21192291ejc.10.1677065151456; Wed, 22 Feb 2023 03:25:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677065151; cv=none; d=google.com; s=arc-20160816; b=TwoBLhWu9fpzoar9NLS1fb/9Hi0Ja4X5PCw426jN2rY/6njn4eWb0qBKuK09rl+br3 4QhejhXBkGSsn0eunee+0h42pkMo8UiiZgGvXq1XCJ6Cjt/w616plTrG17N2zGbVowd1 xZQiqzl0fsdNVr6nltZ89OaEN5mgeCBDJfP67IW22OufQWOhhLxanOKEWvk2mPquTuTm SSEXxzeLJ+edVfSUCTgUoOdW3gFPCaOwma3ITmwu+vuaVBh/3EYgxQ1Gnjmrz43Ssi0v qxHLUZZ2oI3N2/nbh+fQAVZifSt5yhNjRXKEuehxKOyqE1EWJLDAYN+WQc5L3ST+GnoS c55g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:message-id:date :user-agent:references:in-reply-to:subject:cc:to:from:ironport-sdr :dmarc-filter:delivered-to; bh=QSlu30KYM4U9m21o2dDh5FfTjMlHbzJCQwTWArTM2XU=; b=GJM0GdMpK3LGp1g7lAqoxAm7I/8RGOLu9NyJvzKCFi3vjkaf8WCvRMum9yMX7xtPaS TUuC7JCr5K0rMP1OwM8EHHNdHko5EegY1JVMPRrFsGBuKWgY0Ylu5PKo7NtX5co4Oq6B s14N+zOAOb3QuXgOU3wWPhvBxXDeuhmvIbwyhZZC0W5YWS1LJZk0pHnc22vHEtMBpRUa gfA5Vc4ra/2bYAANbUYrWPMAD00pJiQlr53ZuQYB4ioY3xIjOlSvyFwLfoUiTpXEHoYz y/vyGrytI5d8rbutNdaKAL3xAY+45pK+RusOxjFOMPM8xyJR3EsQMqwphY8CibTX4YEQ qPIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id if8-20020a170906df4800b008d3be841cbbsi7932451ejc.442.2023.02.22.03.25.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 03:25:51 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DC9CD3858C83 for ; Wed, 22 Feb 2023 11:25:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 295A63858D33; Wed, 22 Feb 2023 11:25:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 295A63858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.97,318,1669104000"; d="scan'208,223";a="99104663" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 22 Feb 2023 03:25:08 -0800 IronPort-SDR: AGXM3nwCmf4aKuMGs3OZRYVqeMBqPV+gf0DMkSMW56jvR8uFoVLVtBPxr0UjPiOn7fv8HozQD+ erlxO7dN5Ip1nIvg2tOYRVjSkY4Q5LtOHo31UZxXGI+UtVZdMEWqS9t2YzVgSRpq0XGoXagv8B W3WQpJd0FXxPt8hHQN7e4niyPPodPupK+87OmLRqxhcPKT/eMY4Mt13QVvqok+pfBhroyoTOBC izxH+RFdZf0hsYS75NFiMCxDH9rd1x3CGadBlXfOJEFUc6KG/RiUXDSmtX70iyAkpTTDNHyMz8 Ycc= From: Thomas Schwinge To: Jan-Benedict Glaw , , "Richard Biener" CC: Gaius Mulley , , Subject: Rust: In 'type_for_mode' langhook also consider all 'int_n' modes/types (was: Modula-2 / Rust: Many targets failing) In-Reply-To: <20221219212344.ewtuzd2jtztm77x2@lug-owl.de> References: <20221219212344.ewtuzd2jtztm77x2@lug-owl.de> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/28.2 (x86_64-pc-linux-gnu) Date: Wed, 22 Feb 2023 12:25:01 +0100 Message-ID: <871qmi6iya.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, WEIRD_PORT 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: , 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?1758530267852379055?= X-GMAIL-MSGID: =?utf-8?q?1758530267852379055?= Hi! Richard, you may remember your words from "ICE: SIGSEGV in optab_for_tree_code (optabs.c:407) with -O -fno-tree-scev-cprop -ftree-vectorize": > Ideally we'd never use lang_hooks.types.type_for_mode (or _for_size) in the > middle-end but had a pure middle-end based implementation. Is there a canonical PR or other discussion thread for that? Here's another instance of this issue: On 2022-12-19T22:23:45+0100, Jan-Benedict Glaw wrote: > With the recent merges for Modula-2 and Rust, I see a good number of > targets failing with --enable-languages=all, mostly due to issues with > the Modula-2 driver. Thanks for reporting. > Modula-2 related issues > [snipped] > Rust related issues > ===================== > > --target=msp430-elfbare > ~~~~~~~~~~~~~~~~~~~~~~~~~ > /var/lib/laminar/run/gcc-msp430-elfbare/24/toolchain-build/./gcc/xgcc -B/var/lib/laminar/run/gcc-msp430-elfbare/24/toolchain-build/./gcc/ -xrust -frust-incomplete-and-experimental-compiler-do-not-use -nostdinc /dev/null -S -o /dev/null -fself-test=../../gcc/gcc/testsuite/selftests > : internal compiler error: Segmentation fault > 0xf2efbf crash_signal > ../../gcc/gcc/toplev.cc:314 > 0x120c8c7 build_function_type(tree_node*, tree_node*, bool) > ../../gcc/gcc/tree.cc:7360 > 0x120cc20 build_function_type_list(tree_node*, ...) > ../../gcc/gcc/tree.cc:7442 > 0x120d16b build_common_builtin_nodes() > ../../gcc/gcc/tree.cc:9883 > 0x8449b4 grs_langhook_init > ../../gcc/gcc/rust/rust-lang.cc:132 > 0x8427b2 lang_dependent_init > ../../gcc/gcc/toplev.cc:1815 > 0x8427b2 do_compile > ../../gcc/gcc/toplev.cc:2110 > Please submit a full bug report, with preprocessed source (by using -freport-bug). > Please include the complete backtrace with any bug report. > See for instructions. > make[1]: *** [../../gcc/gcc/rust/Make-lang.in:275: s-selftest-rust] Error 1 See also "Test failure on msp430-elfbare target". I confirm with both upstream GCC master branch and GCC/Rust master branch: $ ../source-gcc/configure --target=msp430-elfbare --enable-languages=rust [...] $ make all-gcc [...] [...] [...]/build-gcc/./gcc/xgcc -B[...]/build-gcc/./gcc/ -xc -nostdinc /dev/null -S -o /dev/null -fself-test=../../source-gcc/gcc/testsuite/selftests -fself-test: 57323 pass(es) in 0.420000 seconds echo timestamp > s-selftest-c [...]/build-gcc/./gcc/xgcc -B[...]/build-gcc/./gcc/ -xrust -frust-incomplete-and-experimental-compiler-do-not-use -nostdinc /dev/null -S -o /dev/null -fself-test=../../source-gcc/gcc/testsuite/selftests : internal compiler error: Segmentation fault 0xf51b9f crash_signal ../../source-gcc/gcc/toplev.cc:314 0x12e6a3a build_function_type(tree_node*, tree_node*, bool) ../../source-gcc/gcc/tree.cc:7447 0x12e6ee0 build_function_type_list(tree_node*, ...) ../../source-gcc/gcc/tree.cc:7529 0x12e748e build_common_builtin_nodes() ../../source-gcc/gcc/tree.cc:9977 0x7661c4 grs_langhook_init ../../source-gcc/gcc/rust/rust-lang.cc:128 0x762ac9 lang_dependent_init ../../source-gcc/gcc/toplev.cc:1815 0x762ac9 do_compile ../../source-gcc/gcc/toplev.cc:2110 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See for instructions. make[1]: *** [s-selftest-rust] Error 1 [...] OK to push the attached "Rust: In 'type_for_mode' langhook also consider all 'int_n' modes/types"? Grüße Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 From cae898bef63db18cc40b94ee4d48f85aec258c02 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 22 Feb 2023 11:42:43 +0100 Subject: [PATCH] Rust: In 'type_for_mode' langhook also consider all 'int_n' modes/types As reported in "Rust related issues" at the end of "Modula-2 / Rust: Many targets failing", "Test failure on msp430-elfbare target", for '--target=msp430-elfbar' we ICE: : internal compiler error: Segmentation fault 0xf2efbf crash_signal ../../gcc/gcc/toplev.cc:314 0x120c8c7 build_function_type(tree_node*, tree_node*, bool) ../../gcc/gcc/tree.cc:7360 0x120cc20 build_function_type_list(tree_node*, ...) ../../gcc/gcc/tree.cc:7442 0x120d16b build_common_builtin_nodes() ../../gcc/gcc/tree.cc:9883 0x8449b4 grs_langhook_init ../../gcc/gcc/rust/rust-lang.cc:132 [...] This is due to 'tmp == NULL' for 'gcc/tree.cc:build_common_builtin_nodes': tmp = lang_hooks.types.type_for_mode (targetm.eh_return_filter_mode (), 0); ..., were 'targetm.eh_return_filter_mode' (that is, 'gcc/targhooks.cc:default_eh_return_filter_mode', via calling 'targetm.unwind_word_mode': 'gcc/config/msp430/msp430.cc:msp430_unwind_word_mode') returns 'PSImode', and 'lang_hooks.types.type_for_mode' (that is, 'gcc/rust/rust-lang.cc:grs_langhook_type_for_mode') returns 'NULL' for 'PSImode'. As, for example, discussed in "ICE: SIGSEGV in optab_for_tree_code (optabs.c:407) with -O -fno-tree-scev-cprop -ftree-vectorize", we have to support "random" modes/types in the 'type_for_mode' langhook. gcc/rust/ * rust-lang.cc (grs_langhook_type_for_mode): Also consider all 'int_n' modes/types. --- gcc/rust/rust-lang.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gcc/rust/rust-lang.cc b/gcc/rust/rust-lang.cc index 75f6b4458d7..b4b86236ffc 100644 --- a/gcc/rust/rust-lang.cc +++ b/gcc/rust/rust-lang.cc @@ -235,6 +235,21 @@ grs_langhook_type_for_mode (machine_mode mode, int unsignedp) if (mode == TYPE_MODE (complex_integer_type_node) && !unsignedp) return complex_integer_type_node; } + + /* See (a) + "Test failure on msp430-elfbare target", and + (b) + "ICE: SIGSEGV in optab_for_tree_code (optabs.c:407) with -O -fno-tree-scev-cprop -ftree-vectorize" + -- we have to support "random" modes/types here. + TODO Clean all this up (either locally, or preferably per PR46805: + "Ideally we'd never use lang_hooks.types.type_for_mode (or _for_size) in the + middle-end but had a pure middle-end based implementation". */ + for (size_t i = 0; i < NUM_INT_N_ENTS; i ++) + if (int_n_enabled_p[i] + && mode == int_n_data[i].m) + return (unsignedp ? int_n_trees[i].unsigned_type + : int_n_trees[i].signed_type); + /* gcc_unreachable */ return NULL; } -- 2.25.1