[PATCH]AArch64[GCC-8] Fix overflow in memcopy expansion on aarch64.

Tamar Christina tamar.christina@arm.com
Tue Nov 17 12:27:50 GMT 2020


Hi All,

This a partial backport for 0f801e0b6cc9f67c9a8983127e23161f6025c5b6 which fixes
a truncation error for the inline memcopy on AArch64 on GCC-8.

Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.

Ok for GCC-8?

gcc/ChangeLog:

	PR target/97535
	* config/aarch64/aarch64.c (aarch64_expand_movme): Use
	unsigned HOST_WIDE_INT.

gcc/testsuite/ChangeLog:

	PR target/97535
	* gcc.target/aarch64/pr97535.c: New test.

Thanks,
Tamar

--- inline copy of patch -- 
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 72c11e3565908916d42c2d6481b5177f6cc07a5e..8faadabc996232cb37d876c973aba7f9aff39b6f 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -15968,7 +15968,7 @@ aarch64_copy_one_block_and_progress_pointers (rtx *src, rtx *dst,
 bool
 aarch64_expand_movmem (rtx *operands)
 {
-  unsigned int n;
+  unsigned HOST_WIDE_INT n;
   rtx dst = operands[0];
   rtx src = operands[1];
   rtx base;
diff --git a/gcc/testsuite/gcc.target/aarch64/pr97535.c b/gcc/testsuite/gcc.target/aarch64/pr97535.c
new file mode 100644
index 0000000000000000000000000000000000000000..55586c6e5c5f74f0422ec52484459e31cda99cf0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr97535.c
@@ -0,0 +1,16 @@
+/* { dg-do compile { target { ! ilp32 } } } */
+
+#include <string.h>
+
+#define SIZE 0xFF00000000
+
+extern char raw_buffer[SIZE];
+
+void setRaw(const void *raw)
+{
+        memcpy(raw_buffer, raw, SIZE);
+}
+
+/* At any optimization level this should be a function call
+   and not inlined.  */
+/* { dg-final { scan-assembler "bl\tmemcpy" } } */


-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rb13803.patch
Type: text/x-diff
Size: 1133 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20201117/0e2a6165/attachment.bin>


More information about the Gcc-patches mailing list