[strub] improve handling of indirected volatile parms [PR112938]
commitc39dc5bb65c492fafc5a0fde83708b8d24e0338d
authorAlexandre Oliva <oliva@adacore.com>
Tue, 16 Apr 2024 04:24:59 +0000 (16 01:24 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Tue, 16 Apr 2024 04:24:59 +0000 (16 01:24 -0300)
tree80b299703b42816c6d77a6a38c6143388ed5085e
parent46d914d0e0b7e982627edb285c41c67cc4e640ac
[strub] improve handling of indirected volatile parms [PR112938]

The earlier patch for PR112938 arranged for volatile parms to be made
indirect in internal strub wrapped bodies.

The first problem that remained, more evident, was that the indirected
parameter remained volatile, despite the indirection, but it wasn't
regimplified, so indirecting it was malformed gimple.

Regimplifying turned out not to be needed.  The best course of action
was to drop the volatility from the by-reference parm, that was being
unexpectedly inherited from the original volatile parm.

That exposed another problem: the dereferences would then lose their
volatile status, so we had to bring volatile back to them.

for  gcc/ChangeLog

PR middle-end/112938
* ipa-strub.cc (pass_ipa_strub::execute): Drop volatility from
indirected parm.
(maybe_make_indirect): Restore volatility in dereferences.

for  gcc/testsuite/ChangeLog

PR middle-end/112938
* g++.dg/strub-internal-pr112938.cc: New.
gcc/ipa-strub.cc
gcc/testsuite/g++.dg/strub-internal-pr112938.cc [new file with mode: 0644]