diff --git a/compiler-rt/test/builtins/Unit/atomic_test.c b/compiler-rt/test/builtins/Unit/atomic_test.c --- a/compiler-rt/test/builtins/Unit/atomic_test.c +++ b/compiler-rt/test/builtins/Unit/atomic_test.c @@ -25,7 +25,7 @@ // functions themselves, regardless of how the builtins are lowered. We need to // use asm labels because we can't redeclare the builtins. -void __atomic_load_c(int size, const void *src, void *dest, +void __atomic_load_c(int size, void *src, void *dest, int model) asm("__atomic_load"); uint8_t __atomic_load_1(uint8_t *src, int model); @@ -177,16 +177,22 @@ // Test with aligned data. for (int n = 1; n <= LEN(data); n++) { + // Note: __atomic_load requires a writable mapping, so we copy the data. + __attribute__((aligned(16))) char src[LEN(data)] = {0}; __attribute__((aligned(16))) char dst[LEN(data)] = {0}; - __atomic_load_c(n, data, dst, model); + memcpy(src, data, sizeof(src)); + __atomic_load_c(n, src, dst, model); if (memcmp(dst, data, n) != 0) abort(); } // Test with unaligned data. for (int n = 1; n < LEN(data); n++) { + // Note: __atomic_load requires a writable mapping, so we copy the data. + __attribute__((aligned(16))) char src[LEN(data)] = {0}; __attribute__((aligned(16))) char dst[LEN(data)] = {0}; - __atomic_load_c(n, data + 1, dst + 1, model); + memcpy(src, data, sizeof(src)); + __atomic_load_c(n, src + 1, dst + 1, model); if (memcmp(dst + 1, data + 1, n) != 0) abort(); }