From 8631c115905ea0662db3d69c16f1edaf9292437f Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Tue, 26 Apr 2022 09:46:50 -0500 Subject: [PATCH] [SPIRV][NFC] Fix warnings for switch cases Switch statements that cover all cases should not have a `default` case. When a switch covers all cases and includes a `default` case, clang emits a diagnostic. Omitting the `default` case allows the compiler to instead emit a diagnostic on unhandled enum values. This change removes default cases from all the places that they shouldn't be, and adds a missing enum case for one switch statement that wasn't covering all values. --- .../SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp | 24 +------------------ .../Target/SPIRV/SPIRVInstructionSelector.cpp | 1 - 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp index b8bd536c2524..1a3e35a5f901 100644 --- a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp +++ b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp @@ -159,7 +159,6 @@ StringRef getCapabilityName(Capability e) { CASE(Capability, FragmentDensityEXT) CASE(Capability, PhysicalStorageBufferAddressesEXT) CASE(Capability, CooperativeMatrixNV) - default: break; } llvm_unreachable("Unexpected operand"); @@ -173,7 +172,6 @@ StringRef getSourceLanguageName(SourceLanguage e) { CASE(SourceLanguage, OpenCL_C) CASE(SourceLanguage, OpenCL_CPP) CASE(SourceLanguage, HLSL) - default: break; } llvm_unreachable("Unexpected operand"); @@ -196,7 +194,6 @@ StringRef getExecutionModelName(ExecutionModel e) { CASE(ExecutionModel, ClosestHitNV) CASE(ExecutionModel, MissNV) CASE(ExecutionModel, CallableNV) - default: break; } llvm_unreachable("Unexpected operand"); @@ -208,7 +205,6 @@ StringRef getAddressingModelName(AddressingModel e) { CASE(AddressingModel, Physical32) CASE(AddressingModel, Physical64) CASE(AddressingModel, PhysicalStorageBuffer64EXT) - default: break; } llvm_unreachable("Unexpected operand"); @@ -220,7 +216,6 @@ StringRef getMemoryModelName(MemoryModel e) { CASE(MemoryModel, GLSL450) CASE(MemoryModel, OpenCL) CASE(MemoryModel, VulkanKHR) - default: break; } llvm_unreachable("Unexpected operand"); @@ -247,6 +242,7 @@ StringRef getExecutionModeName(ExecutionMode e) { CASE(ExecutionMode, LocalSize) CASE(ExecutionMode, LocalSizeHint) CASE(ExecutionMode, InputPoints) + CASE(ExecutionMode, InputLines) CASE(ExecutionMode, InputLinesAdjacency) CASE(ExecutionMode, Triangles) CASE(ExecutionMode, InputTrianglesAdjacency) @@ -276,7 +272,6 @@ StringRef getExecutionModeName(ExecutionMode e) { CASE(ExecutionMode, DerivativeGroupQuadsNV) CASE(ExecutionMode, DerivativeGroupLinearNV) CASE(ExecutionMode, OutputTrianglesNV) - default: break; } llvm_unreachable("Unexpected operand"); @@ -304,7 +299,6 @@ StringRef getStorageClassName(StorageClass e) { CASE(StorageClass, IncomingRayPayloadNV) CASE(StorageClass, ShaderRecordBufferNV) CASE(StorageClass, PhysicalStorageBufferEXT) - default: break; } llvm_unreachable("Unexpected operand"); @@ -319,7 +313,6 @@ StringRef getDimName(Dim dim) { CASE_SUF(Dim, DIM, Rect) CASE_SUF(Dim, DIM, Buffer) CASE_SUF(Dim, DIM, SubpassData) - default: break; } llvm_unreachable("Unexpected operand"); @@ -332,7 +325,6 @@ StringRef getSamplerAddressingModeName(SamplerAddressingMode e) { CASE(SamplerAddressingMode, Clamp) CASE(SamplerAddressingMode, Repeat) CASE(SamplerAddressingMode, RepeatMirrored) - default: break; } llvm_unreachable("Unexpected operand"); @@ -342,7 +334,6 @@ StringRef getSamplerFilterModeName(SamplerFilterMode e) { switch (e) { CASE(SamplerFilterMode, Nearest) CASE(SamplerFilterMode, Linear) - default: break; } llvm_unreachable("Unexpected operand"); @@ -390,7 +381,6 @@ StringRef getImageFormatName(ImageFormat e) { CASE(ImageFormat, Rg8ui) CASE(ImageFormat, R16ui) CASE(ImageFormat, R8ui) - default: break; } llvm_unreachable("Unexpected operand"); @@ -418,7 +408,6 @@ StringRef getImageChannelOrderName(ImageChannelOrder e) { CASE(ImageChannelOrder, sRGBA) CASE(ImageChannelOrder, sBGRA) CASE(ImageChannelOrder, ABGR) - default: break; } llvm_unreachable("Unexpected operand"); @@ -443,7 +432,6 @@ StringRef getImageChannelDataTypeName(ImageChannelDataType e) { CASE(ImageChannelDataType, Float) CASE(ImageChannelDataType, UnormInt24) CASE(ImageChannelDataType, UnormInt101010_2) - default: break; } llvm_unreachable("Unexpected operand"); @@ -585,7 +573,6 @@ StringRef getFPRoundingModeName(FPRoundingMode e) { CASE(FPRoundingMode, RTZ) CASE(FPRoundingMode, RTP) CASE(FPRoundingMode, RTN) - default: break; } llvm_unreachable("Unexpected operand"); @@ -595,7 +582,6 @@ StringRef getLinkageTypeName(LinkageType e) { switch (e) { CASE(LinkageType, Export) CASE(LinkageType, Import) - default: break; } llvm_unreachable("Unexpected operand"); @@ -606,7 +592,6 @@ StringRef getAccessQualifierName(AccessQualifier e) { CASE(AccessQualifier, ReadOnly) CASE(AccessQualifier, WriteOnly) CASE(AccessQualifier, ReadWrite) - default: break; } llvm_unreachable("Unexpected operand"); @@ -622,7 +607,6 @@ StringRef getFunctionParameterAttributeName(FunctionParameterAttribute e) { CASE(FunctionParameterAttribute, NoCapture) CASE(FunctionParameterAttribute, NoWrite) CASE(FunctionParameterAttribute, NoReadWrite) - default: break; } llvm_unreachable("Unexpected operand"); @@ -692,7 +676,6 @@ StringRef getDecorationName(Decoration e) { CASE(Decoration, UserSemantic) CASE(Decoration, RestrictPointerEXT) CASE(Decoration, AliasedPointerEXT) - default: break; } llvm_unreachable("Unexpected operand"); @@ -791,7 +774,6 @@ StringRef getBuiltInName(BuiltIn e) { CASE(BuiltIn, HitTNV) CASE(BuiltIn, HitKindNV) CASE(BuiltIn, IncomingRayFlagsNV) - default: break; } llvm_unreachable("Unexpected operand"); @@ -1049,7 +1031,6 @@ StringRef getScopeName(Scope e) { CASE(Scope, Subgroup) CASE(Scope, Invocation) CASE(Scope, QueueFamilyKHR) - default: break; } llvm_unreachable("Unexpected operand"); @@ -1064,7 +1045,6 @@ StringRef getGroupOperationName(GroupOperation e) { CASE(GroupOperation, PartitionedReduceNV) CASE(GroupOperation, PartitionedInclusiveScanNV) CASE(GroupOperation, PartitionedExclusiveScanNV) - default: break; } llvm_unreachable("Unexpected operand"); @@ -1075,7 +1055,6 @@ StringRef getKernelEnqueueFlagsName(KernelEnqueueFlags e) { CASE(KernelEnqueueFlags, NoWait) CASE(KernelEnqueueFlags, WaitKernel) CASE(KernelEnqueueFlags, WaitWorkGroup) - default: break; } llvm_unreachable("Unexpected operand"); @@ -1085,7 +1064,6 @@ StringRef getKernelProfilingInfoName(KernelProfilingInfo e) { switch (e) { CASE(KernelProfilingInfo, None) CASE(KernelProfilingInfo, CmdExecTime) - default: break; } llvm_unreachable("Unexpected operand"); diff --git a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp index 0334d87a93c2..367fca0a0687 100644 --- a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp +++ b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp @@ -389,7 +389,6 @@ static SPIRV::MemorySemantics getMemSemantics(AtomicOrdering Ord) { case AtomicOrdering::Unordered: case AtomicOrdering::Monotonic: case AtomicOrdering::NotAtomic: - default: return SPIRV::MemorySemantics::None; } }