Skip to content

Commit

Permalink
Fixes for switch statements on enums (iree-org#19140)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
bjacob authored Nov 13, 2024
1 parent 68c35d7 commit 1a28f8d
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ static std::tuple<Type, Type, Type> getABCElementTypes(MLIRContext *context,
return {f16, f16, f32};
}
}
assert(false && "unexpected enum value");
return {};
}

static OpaqueMmaLayout getOpaqueMFMALayout(MLIRContext *context,
Expand Down Expand Up @@ -667,6 +669,7 @@ MMASingleSubgroupLayout getSingleSubgroupLayout(MMAIntrinsic intrinsic,
case MMAIntrinsic::NV_WMMA_F16_16x16x16_F16:
return {};
}
assert(false && "unexpected enum value");
return {};
}

Expand Down Expand Up @@ -696,7 +699,6 @@ SmallVector<VirtualMMAIntrinsic> MMAAttr::getVirtualIntrinsics() const {
default:
return {};
}
return {};
}

// Generates amdgpu.mfma/wmma operation on the given inputs for this attribute
Expand Down Expand Up @@ -1281,7 +1283,6 @@ VirtualMMAAttr::getABCVectorTypes() const {
return {aType, bType, cType};
}
}
// This should not happen but just to make GCC happy.
assert(false && "unhandled virtual mma layout type.");
return {VectorType{}, VectorType{}, VectorType{}};
}
Expand All @@ -1301,7 +1302,6 @@ int64_t VirtualMMAAttr::getSubgroupSize() const {
return 64;
}
}
// This should not happen but just to make GCC happy.
assert(false && "unhandled virtual mma layout type.");
return 0;
}
Expand Down Expand Up @@ -1356,7 +1356,6 @@ int64_t VirtualMMAAttr::getUnrollK() const {
return 1;
}
}
// This should not happen but just to make GCC happy.
assert(false && "unhandled virtual mma layout type.");
return 0;
}
Expand Down Expand Up @@ -1424,7 +1423,6 @@ int64_t VirtualMMAAttr::getBlockSize() const {
return 1;
}
}
// This should not happen but just to make GCC happy.
assert(false && "unhandled virtual mma layout type.");
return 0;
}
Expand Down

0 comments on commit 1a28f8d

Please sign in to comment.