Skip to content

Commit adba40e

Browse files
authored
[Matrix] Assert that there's shapeinfo in Visit* (NFC). (#142416)
We should only call Visit* for instructions with shape info. Turn early exit into assert. PR: #142416
1 parent 705eedd commit adba40e

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,9 +2107,8 @@ class LowerMatrixIntrinsics {
21072107
/// Lower load instructions, if shape information is available.
21082108
bool VisitLoad(LoadInst *Inst, Value *Ptr, IRBuilder<> &Builder) {
21092109
auto I = ShapeMap.find(Inst);
2110-
if (I == ShapeMap.end())
2111-
return false;
2112-
2110+
assert(I != ShapeMap.end() &&
2111+
"must only visit instructions with shape info");
21132112
LowerLoad(Inst, Ptr, Inst->getAlign(),
21142113
Builder.getInt64(I->second.getStride()), Inst->isVolatile(),
21152114
I->second);
@@ -2119,9 +2118,8 @@ class LowerMatrixIntrinsics {
21192118
bool VisitStore(StoreInst *Inst, Value *StoredVal, Value *Ptr,
21202119
IRBuilder<> &Builder) {
21212120
auto I = ShapeMap.find(StoredVal);
2122-
if (I == ShapeMap.end())
2123-
return false;
2124-
2121+
assert(I != ShapeMap.end() &&
2122+
"must only visit instructions with shape info");
21252123
LowerStore(Inst, StoredVal, Ptr, Inst->getAlign(),
21262124
Builder.getInt64(I->second.getStride()), Inst->isVolatile(),
21272125
I->second);
@@ -2131,8 +2129,8 @@ class LowerMatrixIntrinsics {
21312129
/// Lower binary operators, if shape information is available.
21322130
bool VisitBinaryOperator(BinaryOperator *Inst) {
21332131
auto I = ShapeMap.find(Inst);
2134-
if (I == ShapeMap.end())
2135-
return false;
2132+
assert(I != ShapeMap.end() &&
2133+
"must only visit instructions with shape info");
21362134

21372135
Value *Lhs = Inst->getOperand(0);
21382136
Value *Rhs = Inst->getOperand(1);
@@ -2163,8 +2161,8 @@ class LowerMatrixIntrinsics {
21632161
/// Lower unary operators, if shape information is available.
21642162
bool VisitUnaryOperator(UnaryOperator *Inst) {
21652163
auto I = ShapeMap.find(Inst);
2166-
if (I == ShapeMap.end())
2167-
return false;
2164+
assert(I != ShapeMap.end() &&
2165+
"must only visit instructions with shape info");
21682166

21692167
Value *Op = Inst->getOperand(0);
21702168

0 commit comments

Comments
 (0)