fix(sync): keep TLoad WAW barriers for same buffer#843
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the WAW dependency exemption logic for TLoad operations on MTE2 pipelines, limiting the exemption to distinct direct subviews. The review feedback correctly identifies a potential correctness issue where nested subviews or subviews of different parent buffers could be incorrectly exempted, and provides a code suggestion to ensure they share the same parent buffer.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| static bool isDistinctDirectSubviewPair(const BaseMemInfo *lhs, | ||
| const BaseMemInfo *rhs) { | ||
| if (!lhs || !rhs) return false; | ||
| if (lhs->baseBuffer == rhs->baseBuffer) return false; | ||
| return isDirectSubviewBuffer(lhs->baseBuffer) && | ||
| isDirectSubviewBuffer(rhs->baseBuffer); | ||
| } |
There was a problem hiding this comment.
The current implementation of isDistinctDirectSubviewPair only checks if both buffers are defined by a subview operation and are distinct SSA values. However, this is insufficient and can lead to correctness issues in the following cases:
- Nested Subviews: If one subview is nested inside another (e.g.,
%view2 = pto.subview %view1), both are defined bySubViewOpand are distinct SSA values, so they would be incorrectly exempted from the WAW barrier even though they overlap. - Different Parent Buffers: If they are subviews of different parent buffers that happen to alias, they are not sibling subviews under the same parent, so the "PTOAS subview non-overlap contract" does not apply.
To ensure correctness, we should verify that both subviews are sibling subviews of the exact same parent buffer by checking that their source operands (the first operand of the subview operation) are identical.
static bool isDistinctDirectSubviewPair(const BaseMemInfo *lhs,
const BaseMemInfo *rhs) {
if (!lhs || !rhs || !lhs->baseBuffer || !rhs->baseBuffer) return false;
if (lhs->baseBuffer == rhs->baseBuffer) return false;
Operation *lhsOp = lhs->baseBuffer.getDefiningOp();
Operation *rhsOp = rhs->baseBuffer.getDefiningOp();
if (!lhsOp || !rhsOp) return false;
if (!isa<pto::SubViewOp, memref::SubViewOp>(lhsOp) ||
!isa<pto::SubViewOp, memref::SubViewOp>(rhsOp)) {
return false;
}
return lhsOp->getOperand(0) == rhsOp->getOperand(0);
}There was a problem hiding this comment.
Good catch, this is a real correctness hole. I tightened the exemption from "distinct direct subview values" to "distinct sibling subviews with the same direct source operand" so nested subviews, root-vs-view, different-parent aliases, and unknown provenance remain conservative and keep the MTE2 barrier. I also added a nested-subview regression in tload_waw_same_buffer_requires_mte2_barrier.pto. Updated in 15d2151.
fd89f60 to
15d2151
Compare
Codex Review该评论由 review 机器人自动更新。
SummaryPR #843 still leaves a real TLoad WAW hole: overlapping or otherwise unproven sibling subviews can still skip the required MTE2 barrier, so the fix is incomplete. Findings
The new |
Summary
Motivation
Design
Testing
Risk / Rollback