Skip to content

Commit db6cdac

Browse files
committed
!fixup improve docs.
1 parent a92c86b commit db6cdac

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,15 @@ class LowerMatrixIntrinsics {
480480
/// the result value of the instruction, with the only exceptions being store
481481
/// instructions and the matrix_column_major_store intrinsics. For those, the
482482
/// shape information indicates that those instructions should be lowered
483-
/// using shape information as well.
483+
/// using shape information as well. Note that extra care is needed when
484+
/// erasing or RAUW'ing a value that is present in ShapeMap. If the
485+
/// replacement is also a matrix operation, use
486+
/// updateShapeAndReplaceAllUsesWith to make sure the replacement is added to
487+
/// ShapeMap. We don't use ValueMap, as there are also cases where we do not
488+
/// want to add shape information for a replacement instruction. When directly
489+
/// erasing a value with an entry in ShapeMap, use
490+
/// eraseFromParentAndRemoveFromShapeMap to make sure ShapeMap is also updated
491+
/// accordingly.
484492
DenseMap<Value *, ShapeInfo> ShapeMap;
485493

486494
/// List of instructions to remove. While lowering, we are not replacing all
@@ -743,6 +751,8 @@ class LowerMatrixIntrinsics {
743751
return Operation(T0, Shape0.t(), T1, Shape1.t());
744752
}
745753

754+
/// Erase \p Inst from both ShapeMap (if an entry exists) and erase \p Inst
755+
/// itself.
746756
void eraseFromParentAndRemoveFromShapeMap(Instruction *Inst) {
747757
auto Iter = ShapeMap.find(Inst);
748758
if (Iter != ShapeMap.end())
@@ -763,6 +773,8 @@ class LowerMatrixIntrinsics {
763773
eraseFromParentAndRemoveFromShapeMap(Inst);
764774
}
765775

776+
/// Add a new entry to ShapeMap for \p New with \p Old's shape info, erase the
777+
/// entry for \p Old and replace all uses of \p Old with \p New.
766778
void updateShapeAndReplaceAllUsesWith(Instruction &Old, Value *New) {
767779
// We need to remove Old from the ShapeMap otherwise RAUW will replace it
768780
// with New. We should only add New it it supportsShapeInfo so we insert

0 commit comments

Comments
 (0)