From patchwork Sat Sep 9 12:48:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 811958 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-461774-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="CYn9Rz/+"; dkim-atps=neutral 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 3xqDXD00C8z9s5L for ; Sat, 9 Sep 2017 22:48:55 +1000 (AEST) 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=l95iD4cbrMJ4L8GF Y8d/eK9zg1O1evWt6n5k3TLRTLD8vs4FI5E0UQhZDQAFg47pa58X9bV5TeW4viyC qwo03+tqxay0+p/UCFY8UMEx2yLGN+Q9hakL7dqxBIMw1LXhKYBtMjVnrwe2Zurz XdkUeLnsmUpT+J6EMl5q6Jkpc6I= 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=gQbudWeZqTtQGwWcpq4C2l djn7Q=; b=CYn9Rz/+v+CW9F4Nz/KETUxwysn8SAmba31OYx18xjYZRagLVREmxk b/zsJJbASb4zHEe2LdORolId6WuCRVSOSjuYaUhPJ/PuFw4gbNQfPBDQzKh9WNBD bz9LuIoDPVOVJ5+hnPWLRh4H3wMj/PFtAXVY38ooX1gKTdQLtWUv0= Received: (qmail 92525 invoked by alias); 9 Sep 2017 12:48:48 -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 91807 invoked by uid 89); 9 Sep 2017 12:48:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1641, capped 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 ESMTP; Sat, 09 Sep 2017 12:48:46 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 2F3F28232E for ; Sat, 9 Sep 2017 14:48:44 +0200 (CEST) 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 V7QQ8oCKAjrk for ; Sat, 9 Sep 2017 14:48:44 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 06ADB8229E for ; Sat, 9 Sep 2017 14:48:43 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Take into account alignment gap for component reordering Date: Sat, 09 Sep 2017 14:48:43 +0200 Message-ID: <1737952.P4YWRSkRpT@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-53-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 This disables the recently implemented component reordering in one more case. Tested on x86_64-suse-linux, applied on the mainline. 2017-09-09 Eric Botcazou * gcc-interface/decl.c (components_to_record): Do not reorder in non- packed record types if pragma Optimize_Alignment (Space) is enabled. Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 251934) +++ gcc-interface/decl.c (working copy) @@ -7683,7 +7683,9 @@ components_to_record (Node_Id gnat_compo of a byte, so that they don't cause the regular fields to be either at self-referential/variable offset or misaligned. Note, in the latter case, that this can only happen in packed record types so the alignment - is effectively capped to the byte for the whole record. + is effectively capped to the byte for the whole record. But we don't + do it for non-packed record types if pragma Optimize_Alignment (Space) + is specified because this can prevent alignment gaps from being filled. Optionally, if the layout warning is enabled, keep track of the above 4 different kinds of fields and issue a warning if some of them would be @@ -7694,6 +7696,8 @@ components_to_record (Node_Id gnat_compo const bool do_reorder = (Convention (gnat_record_type) == Convention_Ada && !No_Reordering (gnat_record_type) + && (!Optimize_Alignment_Space (gnat_record_type) + || Is_Packed (gnat_record_type)) && !debug__debug_flag_dot_r); const bool w_reorder = (Convention (gnat_record_type) == Convention_Ada