[patch] Make memory copy functions scalar storage order barriers

Eric Botcazou botcazou@adacore.com
Wed Jul 8 08:52:58 GMT 2020


[Sorry for dropping the ball here]

> But GCC does not see the reverse storage order in mymemcpy so
> it happily folds the memcpy inside it, inlines the result and then?

You're right, this breaks, hence the following alternative: either we prevent 
inlining from happening, or we declare that this is simply not supported and 
warn (there is a -Wscalar-storage-order warning for problematic constructs).

I didn't find any existing infrastructure for the former and I'm not sure it's 
worth adding, so the attached implements the latter.  Tested on x86-64/Linux.


2020-07-08  Eric Botcazou  <ebotcazou@adacore.com>

c-family/
	* c.opt (Wscalar-storage-order): Add warn_scalar_storage_order variable.


2020-07-08  Eric Botcazou  <ebotcazou@adacore.com>

c/
	* c-typeck.c (convert_for_assignment): If -Wscalar-storage-order is set,
	warn for conversions between pointers that point to incompatible scalar
	storage orders.


2020-07-08  Eric Botcazou  <ebotcazou@adacore.com>

	* gimple-fold.c (gimple_fold_builtin_memory_op): Do not fold if either
	type has reverse scalar storage order.
	* tree-ssa-sccvn.c (vn_reference_lookup_3): Do not propagate through a
	memory copy if either type has reverse scalar storage order.


2020-07-08  Eric Botcazou  <ebotcazou@adacore.com>

testsuite/
	* gcc.dg/sso-11.c: New test.
	* gcc.dg/sso/sso.exp: Pass -Wno-scalar-storage-order.
	* gcc.dg/sso/memcpy-1.c: New test.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-patch
Size: 10598 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200708/155753a2/attachment.bin>


More information about the Gcc-patches mailing list