Skip to content

Commit 928fb49

Browse files
committed
1 parent d53cec1 commit 928fb49

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ endif()
159159
if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
160160
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=unused-variable -Werror=switch")
161161
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
162-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror-unused-variable -Werror-switch")
162+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=unused-variable -Werror=switch")
163163
endif()
164164

165165
# Bring in our cmake folder

lib/ArgKind.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ using namespace llvm;
3535

3636
namespace {
3737

38-
// Maps an LLVM type for a kernel argument to an argument kind.
39-
clspv::ArgKind GetArgKindForType(Type *type);
40-
4138
// Maps an LLVM type for a kernel argument to an argument
4239
// kind suitable for embedded reflection. The result is one of:
4340
// buffer - storage buffer
@@ -48,10 +45,6 @@ clspv::ArgKind GetArgKindForType(Type *type);
4845
// ro_image - sampled image
4946
// wo_image - storage image
5047
// sampler - sampler
51-
inline const char *GetArgKindNameForType(llvm::Type *type) {
52-
return GetArgKindName(GetArgKindForType(type));
53-
}
54-
5548
clspv::ArgKind GetArgKindForType(Type *type) {
5649
if (type->isPointerTy()) {
5750
if (clspv::IsSamplerType(type)) {
@@ -89,8 +82,8 @@ clspv::ArgKind GetArgKindForType(Type *type) {
8982
else
9083
return clspv::ArgKind::Pod;
9184
}
92-
errs() << "Unhandled case in clspv::GetArgKindNameForType: " << *type << "\n";
93-
llvm_unreachable("Unhandled case in clspv::GetArgKindNameForType");
85+
errs() << "Unhandled case in clspv::GetArgKindForType: " << *type << "\n";
86+
llvm_unreachable("Unhandled case in clspv::GetArgKindForType");
9487
return clspv::ArgKind::Buffer;
9588
}
9689
} // namespace

lib/SPIRVProducerPass.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -871,9 +871,11 @@ void SPIRVProducerPass::outputHeader() {
871871
case SPIRVVersion::SPIRV_1_6:
872872
minor = 6;
873873
break;
874+
#if !defined(__clang__)
874875
default:
875876
llvm_unreachable("unhandled spir-v version");
876877
break;
878+
#endif
877879
}
878880
uint32_t version = (1 << 16) | (minor << 8);
879881
binaryOut->write(reinterpret_cast<const char *>(&version), sizeof(version));
@@ -1216,6 +1218,7 @@ void SPIRVProducerPass::FindTypesForResourceVars() {
12161218
for (auto *elem_ty : cast<StructType>(type)->elements()) {
12171219
work_list.push_back(elem_ty);
12181220
}
1221+
break;
12191222
default:
12201223
// This type and its contained types don't get layout.
12211224
break;
@@ -1330,8 +1333,10 @@ SPIRVProducerPass::GetStorageClassForArgKind(clspv::ArgKind arg_kind) const {
13301333
case clspv::ArgKind::StorageImage:
13311334
case clspv::ArgKind::Sampler:
13321335
return spv::StorageClassUniformConstant;
1336+
#if !defined(__clang__)
13331337
default:
13341338
llvm_unreachable("Unsupported storage class for argument kind");
1339+
#endif
13351340
}
13361341
}
13371342

@@ -3323,8 +3328,8 @@ SPIRVProducerPass::GenerateImageInstruction(CallInst *Call,
33233328
const FunctionInfo &FuncInfo) {
33243329
SPIRVID RID;
33253330

3326-
auto GetExtendMask = [this](Type *sample_type,
3327-
bool is_int_image) -> uint32_t {
3331+
auto GetExtendMask = [](Type *sample_type,
3332+
bool is_int_image) -> uint32_t {
33283333
if (SpvVersion() >= SPIRVVersion::SPIRV_1_4 &&
33293334
sample_type->getScalarType()->isIntegerTy()) {
33303335
if (is_int_image)
@@ -4010,7 +4015,7 @@ SPIRVID SPIRVProducerPass::GenerateInstructionFromCall(CallInst *Call) {
40104015
// Generate one more instruction that uses the result of the extended
40114016
// instruction. Its result id is one more than the id of the
40124017
// extended instruction.
4013-
auto generate_extra_inst = [this, &Context, &Call,
4018+
auto generate_extra_inst = [this, &Call,
40144019
&RID](spv::Op opcode, Constant *constant) {
40154020
//
40164021
// Generate instruction like:
@@ -4974,7 +4979,7 @@ void SPIRVProducerPass::HandleDeferredInstruction() {
49744979
SPIRVInstruction *Placeholder = DeferredInsts[i].second;
49754980
SPIRVOperandVec Operands;
49764981

4977-
auto nextDeferred = [&i, &Inst, &DeferredInsts, &Placeholder]() {
4982+
auto nextDeferred = [&i, &DeferredInsts, &Placeholder]() {
49784983
++i;
49794984
assert(DeferredInsts.size() > i);
49804985
assert(Inst == DeferredInsts[i].first);
@@ -5456,10 +5461,12 @@ void SPIRVProducerPass::WriteWordCountAndOpcode(const SPIRVInstruction &Inst) {
54565461
void SPIRVProducerPass::WriteOperand(const SPIRVOperand &Op) {
54575462
SPIRVOperandType OpTy = Op.getType();
54585463
switch (OpTy) {
5464+
#if !defined(__clang__)
54595465
default: {
54605466
llvm_unreachable("Unsupported SPIRV Operand Type???");
54615467
break;
54625468
}
5469+
#endif
54635470
case SPIRVOperandType::NUMBERID: {
54645471
WriteOneWord(Op.getNumID());
54655472
break;
@@ -6501,9 +6508,11 @@ void SPIRVProducerPass::AddArgumentReflection(
65016508
case clspv::ArgKind::Sampler:
65026509
ext_inst = reflection::ExtInstArgumentSampler;
65036510
break;
6511+
#if !defined(__clang__)
65046512
default:
65056513
llvm_unreachable("Unhandled argument reflection");
65066514
break;
6515+
#endif
65076516
}
65086517
Ops << ext_inst << kernel_decl << getSPIRVInt32Constant(ordinal);
65096518

0 commit comments

Comments
 (0)