Skip to content

Commit 1a28f8d

Browse files
authored
Fixes for switch statements on enums (iree-org#19140)
* Adds a missing `return`, to fix the GCC error flagged here: https://github.com/iree-org/iree/pull/19099/files/ab2aa4c5e9487c5f51effdc0d123c2f369dc9c41#r1840709707 * Adds some assertions on these error-case returns which are reachable but would only be reached if there is a bug in our program (as opposed to being triggerable by user input). * Drops some comments erroneously suggesting that it's GCC being difficult. Here, GCC is right and Clang is having a false-negative bug: llvm/llvm-project#115345 * Drops a redundant `return` after a `default: return`. Signed-off-by: Benoit Jacob <[email protected]>
1 parent 68c35d7 commit 1a28f8d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

compiler/src/iree/compiler/Codegen/Dialect/GPU/IR/IREEGPUAttrs.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ static std::tuple<Type, Type, Type> getABCElementTypes(MLIRContext *context,
302302
return {f16, f16, f32};
303303
}
304304
}
305+
assert(false && "unexpected enum value");
306+
return {};
305307
}
306308

307309
static OpaqueMmaLayout getOpaqueMFMALayout(MLIRContext *context,
@@ -667,6 +669,7 @@ MMASingleSubgroupLayout getSingleSubgroupLayout(MMAIntrinsic intrinsic,
667669
case MMAIntrinsic::NV_WMMA_F16_16x16x16_F16:
668670
return {};
669671
}
672+
assert(false && "unexpected enum value");
670673
return {};
671674
}
672675

@@ -696,7 +699,6 @@ SmallVector<VirtualMMAIntrinsic> MMAAttr::getVirtualIntrinsics() const {
696699
default:
697700
return {};
698701
}
699-
return {};
700702
}
701703

702704
// Generates amdgpu.mfma/wmma operation on the given inputs for this attribute
@@ -1281,7 +1283,6 @@ VirtualMMAAttr::getABCVectorTypes() const {
12811283
return {aType, bType, cType};
12821284
}
12831285
}
1284-
// This should not happen but just to make GCC happy.
12851286
assert(false && "unhandled virtual mma layout type.");
12861287
return {VectorType{}, VectorType{}, VectorType{}};
12871288
}
@@ -1301,7 +1302,6 @@ int64_t VirtualMMAAttr::getSubgroupSize() const {
13011302
return 64;
13021303
}
13031304
}
1304-
// This should not happen but just to make GCC happy.
13051305
assert(false && "unhandled virtual mma layout type.");
13061306
return 0;
13071307
}
@@ -1356,7 +1356,6 @@ int64_t VirtualMMAAttr::getUnrollK() const {
13561356
return 1;
13571357
}
13581358
}
1359-
// This should not happen but just to make GCC happy.
13601359
assert(false && "unhandled virtual mma layout type.");
13611360
return 0;
13621361
}
@@ -1424,7 +1423,6 @@ int64_t VirtualMMAAttr::getBlockSize() const {
14241423
return 1;
14251424
}
14261425
}
1427-
// This should not happen but just to make GCC happy.
14281426
assert(false && "unhandled virtual mma layout type.");
14291427
return 0;
14301428
}

0 commit comments

Comments
 (0)