Thank you! But I think I am still a bit confused what should we take out from this.
It seems to me that relying on optimiser when using Atomics is not guaranteed predictable performance which was one of the main goals of ownership features?
I don't know if this was discussed elsewhere, but is the goal of Atomics to be free of metadata access in a guaranteed and predictable way?
The only thing preventing Atomic from being used in @_noLocks or @_noAllocation is the deinit devirtualizer. Once that's turned on, you should be able to use atomics in those contexts without any problem.
Thank you @Alejandro! I think I am starting to understand, but few things are still not clear to me.
My current understanding is that deinit devirtualizer is guaranteed optimisation pass that is happening before performance diagnostic pass. Therefore, diagnostics are performed after problematic code is transformed. Is this right?
If yes, I have few questions:
In your godbolt snippet you used -O. Without -O, there are still metadata accesses. My understanding is that this should not be the case for mandatory optimisations?
I don't seem to be able to get @_noLocks to compile even with -O with -Xllvm -enable-deinit-devirtualizer.
Is there a plan to enable deinit devirtulizer by default?