Repository navigation
Keep volatile indirections of promoted struct fields - #136940
Conversation
|
Azure Pipelines: Successfully started running 5 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
I don't agree. These tests are much too fragile, relying on exact promotion heuristics that are going to be changing in this release. I don't think the test is needed. I would be ok with outerloop test that validates that a volatile load was not dropped by testing for a race. |
FWIW, this used to have quite significant diffs around structs that were later proved to be not exposed. Looks like something changed since the diffs are very minimal now, however. |
The checks count loads and pass whether or not the struct is promoted. The only fragility I see here is the acquire instruction regex. Which heuristic do you think will break it? I have also added an outerloop race test next to the volatile class field tests. |
We do not have good experiences with disassembly tests for anything but validating the absence of instructions or exact expected instruction foldings. A few things that can go wrong in your patterns:
I would rather see the behavior validated, whenever possible.
Is it possible to write this test in a way where we can have a signal that we would have expected to see differing values? I would personally suggest just not adding a test. |
f56e07b to
975f0c9
Compare
|
Dropped the tests, under mild protest ;) |
|
Would a test doing int first = shared.Value;
int changed = shared.Changed;
int second = shared.Value;
if (changed > first && second < changed)
Assert.Fail(...);from one thread, and for (int i = 0; i < int.MaxValue; i++)
{
shared->Value = i;
shared->Changed = i;
}from another be able to show the failure? That is the kind of test I would be ok with adding. |
|
That shape does not catch the issue. Without the volatile flag the JIT hoists or reorders the reads around Changed, so all three variants I tried pass on main. The disagreement test I had earlier fails on main by timeout and passes with the fix in milliseconds. |
|
/ba-g Failure is #136758 |
Fixes #136936, a longstanding bug that was kept around as a quirk for zero-diffs at the time. Disasm tests here are a bit fragile, though arm has stabilized its instructions around this now, but I'd rather have them than not.