From patchwork Mon Jan 10 09:41:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 49786 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C387C3891C01 for ; Mon, 10 Jan 2022 09:44:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C387C3891C01 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641807893; bh=qKMrk//jfPfIff4JP91YQu9nqAu1udVFnMJltTFucBM=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=aWzochTBq2L9YH8/D+ElkYJp/qaUvmN89uJYfYZJqm2UPuBoBRKYz+LhjBIs8YcNr 2J7Eq2UHiJCkNEKAKyRinHoyJvgvWmszPk1K0OphpyVnk00uM3CMZvEjBD3oIoptnh j0y2+uxCf2GVmfDTdQ7fW/KjPY62LN5f8o8qarEE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 8F9BA3891C06 for ; Mon, 10 Jan 2022 09:41:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8F9BA3891C06 Received: by mail-wr1-x435.google.com with SMTP id v6so25481549wra.8 for ; Mon, 10 Jan 2022 01:41:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=qKMrk//jfPfIff4JP91YQu9nqAu1udVFnMJltTFucBM=; b=725cxvEn6A+2nZVjxiTLP5VLraGaqFygWYtWt4lxWqUA+BkUOUJCr6T1NYpgfYyyxX ic2LLRoiAdnN+XV2ifVHFD2C7a7w9kgaew9QQnZHn00/uCZmgnTNrpBNiwuC5lCw3IK4 O/dry8RU6u6h/3O13zmmdjOz8abiw/86ldFQsuqiAUzqZA15DoMu48F/7lhuiSqQzFka iUtgWk0qyMBZr9Odf4Vc/9NVqUtNH9Yh6adFF8gYLuGTnTet/seAJ01W/6AdkWXtm+Us a/smP1qfEHDONG+3AEa6bM+21BE3MSb5nsuop5L1EADzIElxDdQqQwRE3qzjlAcCxOOB f4ow== X-Gm-Message-State: AOAM533DBfQKGADjl/T0nLPe8spScGmK4aaPA50xec6iCkJS+hNQn/Eo lv19TsXYqlHaIjU3Nak2Q7LeTJrsWxDOmQ== X-Google-Smtp-Source: ABdhPJz6NCQBCWd1yMImzDSqdR/FfRLdjyEeXmsnJUEjJfG2uYfGW9cu79Sl5TQJ4v7xe0VmutaGUg== X-Received: by 2002:a05:6000:1006:: with SMTP id a6mr4475482wrx.484.1641807695668; Mon, 10 Jan 2022 01:41:35 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id a3sm6741199wri.89.2022.01.10.01.41.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jan 2022 01:41:35 -0800 (PST) Date: Mon, 10 Jan 2022 09:41:34 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Adjust the alignment to the size for bit-packed arrays Message-ID: <20220110094134.GA586058@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , X-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Eric Botcazou Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This fixes a fallout of the latest change, which removed a problematic line resetting the alignment of the PAT type. It turns out that the alignment must now be adjusted for modular PAT types, as done in other contexts, to be consistent with the size. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_pakd.adb (Install_PAT): If the PAT is a scalar type, apply the canonical adjustment to its alignment. diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb --- a/gcc/ada/exp_pakd.adb +++ b/gcc/ada/exp_pakd.adb @@ -573,6 +573,19 @@ package body Exp_Pakd is end if; end if; + -- In the case of a modular type, make sure the alignment is + -- consistent with the Esize. + + if Is_Scalar_Type (PAT) then + while Alignment (PAT) * System_Storage_Unit < Esize (PAT) + and then Alignment (PAT) < Maximum_Alignment + loop + Set_Alignment (PAT, 2 * Alignment (PAT)); + end loop; + end if; + + -- Then, in all cases, make sure the opposite is also true + Adjust_Esize_Alignment (PAT); -- Set remaining fields of packed array type