Or, when do we need LoadStore
barrier?
According to Doug Lea,
(LoadStore) ensures that Load1’s data are loaded before all data associated with Store2 and subsequent store instructions are flushed
So, it seems that the result of the load
is only available after the store
is finished.
After all, the result of the load
could be at stale status until the last moment before the store finished.
So in my opinion, this barrier only works for the following pattern:
load r1 [x1]; // load operation
#LoadStore barrier
store [y1] r2; // store operation
...
//other operations really need newest [x1]
...
Is this example correct? Please correct me if not.
Also, can you provide a specific situation where this pattern occurs?
I really appreciate any advice or suggestion.