public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] LoongArch: Assign the '/u' attribute to the mem to which the global offset table belongs.
@ 2024-01-13  6:37 Lulu Cheng
  2024-01-18  7:25 ` [pushed][PATCH] " chenglulu
  0 siblings, 1 reply; 2+ messages in thread
From: Lulu Cheng @ 2024-01-13  6:37 UTC (permalink / raw)
  To: gcc-patches; +Cc: xry111, i, xuchenghua, Lulu Cheng

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 <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];
+}
-- 
2.39.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [pushed][PATCH] LoongArch: Assign the '/u' attribute to the mem to which the global offset table belongs.
  2024-01-13  6:37 [PATCH] LoongArch: Assign the '/u' attribute to the mem to which the global offset table belongs Lulu Cheng
@ 2024-01-18  7:25 ` chenglulu
  0 siblings, 0 replies; 2+ messages in thread
From: chenglulu @ 2024-01-18  7:25 UTC (permalink / raw)
  To: gcc-patches; +Cc: xry111, i, xuchenghua

Pushed to r14-8203.

在 2024/1/13 下午2:37, Lulu Cheng 写道:
> 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 <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];
> +}


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-18  7:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-13  6:37 [PATCH] LoongArch: Assign the '/u' attribute to the mem to which the global offset table belongs Lulu Cheng
2024-01-18  7:25 ` [pushed][PATCH] " chenglulu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).