]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: Assign the '/u' attribute to the mem to which the global offset table...
authorLulu Cheng <chenglulu@loongson.cn>
Fri, 12 Jan 2024 09:06:30 +0000 (17:06 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Thu, 18 Jan 2024 07:23:15 +0000 (15:23 +0800)
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
gcc/testsuite/g++.target/loongarch/got-load.C [new file with mode: 0644]

index 3b8559bfdc85cc01c6008c637c4240eae3598dd9..8246747428835b27eb6a92aa0eb8df651473ac40 100644 (file)
@@ -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 (file)
index 0000000..20924c7
--- /dev/null
@@ -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 <bits/stdc++.h>
+
+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];
+}