From patchwork Tue Oct 10 12:14:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 150727 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp153869vqb; Tue, 10 Oct 2023 05:19:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvqtzHHtYSxmFtiKI5FKHsoqblrwQSgVBD2ntGTkgLZ8RNNMbgW3aXMwwYEt2SsrRXxRuj X-Received: by 2002:a05:6402:1a28:b0:522:3849:48d8 with SMTP id be8-20020a0564021a2800b00522384948d8mr16651027edb.9.1696940370808; Tue, 10 Oct 2023 05:19:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696940370; cv=none; d=google.com; s=arc-20160816; b=m0rurc0Yma6JO0dv+U+I/prqPdX3jPIjo+YKu2U8MZwV5ULnwl/338QzUyEjtVZR0P AI8KETawF5N6xl/ohqagoMgw1oBRg9Rj+KUGa22Xr5Y8Wl92KOnLQ7kGUpPmF9E06GQl zUk8pUZ0wHANTZA4xJpaxOM82isspfDNHbzZH1OcTyEnlSlPi+6lJubQHZvL28FFHc2a V/gslFtrxQSSUaf98uIend6CgJsEukdaz6Ye/GH3JYA2ewrvmStHUb0SyeK0CGwMPPZl 8/mPDnW/pKAZEd2HLjrMQkOt2XYfR/gZz2FxfrWN5KNE1uH/O6km82T12siXUPW1D7YP aAWg== ARC-Message-Signature: i=1; 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 :dmarc-filter:delivered-to; bh=3HVEVs7PKoKXY8FXbN2XvOhYU5a7jC/KOowrz5Zobi4=; fh=hOhsC1930eHatDPYd2EALQ9Ry/g++vvN4vxlQkRuX+0=; b=bs3TjpMRuqvHtzXTgSPNxyo7PEvS6s/Lm/OBAGzTo9Caz4c+qmtR5FA0bxDM7lyU0s l0MsWYdSkAYNFIxhXvOQxtkuE9ciLVw566y/Wj3NEs5V6fd8kxC9i/ZmEr5brz1yBKEm 0MPfbOL6jwxQU7nvfRbda5rNtI1ZKoIaPPbO/nc+1qnREyGvnwA67BKrcHfKgSsgcXpP CMgtbXHADMPfn5RrLfRzt0pI6Sgb7kTPJmggROu9V0aKVY8XwuMEvt/9rXQF3cozO2CP gr8A3y0EPt5r1mE0PJjIX4omUGmVmMoYdXmhT0eaq0+OlqemQKKUa9MB+G5fwtIubryw w75A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=B6mG3tu9; 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=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id p11-20020a056402074b00b00533e4393d44si5399318edy.486.2023.10.10.05.19.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 05:19:30 -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=@adacore.com header.s=google header.b=B6mG3tu9; 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=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E65D5388B6AF for ; Tue, 10 Oct 2023 12:16:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id 00CE83861912 for ; Tue, 10 Oct 2023 12:15:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 00CE83861912 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4065dea9a33so53736735e9.3 for ; Tue, 10 Oct 2023 05:15:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1696940102; x=1697544902; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=3HVEVs7PKoKXY8FXbN2XvOhYU5a7jC/KOowrz5Zobi4=; b=B6mG3tu97YUL6OgFrn5jQxHsvmS7EEfhCFpGy0pf9HhmuxvFaiJj8xYZ2ln43CL3TA vlXPP5TTAXllVs5mfrE/+ifWmhJsPKhj2IgrpoqplQPGjkGfQdW9ibXtCJwQtMttpV3O r0+nifkioK12b6GHXBIpRIawBvAAJazalPl0tmlKVwsVr/HnVXNaf2I0PCOSwe1LLKi3 PDd5+Qtu7/qeG0RzGNHob6lRQ0UsUVQRD/rTeZe53RZPh3RIDIVbmkrhAhKKgvuiyc75 nH5/hbDgbalCuerg6N12VpqJ1AFvWVOJhJvMm5yQfZ1JFk9kWxHt3FjavGP1GlWlvsu3 fZAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696940102; x=1697544902; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3HVEVs7PKoKXY8FXbN2XvOhYU5a7jC/KOowrz5Zobi4=; b=KAWSZ9HoiQhtZeoVIE5gwKKG19C1riAgZBZ5swzfFW8sBOmhhJk9PwAw8UhubNEUaK YRhpVLDbMHS9kvOSTuO9Z/QpDNRWyBOWle4ANgL37ldJGYR7vpNi0dnTLf32htlFD/SU 0LMH6ypwIMvoNURiAANygHJudKTi6V7auOIxmE4gbPnZbOYwXZHOgLkOttLcols+zOr7 IO2oNnnGA141AXIeOXVNtUNgofMzlu0BbDUlc4BtC2TXU4YeUtniyHmg3jJQyf7vUu+G vGSVRmZBjonCghwjOVIz+k34LSc7eyKvBe1ZCC6lBYb+16eHR0op6X7jNI5vGTxtW5JJ spWQ== X-Gm-Message-State: AOJu0YwyNtEF6+Zsw4/29sC/GeObmpnNTIANDjBqA0WaCoICTMru+Gyh wXaHcthzTDc7TEFGXiIuR1YWFPcYv9jn8sXu3RZSiQ== X-Received: by 2002:a7b:c387:0:b0:3f9:b430:199b with SMTP id s7-20020a7bc387000000b003f9b430199bmr15832721wmj.15.1696940100967; Tue, 10 Oct 2023 05:15:00 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id k22-20020a7bc416000000b00404719b05b5sm14023928wmi.27.2023.10.10.05.15.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 05:15:00 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix internal error on too large representation clause for small component Date: Tue, 10 Oct 2023 14:14:59 +0200 Message-ID: <20231010121459.3888667-1-poulhies@adacore.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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.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: 1779370945921133337 X-GMAIL-MSGID: 1779370945921133337 From: Eric Botcazou This is a small bug present on strict-alignment platforms for questionable representation clauses. gcc/ada/ * gcc-interface/decl.cc (inline_status_for_subprog): Minor tweak. (gnat_to_gnu_field): Try harder to get a packable form of the type for a bitfield. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/decl.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index 5e16b56217c..20ab185d577 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -5114,7 +5114,7 @@ inline_status_for_subprog (Entity_Id subprog) tree gnu_type; /* This is a kludge to work around a pass ordering issue: for small - record types with many components, i.e. typically bit-fields, the + record types with many components, i.e. typically bitfields, the initialization routine can contain many assignments that will be merged by the GIMPLE store merging pass. But this pass runs very late in the pipeline, in particular after the inlining decisions @@ -7702,6 +7702,18 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, gnu_field_type = maybe_pad_type (gnu_field_type, gnu_size, 0, gnat_field, false, definition, true); + /* For a bitfield, if the type still has BLKmode, try again to change it + to an integral mode form. This may be necessary on strict-alignment + platforms with a size clause that is much larger than the field type, + because maybe_pad_type has preserved the alignment of the field type, + which may be too low for the new size. */ + if (!needs_strict_alignment + && RECORD_OR_UNION_TYPE_P (gnu_field_type) + && !TYPE_FAT_POINTER_P (gnu_field_type) + && TYPE_MODE (gnu_field_type) == BLKmode + && is_bitfield) + gnu_field_type = make_packable_type (gnu_field_type, true, 1); + /* If a padding record was made, declare it now since it will never be declared otherwise. This is necessary to ensure that its subtrees are properly marked. */