diff options
| author | Jeroen Hofstee <jhofstee@victronenergy.com> | 2025-05-19 11:30:29 -0700 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-05-27 09:01:17 +0100 |
| commit | b4c6bbce0ecb395c428228afa7eda8fae5ae1a61 (patch) | |
| tree | 74467079e2f003a8d0a959f09cb748902c41a991 | |
| parent | 474a7b65e3e57a1fde91788427b3c0731ac4a9cc (diff) | |
| download | poky-b4c6bbce0ecb395c428228afa7eda8fae5ae1a61.tar.gz | |
gcc: Fix wrong code generation in atomic intrinsics for arm
This is seen with QT code
Error: ARM register expected -- `ldrex r1,[s16]'
(From OE-Core rev: 07f6ebadf0bc4a90bdba9106df7fb55be8d76ffd)
Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/recipes-devtools/gcc/gcc-15.1.inc | 1 | ||||
| -rw-r--r-- | meta/recipes-devtools/gcc/gcc/0026-arm-fully-validate-mem_noofs_operand-PR120351.patch | 95 |
2 files changed, 96 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-15.1.inc b/meta/recipes-devtools/gcc/gcc-15.1.inc index f3e9204131..0e6ae67c8b 100644 --- a/meta/recipes-devtools/gcc/gcc-15.1.inc +++ b/meta/recipes-devtools/gcc/gcc-15.1.inc | |||
| @@ -71,6 +71,7 @@ SRC_URI = "${BASEURI} \ | |||
| 71 | file://0023-Fix-install-path-of-linux64.h.patch \ | 71 | file://0023-Fix-install-path-of-linux64.h.patch \ |
| 72 | file://0024-Avoid-hardcoded-build-paths-into-ppc-libgcc.patch \ | 72 | file://0024-Avoid-hardcoded-build-paths-into-ppc-libgcc.patch \ |
| 73 | file://0025-gcc-testsuite-tweaks-for-mips-OE.patch \ | 73 | file://0025-gcc-testsuite-tweaks-for-mips-OE.patch \ |
| 74 | file://0026-arm-fully-validate-mem_noofs_operand-PR120351.patch \ | ||
| 74 | " | 75 | " |
| 75 | 76 | ||
| 76 | S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/${SOURCEDIR}" | 77 | S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/${SOURCEDIR}" |
diff --git a/meta/recipes-devtools/gcc/gcc/0026-arm-fully-validate-mem_noofs_operand-PR120351.patch b/meta/recipes-devtools/gcc/gcc/0026-arm-fully-validate-mem_noofs_operand-PR120351.patch new file mode 100644 index 0000000000..3f324fdc22 --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc/0026-arm-fully-validate-mem_noofs_operand-PR120351.patch | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | From bb7adc5dab8bcee2ef1c0d2af370ea77c49bb5c5 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Richard Earnshaw <rearnsha@arm.com> | ||
| 3 | Date: Mon, 19 May 2025 16:19:39 +0100 | ||
| 4 | Subject: [PATCH] arm: fully validate mem_noofs_operand [PR120351] | ||
| 5 | |||
| 6 | It's not enough to just check that a memory operand is of the form | ||
| 7 | mem(reg); after RA we also need to validate the register being used. | ||
| 8 | The safest way to do this is to call memory_operand. | ||
| 9 | |||
| 10 | PR target/120351 | ||
| 11 | |||
| 12 | gcc/ChangeLog: | ||
| 13 | |||
| 14 | * config/arm/predicates.md (mem_noofs_operand): Also check the op | ||
| 15 | is a valid memory_operand. | ||
| 16 | |||
| 17 | gcc/testsuite/ChangeLog: | ||
| 18 | |||
| 19 | * gcc.target/arm/pr120351.c: New test. | ||
| 20 | |||
| 21 | Upstream-Status: Backport [https://gcc.gnu.org/cgit/gcc/commit/?id=e5bb7a328eb71daa02d15b48d3a6c6b8cd24abc5] | ||
| 22 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 23 | --- | ||
| 24 | gcc/config/arm/predicates.md | 3 +- | ||
| 25 | gcc/testsuite/gcc.target/arm/pr120351.c | 47 +++++++++++++++++++++++++ | ||
| 26 | 2 files changed, 49 insertions(+), 1 deletion(-) | ||
| 27 | create mode 100644 gcc/testsuite/gcc.target/arm/pr120351.c | ||
| 28 | |||
| 29 | diff --git a/gcc/config/arm/predicates.md b/gcc/config/arm/predicates.md | ||
| 30 | index 75c06d9be25..655f60312de 100644 | ||
| 31 | --- a/gcc/config/arm/predicates.md | ||
| 32 | +++ b/gcc/config/arm/predicates.md | ||
| 33 | @@ -907,7 +907,8 @@ | ||
| 34 | |||
| 35 | (define_predicate "mem_noofs_operand" | ||
| 36 | (and (match_code "mem") | ||
| 37 | - (match_code "reg" "0"))) | ||
| 38 | + (match_code "reg" "0") | ||
| 39 | + (match_operand 0 "memory_operand"))) | ||
| 40 | |||
| 41 | (define_predicate "call_insn_operand" | ||
| 42 | (ior (and (match_code "symbol_ref") | ||
| 43 | diff --git a/gcc/testsuite/gcc.target/arm/pr120351.c b/gcc/testsuite/gcc.target/arm/pr120351.c | ||
| 44 | new file mode 100644 | ||
| 45 | index 00000000000..d8e9d73275c | ||
| 46 | --- /dev/null | ||
| 47 | +++ b/gcc/testsuite/gcc.target/arm/pr120351.c | ||
| 48 | @@ -0,0 +1,47 @@ | ||
| 49 | +/* { dg-do assemble } */ | ||
| 50 | +/* { dg-require-effective-target arm_neon_ok } */ | ||
| 51 | +/* { dg-add-options arm_neon } */ | ||
| 52 | +/* { dg-additional-options "-O2" } */ | ||
| 53 | + | ||
| 54 | + | ||
| 55 | +typedef struct A | ||
| 56 | +{ | ||
| 57 | + int f1; | ||
| 58 | +} A; | ||
| 59 | + | ||
| 60 | +__inline void ref (A* x) | ||
| 61 | +{ | ||
| 62 | + __atomic_fetch_add(&x->f1, 1, 0); | ||
| 63 | +} | ||
| 64 | + | ||
| 65 | +typedef struct B | ||
| 66 | +{ | ||
| 67 | + A *d; | ||
| 68 | + int *ptr; | ||
| 69 | +} B; | ||
| 70 | + | ||
| 71 | +void insertOne (B*, B*); | ||
| 72 | + | ||
| 73 | +void init (B *); | ||
| 74 | +__inline void copy (B *p, B *q) | ||
| 75 | +{ | ||
| 76 | + p->d = q->d; | ||
| 77 | + p->ptr = q->ptr; | ||
| 78 | + ref (p->d); | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +__inline void emplace(B* x) | ||
| 82 | +{ | ||
| 83 | + B dummy; | ||
| 84 | + B _tmp; | ||
| 85 | + init (&dummy); | ||
| 86 | + copy (&_tmp, &dummy); | ||
| 87 | + insertOne(x, &_tmp); | ||
| 88 | +} | ||
| 89 | + | ||
| 90 | +void testing () | ||
| 91 | +{ | ||
| 92 | + B test; | ||
| 93 | + init (&test); | ||
| 94 | + emplace(&test); | ||
| 95 | +} | ||
