From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 107985 invoked by alias); 20 Oct 2015 21:27:57 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 107958 invoked by uid 89); 20 Oct 2015 21:27:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f44.google.com Received: from mail-pa0-f44.google.com (HELO mail-pa0-f44.google.com) (209.85.220.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 20 Oct 2015 21:27:55 +0000 Received: by pabrc13 with SMTP id rc13so32237435pab.0 for ; Tue, 20 Oct 2015 14:27:53 -0700 (PDT) X-Received: by 10.68.243.99 with SMTP id wx3mr6234269pbc.33.1445376473295; Tue, 20 Oct 2015 14:27:53 -0700 (PDT) Received: from bigtime.com (cpe-50-113-10-46.hawaii.res.rr.com. [50.113.10.46]) by smtp.gmail.com with ESMTPSA id de4sm5422136pbb.60.2015.10.20.14.27.52 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Oct 2015 14:27:52 -0700 (PDT) From: Richard Henderson To: gcc-patches@gcc.gnu.org Cc: richard.guenther@gmail.com Subject: [PATCH v2 01/13] Change default of non-overlapping address space conversion Date: Tue, 20 Oct 2015 21:28:00 -0000 Message-Id: <1445376433-14658-2-git-send-email-rth@redhat.com> In-Reply-To: <1445376433-14658-1-git-send-email-rth@redhat.com> References: <1445376433-14658-1-git-send-email-rth@redhat.com> X-IsSubscribed: yes X-SW-Source: 2015-10/txt/msg01981.txt.bz2 The current default of making all undefined coversions being set to null is not useful. It has caused all users to lie and say that spaces are subsets when they are not, just so that they can override the conversion. --- gcc/expr.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/gcc/expr.c b/gcc/expr.c index 595324d..9287da2 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -8179,34 +8179,40 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, case ADDR_SPACE_CONVERT_EXPR: { tree treeop0_type = TREE_TYPE (treeop0); - addr_space_t as_to; - addr_space_t as_from; gcc_assert (POINTER_TYPE_P (type)); gcc_assert (POINTER_TYPE_P (treeop0_type)); - as_to = TYPE_ADDR_SPACE (TREE_TYPE (type)); - as_from = TYPE_ADDR_SPACE (TREE_TYPE (treeop0_type)); + addr_space_t as_to = TYPE_ADDR_SPACE (TREE_TYPE (type)); + addr_space_t as_from = TYPE_ADDR_SPACE (TREE_TYPE (treeop0_type)); /* Conversions between pointers to the same address space should have been implemented via CONVERT_EXPR / NOP_EXPR. */ gcc_assert (as_to != as_from); + op0 = expand_expr (treeop0, NULL_RTX, VOIDmode, modifier); + /* Ask target code to handle conversion between pointers to overlapping address spaces. */ if (targetm.addr_space.subset_p (as_to, as_from) || targetm.addr_space.subset_p (as_from, as_to)) { - op0 = expand_expr (treeop0, NULL_RTX, VOIDmode, modifier); op0 = targetm.addr_space.convert (op0, treeop0_type, type); - gcc_assert (op0); - return op0; } - - /* For disjoint address spaces, converting anything but - a null pointer invokes undefined behaviour. We simply - always return a null pointer here. */ - return CONST0_RTX (mode); + else + { + /* For disjoint address spaces, converting anything but a null + pointer invokes undefined behaviour. We truncate or extend the + value as if we'd converted via integers, which handles 0 as + required, and all others as the programmer likely expects. */ +#ifndef POINTERS_EXTEND_UNSIGNED + const int POINTERS_EXTEND_UNSIGNED = 1; +#endif + op0 = convert_modes (mode, TYPE_MODE (treeop0_type), + op0, POINTERS_EXTEND_UNSIGNED); + } + gcc_assert (op0); + return op0; } case POINTER_PLUS_EXPR: -- 2.4.3