@@ -221,8 +221,7 @@ DominatedAccessAnalysis::Result DominatedAccessAnalysis::analyze() && {
221
221
}
222
222
if (isa<BeginUnpairedAccessInst>(&I)) {
223
223
// Unpaired accesses could be tracked, but are ignored because they are
224
- // mostly irrelevant and hard to test. Rather than making the results
225
- // conservative, we return an empty result.
224
+ // mostly irrelevant and hard to test. Completely bail on this function.
226
225
result.accessMap .clear ();
227
226
return std::move (result);
228
227
}
@@ -456,6 +455,21 @@ bool DominatedAccessRemoval::checkDominatedAccess(
456
455
// non-distinct read and isn't contained by another non-distinct read. The
457
456
// containsRead and isInner flags from in DominatedAccessAnalysis answer this
458
457
// conservatively.
458
+ //
459
+ // Note: Promoting an earlier access to a modify could cause a program to
460
+ // trap when optimized even if the unoptimized program does not trap; the
461
+ // original modify access may be on an unreachable code path. This is acceptable
462
+ // because:
463
+ //
464
+ // (a) in theory, exclusivity violations do not need to be executed to be
465
+ // considered program violations. Promoting the access does not introduce any
466
+ // new conflict where one didn't already exist statically. Catching these
467
+ // violations at runtime is only an implementation compromise, and the more true
468
+ // violations are caught, the better.
469
+ //
470
+ // (b) in practice, this situation is so exceedingly unlikely that it won't
471
+ // cause any pervasive usability problem where programs have stronger
472
+ // enforcement only when optimized.
459
473
bool DominatedAccessRemoval::optimizeDominatedAccess (
460
474
BeginAccessInst *BAI, DomAccessedStorage currAccessInfo,
461
475
const DominatingAccess &domAccess) {
0 commit comments