I'm troubled that 'write-only variables are ... optimized out'. That means, no more embedded trace buffers in memory dumps? I've used that for decades to debug intermittent problems. Maybe there's some way to tag necessary write-only variables...
volatile works, asm works, and it's usually not hard to trick the optimizer.
I mean, the goal of an optimizer is literally not to be able to be tricked into doing work it doesn't have to.