[Bug d/110516] core.volatile.volatileLoad discarded if result is unused
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Jul 2 01:42:52 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110516
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:
https://gcc.gnu.org/g:da7a10ea9245d7461253495698873891ffc20666
commit r11-10890-gda7a10ea9245d7461253495698873891ffc20666
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Sun Jul 2 03:24:53 2023 +0200
d: Fix core.volatile.volatileLoad discarded if result is unused
The first pass of code generation in the D front-end splits up all
compound expressions and discards expressions that have no side effects.
This included calls to the `volatileLoad' intrinsic if its result was
not used, causing such calls to be eliminated from the program.
We already set TREE_THIS_VOLATILE on the expression, however the
tree documentation says if this bit is set in an expression, so is
TREE_SIDE_EFFECTS. So set TREE_SIDE_EFFECTS on the expression too.
This prevents any early discarding from occuring.
PR d/110516
gcc/d/ChangeLog:
* intrinsics.cc (expand_volatile_load): Set TREE_SIDE_EFFECTS on
the
expanded expression.
(expand_volatile_store): Likewise.
gcc/testsuite/ChangeLog:
* gdc.dg/torture/pr110516a.d: New test.
* gdc.dg/torture/pr110516b.d: New test.
(cherry picked from commit 80ae426a195a0d035640a6301da833564deade52)
More information about the Gcc-bugs
mailing list