[Patch 1/2] Don't put out a call to memcpy for volatile struct operations
James Greenhalgh
james.greenhalgh@arm.com
Thu Aug 21 10:34:00 GMT 2014
Hi,
Andrew is quite right, we break the contract for volatile struct copies
if we start double copying bytes.
But, the generic code will call memcpy - at which point anything could
happen. So, we must not put out a call to memcpy if either our source or
destination operands are volatile. The same is true of memset, so also
disable that call for volatile operands, and add a fallback loop
implementation.
Bootstrapped on x86, Arm and AArch64 with no issues.
OK?
Thanks,
James
---
gcc/
2014-08-21 James Greenhalgh <james.greenhalgh@arm.com>
* expr.c (set_storage_via_loop): New.
(emit_block_move_hints): Do not call memcpy with volatile operands.
(emit_block_move_via_movmem): Clarify that targets do have to care
about volatile operands.
(clear_storage_hints): Do not call memset for volatile operands,
fall back to a loop implementation.
gcc/testsuite/
2014-08-21 James Greenhalgh <james.greenhalgh@arm.com>
* gcc.dg/large-volatile-struct-copy-1.c: New.
* gcc.dg/large-volatile-struct-set-1.c: Likewise.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Patch-1-2-Don-t-put-out-a-call-to-memcpy-for-volatil.patch
Type: text/x-patch
Size: 4804 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20140821/552ae010/attachment.bin>
More information about the Gcc-patches
mailing list