From patchwork Tue Dec 3 10:12:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1203590 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-515040-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="H9GmKTfO"; 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 47RyV516ydz9s4Y for ; Tue, 3 Dec 2019 21:12:59 +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=Q2coavHIU5xlII+s wjkvgMISZbl6x9kS13lvLTBhbmcc1s2lKI55pGvH3YuwOD4PSEl5eF5Z481Z4CMZ RgyNo2b51WIXQG8LsVUwnUdJV+Ss2etk1gTwdlYW2//a9lwV6wL7ayAaTYBc3EPp hCS4wWqT+cACP0zBreaWzoBf960= 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=6A1boNz/9lwjO2uzo1tXs/ tZqf8=; b=H9GmKTfOwM3P+gJSCx6wt5oWjd6zYmv5zy8rpU8R43FMY1qycKLemJ 6pKUxe0Mrt4XGm+739x6D7KrvDkjj7shTcFZLB6Svw8B6ykqmbdET2swajGOEYXC I0+q+YQzu9Rdx5kktToEWMS/pDL5CJyypNyo6LN7ECeX4azMOEW4g= Received: (qmail 109442 invoked by alias); 3 Dec 2019 10:12:49 -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 109389 invoked by uid 89); 3 Dec 2019 10:12:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1935 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; Tue, 03 Dec 2019 10:12:41 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id B90C981380 for ; Tue, 3 Dec 2019 11:12:39 +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 opF4WHAtyS4m for ; Tue, 3 Dec 2019 11:12:39 +0100 (CET) Received: from polaris.localnet (unknown [IPv6:2a01:e0a:41b:9230:1a03:73ff:fe45:373a]) (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 9861C8137F for ; Tue, 3 Dec 2019 11:12:39 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix debug info for variant records on m68k Date: Tue, 03 Dec 2019 11:12:37 +0100 Message-ID: <1693514.iT2t62ubmi@polaris> MIME-Version: 1.0 This fixes a bug in the encoding used in the debug info generated for record types with variant part for targets where the alignment is capped to 16 bits like the m68k (unless -malign-int is specified). Tested on m68k-elf and x86_64-suse-linux, applied on the mainline. 2019-12-03 Eric Botcazou * gcc-interface/utils.c (fold_convert_size): New function. (fold_bit_position): Invoke it to do further folding. Index: gcc-interface/utils.c =================================================================== --- gcc-interface/utils.c (revision 277906) +++ gcc-interface/utils.c (working copy) @@ -2349,19 +2349,27 @@ merge_sizes (tree last_size, tree first_ return new_size; } +/* Convert the size expression EXPR to TYPE and fold the result. */ + +static tree +fold_convert_size (tree type, tree expr) +{ + /* We assume that size expressions do not wrap around. */ + if (TREE_CODE (expr) == MULT_EXPR || TREE_CODE (expr) == PLUS_EXPR) + return size_binop (TREE_CODE (expr), + fold_convert_size (type, TREE_OPERAND (expr, 0)), + fold_convert_size (type, TREE_OPERAND (expr, 1))); + + return fold_convert (type, expr); +} + /* Return the bit position of FIELD, in bits from the start of the record, and fold it as much as possible. This is a tree of type bitsizetype. */ static tree fold_bit_position (const_tree field) { - tree offset = DECL_FIELD_OFFSET (field); - if (TREE_CODE (offset) == MULT_EXPR || TREE_CODE (offset) == PLUS_EXPR) - offset = size_binop (TREE_CODE (offset), - fold_convert (bitsizetype, TREE_OPERAND (offset, 0)), - fold_convert (bitsizetype, TREE_OPERAND (offset, 1))); - else - offset = fold_convert (bitsizetype, offset); + tree offset = fold_convert_size (bitsizetype, DECL_FIELD_OFFSET (field)); return size_binop (PLUS_EXPR, DECL_FIELD_BIT_OFFSET (field), size_binop (MULT_EXPR, offset, bitsize_unit_node)); }