From patchwork Sat Oct 28 22:41:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 159306 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1426727vqb; Sat, 28 Oct 2023 15:42:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFs+jmacYANWVHlUlIBitwsUqXS1oyL16HPXO3FQXcnz7sC3AGM1MsHFaszUhXgJK3h2/84 X-Received: by 2002:a05:622a:5c9:b0:418:1179:9195 with SMTP id d9-20020a05622a05c900b0041811799195mr7333008qtb.66.1698532931400; Sat, 28 Oct 2023 15:42:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698532931; cv=pass; d=google.com; s=arc-20160816; b=Yuxsr0iE5XbBUOcHw4Q6oKmXedinQOwjbMT1yvGNJJxQCYv/y84LZ3S1jLhbCen3eJ Ff9U6FQzajYp9ac+ARiizgdNQxgPnATYgl3iItjyIubMKSlPKcU7F61Ql8K4iRh0Urkb Ge6XcTN4YkSAfAVxEBCYLD6LkVEfCmNBDaC0W9ONmqh30OM9zv0HZT6BlsyQUMkTDpkU KDRPOsT8uIWbZPW8Bay+3oeIZL7Op3TppvEjB9ExAHosdzRDrgP+RhWlUGxKZc2v6q5a 6tkg2ltJBZ69BzOdCdZVc9jU6uIQj/iKCPDeCA8Rp04ZaNK4V97vdpIJxVhN05EC7i0Z sq1w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=BadZZSfmn7HiAbcHUAW7RhKwWyZH6wLT3oWTcdtNZt0=; fh=D2tRalIjW6KCgVuqwFHStdMb9uqe8HSQc2WEvRJ6uLE=; b=lHKg04apReNdF/amj5xXDafD/jbuPVL3QzOZQHOJ1ISmO1mr2iegS+UzL2HIgZJe4I PjLI5TtljrbgCW+/oEllM1OE9eKrV4AswsPZ3J2+dpiSu1OFPtLVp8gngr0k6sPv69Lk zCH1XV2XmAtYP50jU/seMx/p/qR8kiqt3+0aA3G7KnPKAXqsLdICuu3ILjeNSWrHnBmH g0tYvBa0BzkIvBKtpgBmVM5sTc/E/LLAW+KwCdJ1zIBCwezwcJPx0H/w6l9BoGtlqfP3 9L5RrNhdc+8EZV4d0nq2MJOJZstYqKhOQfIz9qGCMGuzVZJfIMug1oqOG75mcy+yz57X Q3cw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gdcproject.org header.s=MBO0001 header.b=IdrAw+OJ; arc=pass (i=1); 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"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gdcproject.org Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id u41-20020a05622a19a900b00410a249beecsi3161721qtc.277.2023.10.28.15.42.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 15:42:11 -0700 (PDT) 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; dkim=pass header.i=@gdcproject.org header.s=MBO0001 header.b=IdrAw+OJ; arc=pass (i=1); 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"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=gdcproject.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2EAA638618A6 for ; Sat, 28 Oct 2023 22:42:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050:0:465::101]) by sourceware.org (Postfix) with ESMTPS id 18A3F3857C66 for ; Sat, 28 Oct 2023 22:41:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 18A3F3857C66 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=gdcproject.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gdcproject.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 18A3F3857C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:67c:2050:0:465::101 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698532909; cv=none; b=W2YuwsB6DZzdwZx1EqnEHPGk8i0nJhPyGFeWT8CABps4UiN61K4uHDUDzdc9xfDQK+ePxsuetJQMKbMm0+Y9HB/8WgMGyVofiFeAs3hx7VhxOnZIrx87HSxmWF5pHhlWt42vVh9m3oJcoKWZa2WWGN4c7k3fHPBqJcXi/XRyWnI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698532909; c=relaxed/simple; bh=YPb8thpXJQWgWcQGCz0Cw8G5TlX0nmJDlZLdPIc9srQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=jixkdhNzo5P/ZKYNXOjVU6S2mUA1R+UeqjgXmWPF5L8vRGU50IIUepnnlbUiFwGFx1iANO1wMoz3x3xxcSUGgV2l7en/mAP1ubQJBG3ThM1vzWF9rqhRRB0Og/Bt0vpU7X4dTBa/qZfhSuGbSYNB0Krq+aFklHv956G+rQ+jrL4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.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 mout-p-101.mailbox.org (Postfix) with ESMTPS id 4SHvfJ1CSNz9sRX; Sun, 29 Oct 2023 00:41:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gdcproject.org; s=MBO0001; t=1698532904; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=BadZZSfmn7HiAbcHUAW7RhKwWyZH6wLT3oWTcdtNZt0=; b=IdrAw+OJmHeNr7stK7XbhDK1eHDZOXlcF0eTEJBjPM6E7W38MrUtOeoIJFYNQBe73JVdUP vdfuyq8m0bDbvd5w7yb7p93aZ+hzFGioS0WRjdljEBVBGKujtY4g5a77jE5eOzrGDm8qej ysmVDsWKxgVUu5ixapE6XM+v6wjwh4mki7ND+JPGLEkqNzD8hAx7k8z4CUikD2makG9GAL pfdXK7QO5HpTkKnKW6TQEYxD81cGBdoy6m7ZDJQ8sTZqU5JOT7UrTJ1ivAex/KA6I/HOR8 3KUnjjKbLcbgD90M/7S+ZXBFP4B3hQmYdxx7WLvCwzzRqjlCSCwsWmlZQy6l+A== From: Iain Buclaw To: gcc-patches@gcc.gnu.org Cc: Iain Buclaw Subject: [committed] d: Fix ICE: in verify_gimple_in_seq on powerpc-darwin9 [PR112270] Date: Sun, 29 Oct 2023 00:41:40 +0200 Message-Id: <20231028224140.172969-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781040867204097305 X-GMAIL-MSGID: 1781040867204097305 Hi, This patch fixes an ICE seen during stage2 on powerpc-darwin9 only. There were still some uses of GCC's boolean_type_node in the D front-end, which caused a type mismatch to trigger as D bool size is fixed to 1 byte on all targets. So two new nodes have been introduced - d_bool_false_node and d_bool_true_node - which have replaced all remaining uses of boolean_false_node and boolean_true_node respectively. Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed to mainline, and backported to gcc-12 and gcc-13. Regards, Iain. --- PR d/112270 gcc/d/ChangeLog: * d-builtins.cc (d_build_d_type_nodes): Initialize d_bool_false_node, d_bool_true_node. * d-codegen.cc (build_array_struct_comparison): Use d_bool_false_node instead of boolean_false_node. * d-convert.cc (d_truthvalue_conversion): Use d_bool_false_node and d_bool_true_node instead of boolean_false_node and boolean_true_node. * d-tree.h (enum d_tree_index): Add DTI_BOOL_FALSE and DTI_BOOL_TRUE. (d_bool_false_node): New macro. (d_bool_true_node): New macro. * modules.cc (build_dso_cdtor_fn): Use d_bool_false_node and d_bool_true_node instead of boolean_false_node and boolean_true_node. (register_moduleinfo): Use d_bool_type instead of boolean_type_node. gcc/testsuite/ChangeLog: * gdc.dg/pr112270.d: New test. --- gcc/d/d-builtins.cc | 3 +++ gcc/d/d-codegen.cc | 2 +- gcc/d/d-convert.cc | 10 +++++----- gcc/d/d-tree.h | 6 ++++++ gcc/d/modules.cc | 4 ++-- gcc/testsuite/gdc.dg/pr112270.d | 7 +++++++ 6 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/gdc.dg/pr112270.d diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc index cf998d22721..f6ea026bdcf 100644 --- a/gcc/d/d-builtins.cc +++ b/gcc/d/d-builtins.cc @@ -956,6 +956,9 @@ d_build_d_type_nodes (void) d_bool_type = make_unsigned_type (1); TREE_SET_CODE (d_bool_type, BOOLEAN_TYPE); + d_bool_false_node = TYPE_MIN_VALUE (d_bool_type); + d_bool_true_node = TYPE_MAX_VALUE (d_bool_type); + char8_type_node = make_unsigned_type (8); TYPE_STRING_FLAG (char8_type_node) = 1; diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc index 91ddb1b657e..270cb5e2be6 100644 --- a/gcc/d/d-codegen.cc +++ b/gcc/d/d-codegen.cc @@ -1115,7 +1115,7 @@ build_array_struct_comparison (tree_code code, StructDeclaration *sd, if (length == 0 || result OP 0) break; */ t = build_boolop (EQ_EXPR, length, d_convert (lentype, integer_zero_node)); t = build_boolop (TRUTH_ORIF_EXPR, t, build_boolop (code, result, - boolean_false_node)); + d_bool_false_node)); t = build1 (EXIT_EXPR, void_type_node, t); add_stmt (t); diff --git a/gcc/d/d-convert.cc b/gcc/d/d-convert.cc index 2b9d8e78fb6..71d7a41374e 100644 --- a/gcc/d/d-convert.cc +++ b/gcc/d/d-convert.cc @@ -132,13 +132,13 @@ d_truthvalue_conversion (tree expr) return expr; case INTEGER_CST: - return integer_zerop (expr) ? boolean_false_node - : boolean_true_node; + return integer_zerop (expr) ? d_bool_false_node + : d_bool_true_node; case REAL_CST: return real_compare (NE_EXPR, &TREE_REAL_CST (expr), &dconst0) - ? boolean_true_node - : boolean_false_node; + ? d_bool_true_node + : d_bool_false_node; case ADDR_EXPR: /* If we are taking the address of a decl that can never be null, @@ -148,7 +148,7 @@ d_truthvalue_conversion (tree expr) warning (OPT_Waddress, "the address of %qD will always evaluate as %", TREE_OPERAND (expr, 0)); - return boolean_true_node; + return d_bool_true_node; } break; diff --git a/gcc/d/d-tree.h b/gcc/d/d-tree.h index ed26533feb4..7763695a106 100644 --- a/gcc/d/d-tree.h +++ b/gcc/d/d-tree.h @@ -444,6 +444,9 @@ enum d_tree_index DTI_NULL_ARRAY, DTI_BOTTOM_TYPE, + DTI_BOOL_FALSE, + DTI_BOOL_TRUE, + DTI_MAX }; @@ -480,6 +483,9 @@ extern GTY(()) tree d_global_trees[DTI_MAX]; #define null_array_node d_global_trees[DTI_NULL_ARRAY] /* The bottom type, referred to as `noreturn` in code. */ #define noreturn_type_node d_global_trees[DTI_BOTTOM_TYPE] +/* D boolean values are always byte-sized, unlike boolean_type_node. */ +#define d_bool_false_node d_global_trees[DTI_BOOL_FALSE] +#define d_bool_true_node d_global_trees[DTI_BOOL_TRUE] /* A prefix for internal variables, which are not user-visible. */ #if !defined (NO_DOT_IN_LABEL) diff --git a/gcc/d/modules.cc b/gcc/d/modules.cc index 8d6c8f0f9ad..e3c1ef9f82e 100644 --- a/gcc/d/modules.cc +++ b/gcc/d/modules.cc @@ -330,7 +330,7 @@ static tree build_dso_cdtor_fn (bool ctor_p) { const char *name = ctor_p ? GDC_PREFIX ("dso_ctor") : GDC_PREFIX ("dso_dtor"); - tree condition = ctor_p ? boolean_true_node : boolean_false_node; + tree condition = ctor_p ? d_bool_true_node : d_bool_false_node; /* Declaration of dso_ctor/dso_dtor is: @@ -453,7 +453,7 @@ register_moduleinfo (Module *decl, tree minfo) d_finish_decl (dso_slot_node); dso_initialized_node = build_dso_registry_var (GDC_PREFIX ("dso_initialized"), - boolean_type_node); + d_bool_type); d_finish_decl (dso_initialized_node); /* Declare dso_ctor() and dso_dtor(). */ diff --git a/gcc/testsuite/gdc.dg/pr112270.d b/gcc/testsuite/gdc.dg/pr112270.d new file mode 100644 index 00000000000..591c798fddd --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr112270.d @@ -0,0 +1,7 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112270 +// { dg-do compile } +class CPPNamespaceDeclaration { } +bool isNamespaceEqual (CPPNamespaceDeclaration a) +{ + return a ? true : isNamespaceEqual(a); +}