From patchwork Fri Oct 25 08:44:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 99531 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 6A8A23858C41 for ; Fri, 25 Oct 2024 08:45:03 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id DB3F63858D21 for ; Fri, 25 Oct 2024 08:44:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB3F63858D21 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DB3F63858D21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729845876; cv=none; b=REPobQpMaSzAL1ds3gxwEZ5RU8sYS1CUEmyprM+txsecY33u6JleOh/Wd9lot87ZXMhYhmJYXdqOujXhYfg0pKOpkKTrjNO3nAUiLYIs+YrKJcu8NL8CpLgI8nbQsafxKBhtOMPZ2LQki2OXVJKirXsmCfnE977ujB9uiRHZsAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729845876; c=relaxed/simple; bh=sSJpdvtetoC8UZO9qdGqfj/EmJITjO9yktnXzawbuk0=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=WnbSrzCSCmsJW7kjBbvitaMfSEYgD+1Wh9fShVdrQdf/qee24zyWAggofa5WLQL4kPJPTO/P3RQBzVBCEVrLyqXLaeB7dtS78ZYm1OvDcMGUaByUHAyeCUN8Axbu0l0DuBU4vEW3A6Gszbg5xl5m0+BUjsF8uOCe7IugcDg2pIU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729845869; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=9m/CPr5Iumq0QB3QJQwKtrOlQbR3Wq6MdBlna690F1c=; b=IF/BcHxRDJZKH2GgBKN9ue3J6XinU6OINhYXIhivFoQ/nUGeFQMwFnHPrXn0M22xhqh1b+ NZ0r9QwsTO+UoRfaR1T36BCYpxwniDaseMmdBSAL0wfvxqyfrUg9eX7H51vBn+cZMAZGyC 4g1ZieOzn7oUFSysK1dSFWMKt1rTJws= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-652-cQntP_PTPUaZYV8P4w5sSA-1; Fri, 25 Oct 2024 04:44:26 -0400 X-MC-Unique: cQntP_PTPUaZYV8P4w5sSA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1CD811955F40; Fri, 25 Oct 2024 08:44:25 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.16]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 677171956056; Fri, 25 Oct 2024 08:44:23 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 49P8iKMF1367759 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 25 Oct 2024 10:44:20 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 49P8iKGP1367758; Fri, 25 Oct 2024 10:44:20 +0200 Date: Fri, 25 Oct 2024 10:44:19 +0200 From: Jakub Jelinek To: Richard Biener , Jan Hubicka Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] lto: Handle RAW_DATA_CST in compare_tree_sccs_1 [PR117201] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SCC_10_SHORT_WORD_LINES, SCC_5_SHORT_WORD_LINES, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no 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: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org Hi! I've missed I need to add RAW_DATA_CST support in compare_tree_sccs_1, because without that it considers all RAW_DATA_CSTs to be equivalent, regardless of their length or content. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-10-24 Jakub Jelinek PR lto/117201 PR lto/117288 * lto-common.cc (compare_tree_sccs_1): Handle RAW_DATA_CST. * gcc.dg/lto/pr117201_0.c: New test. * gcc.dg/lto/pr117288_0.c: New test. Jakub --- gcc/lto/lto-common.cc.jj 2024-06-07 12:17:09.000000000 +0200 +++ gcc/lto/lto-common.cc 2024-10-24 15:55:13.713178421 +0200 @@ -1335,6 +1335,12 @@ compare_tree_sccs_1 (tree t1, tree t2, t TREE_STRING_LENGTH (t1)) != 0) return false; + if (code == RAW_DATA_CST) + if (RAW_DATA_LENGTH (t1) != RAW_DATA_LENGTH (t2) + || memcmp (RAW_DATA_POINTER (t1), RAW_DATA_POINTER (t2), + RAW_DATA_LENGTH (t1)) != 0) + return false; + if (code == OMP_CLAUSE) { compare_values (OMP_CLAUSE_CODE); --- gcc/testsuite/gcc.dg/lto/pr117201_0.c.jj 2024-10-24 15:56:04.769462522 +0200 +++ gcc/testsuite/gcc.dg/lto/pr117201_0.c 2024-10-24 15:57:12.579511715 +0200 @@ -0,0 +1,26 @@ +/* PR lto/117201 */ +/* { dg-lto-do run } */ +/* { dg-lto-options { "-O0 -flto" } } */ + +unsigned char a = 193; +unsigned char *b = &a; + +void +foo (void) +{ + unsigned char c[] = { 0, 2, 1, 1, 2, 1, 2, 2, 6, 2, 1, 1, 1, 1, 2, 2, 0, + 2, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, + 1, 1, 2, 1, 2, 2, 1, 1, 2, 4, 8, 8, 3, 3, 1, 1, 5, + 4, 1, 1, 1, 0, 5, 5, 9, 4, 8, 8, 7, 0, 1, 1 }; +} + +int +main () +{ + unsigned char c[] = { 193, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 5, 2, 3, 1, 0, + 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 4, + 2, 2, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, + 1, 1, 0, 5, 3, 3, 1, 0, 1, 0, 0, 1, 0, 1, 0 }; + if (b[0] != c[0]) + __builtin_abort (); +} --- gcc/testsuite/gcc.dg/lto/pr117288_0.c.jj 2024-10-25 10:37:37.693612115 +0200 +++ gcc/testsuite/gcc.dg/lto/pr117288_0.c 2024-10-25 10:32:29.530992602 +0200 @@ -0,0 +1,76 @@ +/* PR lto/117288 */ +/* { dg-lto-do link } */ +/* { dg-lto-options { "-O0 -flto" } } */ + +__attribute__((noipa)) static void +foo (const void *x) +{ + (void) x; +} + +static void +bar (void) +{ + unsigned char a[81] = { + 0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0xfa, 0x01, 0x00, 0x01, + 0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0xee, 0xfe, 0xfd, 0xc0, 0xca, 0xb5, 0x6f, 0x3d, + 0x23, 0xcc, 0x53, 0x9a, 0x67, 0x17, 0x70, 0xd3, + 0xfb, 0x23, 0x16, 0x9e, 0x4e, 0xd6, 0x7e, 0x29, + 0xab, 0xfa, 0x4c, 0xa5, 0x84, 0x95, 0xc3, 0xdb, + 0x21, 0x9a, 0x52, 0x00, 0x00, 0x00, 0x36, 0x13, + 0x01, 0x13, 0x02, 0x13, 0x03, 0xc0, 0x2c, 0xc0, + 0x2b, 0xc0, 0x30, 0xc0, 0x2f, 0x00, 0x9f, 0x00, + 0x9e, + }; + foo (&a); +} + +static void +baz (void) +{ + const struct S + { + unsigned char a[32]; + int b; + unsigned char c[32]; + int d; + unsigned char e[32]; + int f; + unsigned char g[80]; + int h; + unsigned char i[80]; + int j; + } s = { + { 0x00, }, 16, + { 0x4f, }, 16, + { 0x00 }, 0, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, + 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }, 80, + { 0xe9, }, 80, + }; + + foo (s.g); +} + +__attribute__((noipa)) static void +qux (const void (*x) (void)) +{ + (void) x; +} + +int +main () +{ + qux (&baz); + qux (&bar); +}