From patchwork Sat Jan 13 06:37:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: chenglulu X-Patchwork-Id: 187872 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp625887dyc; Fri, 12 Jan 2024 22:38:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHD0mDsBMWq1cyAYGZn5zE78Rlngp2/y71CYUSzp1V+Zm08SwJujT+JgVeCeZuRY5Fvw+q7 X-Received: by 2002:a05:622a:1b2a:b0:429:b92a:7204 with SMTP id bb42-20020a05622a1b2a00b00429b92a7204mr3394373qtb.20.1705127882693; Fri, 12 Jan 2024 22:38:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705127882; cv=pass; d=google.com; s=arc-20160816; b=srgdUjYLceh6SYHna4p6SJ0f8f9QcUoabH5rae6o64q2FfJ1wlmc5BObs7ZD607qee 5cMgnSSaCVJAAhFBhJ/SuVleuddbM6McgQ4uV92qfScO/TEwjArQxIVyuCa3TZN/g011 KzEAoejqLZfMfBN7sSp9FHz/wfVmSj7PxKxY+lyi/rrRvWQS+8ScDo43wbFHA6Gk4pNy jfRkQjUEu6poGoObMKItI3/+RCr8P5K+pNl93wRNS7LzxH6jmcNghFdO6lFcdIkBP3E8 BUNtz9VijRc5wBHjvaSw2NSAJakZ8+XyapAVE5slkN6Q8WwPPJgkXa+zusI4Vi0xeiAi enJw== ARC-Message-Signature: i=2; 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:arc-filter :dmarc-filter:delivered-to; bh=SjlAPf8bZZFpp3bIoR3540Zj7PrO6CEWMwG8PNbFquU=; fh=kLXYvQYlFoGM+V705nfHVJAr1G8Exwjn4Aw52UExiO4=; b=VGgazijzdjQXBPuEiB34BeJ9Zw8TBvSrURrsage4SiOHqTnxQ0oIrMf13GgngPLlzu Lv79hSOQtufupt8Z/CY7AG4W60IyYMXd86JKWkEkOMH/2R4oPUZ1spww5xDePJRU9QSa JvOdMq3yxkfKQuenyfSF2QLGGQ4IRFRaFnPg+0XzbyW5sPvDIeFx/Ji5ccWkXRmBW+6S OD74psyMGV2bPse1TI/jWN4Ae96kX4yxO8L/hcP8wf97ehdCHqsw+on7XjhRe8H29AjY 6wNvter+0xdo7OdSNP+BzwlCNVmQ5HWGUYIPn//23BFHMzVdT5v5vpoSLvm78U2AaBEK /KJg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id o19-20020ac85a53000000b00429917b97c9si4591499qta.382.2024.01.12.22.38.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 22:38:02 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 54D403858D32 for ; Sat, 13 Jan 2024 06:38:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 8C1033858D20 for ; Sat, 13 Jan 2024 06:37:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8C1033858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8C1033858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705127846; cv=none; b=pLr0W4m2Feo3Bgn5MEiby8VRfuiERd5spYwVUhYtfEkgNk1pw/TndahUWMLKw9VWGNmv4Lc4dvVwm30RsZYnnGpPXJrT2FTn07iCsoeZIdeUC4u7Eg6U9Al4xOwFxLf5wQAidcNlIEp7RSId3EBtnxOeBIF37VEmy21oPBJTQYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705127846; c=relaxed/simple; bh=Oxr73d5euLDC9umkwffYhXzqqrVjesIZLjleClVgRRo=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=TQNIbukkIoN9P+viCfnOFQDHL02f8cYAxKiyoADoksLflJhR5lnI08Z+jMtZrSjRZpy/aR0OCCOCgrR7IJFrTBVfIhF2Jgfuc5bOuIVCeU4CaeYbLK3a1M8R3AI35pLqLUtN85sV9Jd8b39uxUIj8P/SfnWxbcmQAOqvRDFduUg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8DxfbueL6JltMAEAA--.5442S3; Sat, 13 Jan 2024 14:37:19 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bx39+bL6JlPpIXAA--.61051S2; Sat, 13 Jan 2024 14:37:17 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, i@xen0n.name, xuchenghua@loongson.cn, Lulu Cheng Subject: [PATCH] LoongArch: Assign the '/u' attribute to the mem to which the global offset table belongs. Date: Sat, 13 Jan 2024 14:37:09 +0800 Message-Id: <20240113063709.19072-1-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Bx39+bL6JlPpIXAA--.61051S2 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoW7WFWxAFWrGr1ftr4xJw4fWFX_yoW8ArWkpa 47Zr4Ykr48Cr97KFsxt343uFs8Grn7Gryava4fKryIkr47Z347ZFn5t3srXF43Ja1UXryI vFWrC3WYgF40qwbCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUyEb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVWUJVW8JwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ Jr0_Gr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27wAqx4 xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v2 6r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwI xGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480 Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7 IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k2 6cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxV AFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU8czVUUUUUU== X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: 1787956174343444231 X-GMAIL-MSGID: 1787956174343444231 gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_split_symbol): Assign the '/u' attribute to the mem. gcc/testsuite/ChangeLog: * g++.target/loongarch/got-load.C: New test. --- gcc/config/loongarch/loongarch.cc | 5 +++++ gcc/testsuite/g++.target/loongarch/got-load.C | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 gcc/testsuite/g++.target/loongarch/got-load.C diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 3b8559bfdc8..82467474288 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -3202,6 +3202,11 @@ loongarch_split_symbol (rtx temp, rtx addr, machine_mode mode, rtx *low_out) rtx mem = gen_rtx_MEM (Pmode, low); *low_out = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, mem), UNSPEC_LOAD_FROM_GOT); + + /* Nonzero in a mem, if the memory is statically allocated and + read-only. A common example of the later is a shared library’s + global offset table. */ + MEM_READONLY_P (mem) = 1; } break; diff --git a/gcc/testsuite/g++.target/loongarch/got-load.C b/gcc/testsuite/g++.target/loongarch/got-load.C new file mode 100644 index 00000000000..20924c73942 --- /dev/null +++ b/gcc/testsuite/g++.target/loongarch/got-load.C @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-mabi=lp64d -O2 -mexplicit-relocs -mcmodel=normal -fdump-rtl-expand" } */ +/* { dg-final { scan-rtl-dump-times "mem/u" 2 "expand" } } */ + +#include + +using namespace std; + +int lr[100005][2]; + +void +test(void) +{ + int n; + + cin >> n; + for (int i = 0; i < n; ++i) + cin >> lr[i][0] >> lr[i][1]; +}