diff options
author | Lulu Cheng <chenglulu@loongson.cn> | 2024-01-12 17:06:30 +0800 |
---|---|---|
committer | Lulu Cheng <chenglulu@loongson.cn> | 2024-01-18 15:23:15 +0800 |
commit | d78b7bdb9ac0514b542259d0f4c6d623d09fd830 (patch) | |
tree | b685f16c7e4212cf6be9aed07b11be98256655ae /gcc | |
parent | a689c1f4865ea6d4c7d2a928a17894671642fa34 (diff) | |
download | gcc-d78b7bdb9ac0514b542259d0f4c6d623d09fd830.zip gcc-d78b7bdb9ac0514b542259d0f4c6d623d09fd830.tar.gz gcc-d78b7bdb9ac0514b542259d0f4c6d623d09fd830.tar.bz2 |
LoongArch: Assign the '/u' attribute to the mem to which the global offset table belongs.
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config/loongarch/loongarch.cc | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.target/loongarch/got-load.C | 19 |
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 3b8559b..8246747 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 0000000..20924c73 --- /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]; +} |