2024年9月30日 17:15,Alan Huang <mmpgouride@xxxxxxxxx> 写道:
2024年9月30日 16:57,Jonas Oberhauser <jonas.oberhauser@xxxxxxxxxxxxxxx> 写道:
Am 9/29/2024 um 12:26 AM schrieb Alan Huang:
2024年9月28日 23:55,Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx> wrote:
barrier_data(&b) prevents that.
The motivation for introducing ptr_eq() is indeed because the
compiler barrier is not sufficient to prevent the compiler from
using one pointer instead of the other.
I don't think one barrier_data can garantuee preventing this, because right after doing the comparison, the compiler still could do b=a.
In that case you would be guaranteed to use the value in b, but that value is not the value loaded into b originally but rather the value loaded into a, and hence your address dependency goes to the wrong load still.
After barrier_data(&b), *b will be loaded from memory, you mean even if *b is loaded from memory, the address dependency goes to the wrong load still?
Sorry, *b should b.