From patchwork Mon Nov 24 08:15:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 413570 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 12613140161 for ; Mon, 24 Nov 2014 19:23:44 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=HlSWkf7HJ77lpqxk P2TG6AWsmWfdWBlIoLr5J+Ckj9EV9QsFTELClfF0yczTqBD01/7CCsgMWZVjTS4Q PRQ2R/zjUJBABHdwtbr3ULK315MlFY/LhAuQr477thJPnisCh8nF4fEFz8YzaL1B kOnY55WVzu1al9HRWS9g81hDFcA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=3dUKAyMcDnl3zgNVEf7lZo iXRqs=; b=WHyqdCFKbqxOXaEznYF9lJuUSd0mCtNNtm1YqJQkg6WqW7JHFTm33I /G8pzcqxjZ5569DMJ5xywf5C1MEdm7MUUxvfV0MRQAmX8Ymn5TauvJoLnYcYJGIv OD+gone1eLvbPjT/k1jMw5cHVslWsjl6WqjrJdqZ7CRIP0qVw0f14= Received: (qmail 19098 invoked by alias); 24 Nov 2014 08:23:38 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 19088 invoked by uid 89); 24 Nov 2014 08:23:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 24 Nov 2014 08:23:36 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 863342B7F01B for ; Mon, 24 Nov 2014 09:23:29 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NICwDU9es2gE for ; Mon, 24 Nov 2014 09:23:29 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 2DC712B7F014 for ; Mon, 24 Nov 2014 09:23:28 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix ICE on array with unaligned index type at -O3 Date: Mon, 24 Nov 2014 09:15:24 +0100 Message-ID: <45708284.trDWrk8Xlv@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.29-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 This is a regression present on the mainline and 4.9 branch involving an array with an unaligned index type and when -O3 is specified. Tested on x86_64-suse-linux, applied on the mainline and 4.9 branch. 2014-11-24 Eric Botcazou * gcc-interface/trans.c (push_range_check_info): Replace early test with assertion. (Raise_Error_to_gnu): Do not call push_range_check_info if the loop stack is empty. * gcc-interface/utils.c (convert_to_fat_pointer): Fix formatting. * gcc-interface/utils2.c (gnat_invariant_expr): Deal with padded types and revert latest change. 2014-11-24 Eric Botcazou * gnat.dg/opt45.adb: New test. Index: gcc-interface/utils.c =================================================================== --- gcc-interface/utils.c (revision 217961) +++ gcc-interface/utils.c (working copy) @@ -3860,8 +3860,7 @@ convert_to_fat_pointer (tree type, tree { /* The template type can still be dummy at this point so we build an empty constructor. The middle-end will fill it in with zeros. */ - t = build_constructor (template_type, - NULL); + t = build_constructor (template_type, NULL); TREE_CONSTANT (t) = TREE_STATIC (t) = 1; null_bounds = build_unary_op (ADDR_EXPR, NULL_TREE, t); SET_TYPE_NULL_BOUNDS (ptr_template_type, null_bounds); Index: gcc-interface/utils2.c =================================================================== --- gcc-interface/utils2.c (revision 217961) +++ gcc-interface/utils2.c (working copy) @@ -2780,7 +2780,13 @@ gnat_invariant_expr (tree expr) || (TREE_CODE (expr) == VAR_DECL && TREE_READONLY (expr))) && decl_function_context (expr) == current_function_decl && DECL_INITIAL (expr)) - expr = remove_conversions (DECL_INITIAL (expr), false); + { + expr = DECL_INITIAL (expr); + /* Look into CONSTRUCTORs built to initialize padded types. */ + if (TYPE_IS_PADDING_P (TREE_TYPE (expr))) + expr = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (expr))), expr); + expr = remove_conversions (expr, false); + } if (TREE_CONSTANT (expr)) return fold_convert (type, expr); @@ -2836,7 +2842,7 @@ object: if (!TREE_READONLY (t)) return NULL_TREE; - if (TREE_CODE (t) == CONSTRUCTOR || TREE_CODE (t) == PARM_DECL) + if (TREE_CODE (t) == PARM_DECL) return fold_convert (type, expr); if (TREE_CODE (t) == VAR_DECL Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 217965) +++ gcc-interface/trans.c (working copy) @@ -2569,9 +2569,6 @@ push_range_check_info (tree var) struct loop_info_d *iter = NULL; unsigned int i; - if (vec_safe_is_empty (gnu_loop_stack)) - return NULL; - var = remove_conversions (var, false); if (TREE_CODE (var) != VAR_DECL) @@ -2580,6 +2577,8 @@ push_range_check_info (tree var) if (decl_function_context (var) != current_function_decl) return NULL; + gcc_assert (vec_safe_length (gnu_loop_stack) > 0); + for (i = vec_safe_length (gnu_loop_stack) - 1; vec_safe_iterate (gnu_loop_stack, i, &iter); i--) @@ -5175,6 +5174,7 @@ Raise_Error_to_gnu (Node_Id gnat_node, t the original checks reinstated, and a run time selection. The former loop will be suitable for vectorization. */ if (flag_unswitch_loops + && !vec_safe_is_empty (gnu_loop_stack) && (!gnu_low_bound || (gnu_low_bound = gnat_invariant_expr (gnu_low_bound))) && (!gnu_high_bound