[mlir][sparse] Updating TensorExp ctor to catch unknown TensorExp::Kind
authorwren romano <2998727+wrengr@users.noreply.github.com>
Fri, 24 Mar 2023 21:34:20 +0000 (14:34 -0700)
committerwren romano <2998727+wrengr@users.noreply.github.com>
Fri, 24 Mar 2023 22:08:13 +0000 (15:08 -0700)
Depends On D146562

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D146673

mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp

index 9b39fd0..b3ff608 100644 (file)
@@ -105,14 +105,14 @@ TensorExp::TensorExp(Kind k, unsigned x, ExprId y, Value v, Operation *o)
   case TensorExp::Kind::kTensor:
     assert(x != kInvalidId && y == kInvalidId && !v && !o);
     tensor = x;
-    break;
+    return;
   case TensorExp::Kind::kInvariant:
     assert(x == kInvalidId && y == kInvalidId && v && !o);
-    break;
+    return;
   case TensorExp::Kind::kLoopVar:
     assert(x != kInvalidId && y == kInvalidId && !v && !o);
     loop = x;
-    break;
+    return;
   // Unary operations.
   case TensorExp::Kind::kAbsF:
   case TensorExp::Kind::kAbsC:
@@ -137,7 +137,7 @@ TensorExp::TensorExp(Kind k, unsigned x, ExprId y, Value v, Operation *o)
     assert(x != kInvalidId && y == kInvalidId && !v && !o);
     children.e0 = x;
     children.e1 = y;
-    break;
+    return;
   case TensorExp::Kind::kTruncF:
   case TensorExp::Kind::kExtF:
   case TensorExp::Kind::kCastFS:
@@ -152,20 +152,20 @@ TensorExp::TensorExp(Kind k, unsigned x, ExprId y, Value v, Operation *o)
     assert(x != kInvalidId && y == kInvalidId && v && !o);
     children.e0 = x;
     children.e1 = y;
-    break;
+    return;
   case TensorExp::Kind::kBinaryBranch:
   case TensorExp::Kind::kSelect:
     assert(x != kInvalidId && y == kInvalidId && !v && o);
     children.e0 = x;
     children.e1 = y;
-    break;
+    return;
   case TensorExp::Kind::kUnary:
     // No assertion on y can be made, as the branching paths involve both
     // a unary (`mapSet`) and binary (`disjSet`) pathway.
     assert(x != kInvalidId && !v && o);
     children.e0 = x;
     children.e1 = y;
-    break;
+    return;
   // Binary operations.
   case TensorExp::Kind::kMulF:
   case TensorExp::Kind::kMulC:
@@ -189,14 +189,15 @@ TensorExp::TensorExp(Kind k, unsigned x, ExprId y, Value v, Operation *o)
     assert(x != kInvalidId && y != kInvalidId && !v && !o);
     children.e0 = x;
     children.e1 = y;
-    break;
+    return;
   case TensorExp::Kind::kBinary:
   case TensorExp::Kind::kReduce:
     assert(x != kInvalidId && y != kInvalidId && !v && o);
     children.e0 = x;
     children.e1 = y;
-    break;
+    return;
   }
+  llvm_unreachable("unexpected kind");
 }
 
 LatPoint::LatPoint(const BitVector &bits, ExprId e) : bits(bits), exp(e) {}