-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Clang warning diagnostics #835
Open
jgavris
wants to merge
1
commit into
google:main
Choose a base branch
from
ButterflyNetwork:clang-warnings
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,9 +35,6 @@ using namespace llvm; | |
|
||
namespace { | ||
|
||
// Maps an LLVM type for a kernel argument to an argument kind. | ||
clspv::ArgKind GetArgKindForType(Type *type); | ||
|
||
// Maps an LLVM type for a kernel argument to an argument | ||
// kind suitable for embedded reflection. The result is one of: | ||
// buffer - storage buffer | ||
|
@@ -48,10 +45,6 @@ clspv::ArgKind GetArgKindForType(Type *type); | |
// ro_image - sampled image | ||
// wo_image - storage image | ||
// sampler - sampler | ||
inline const char *GetArgKindNameForType(llvm::Type *type) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No callers |
||
return GetArgKindName(GetArgKindForType(type)); | ||
} | ||
|
||
clspv::ArgKind GetArgKindForType(Type *type) { | ||
if (type->isPointerTy()) { | ||
if (clspv::IsSamplerType(type)) { | ||
|
@@ -89,8 +82,8 @@ clspv::ArgKind GetArgKindForType(Type *type) { | |
else | ||
return clspv::ArgKind::Pod; | ||
} | ||
errs() << "Unhandled case in clspv::GetArgKindNameForType: " << *type << "\n"; | ||
llvm_unreachable("Unhandled case in clspv::GetArgKindNameForType"); | ||
errs() << "Unhandled case in clspv::GetArgKindForType: " << *type << "\n"; | ||
llvm_unreachable("Unhandled case in clspv::GetArgKindForType"); | ||
return clspv::ArgKind::Buffer; | ||
} | ||
} // namespace | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -871,9 +871,11 @@ void SPIRVProducerPass::outputHeader() { | |
case SPIRVVersion::SPIRV_1_6: | ||
minor = 6; | ||
break; | ||
#if !defined(__clang__) | ||
default: | ||
llvm_unreachable("unhandled spir-v version"); | ||
break; | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For Clang / LLVM, these probably don't make sense anymore as they are covered, if the warnings are kept as errors. |
||
} | ||
uint32_t version = (1 << 16) | (minor << 8); | ||
binaryOut->write(reinterpret_cast<const char *>(&version), sizeof(version)); | ||
|
@@ -1216,6 +1218,7 @@ void SPIRVProducerPass::FindTypesForResourceVars() { | |
for (auto *elem_ty : cast<StructType>(type)->elements()) { | ||
work_list.push_back(elem_ty); | ||
} | ||
break; | ||
default: | ||
// This type and its contained types don't get layout. | ||
break; | ||
|
@@ -1330,8 +1333,10 @@ SPIRVProducerPass::GetStorageClassForArgKind(clspv::ArgKind arg_kind) const { | |
case clspv::ArgKind::StorageImage: | ||
case clspv::ArgKind::Sampler: | ||
return spv::StorageClassUniformConstant; | ||
#if !defined(__clang__) | ||
default: | ||
llvm_unreachable("Unsupported storage class for argument kind"); | ||
#endif | ||
} | ||
} | ||
|
||
|
@@ -3323,8 +3328,8 @@ SPIRVProducerPass::GenerateImageInstruction(CallInst *Call, | |
const FunctionInfo &FuncInfo) { | ||
SPIRVID RID; | ||
|
||
auto GetExtendMask = [this](Type *sample_type, | ||
bool is_int_image) -> uint32_t { | ||
auto GetExtendMask = [](Type *sample_type, | ||
bool is_int_image) -> uint32_t { | ||
if (SpvVersion() >= SPIRVVersion::SPIRV_1_4 && | ||
sample_type->getScalarType()->isIntegerTy()) { | ||
if (is_int_image) | ||
|
@@ -4010,7 +4015,7 @@ SPIRVID SPIRVProducerPass::GenerateInstructionFromCall(CallInst *Call) { | |
// Generate one more instruction that uses the result of the extended | ||
// instruction. Its result id is one more than the id of the | ||
// extended instruction. | ||
auto generate_extra_inst = [this, &Context, &Call, | ||
auto generate_extra_inst = [this, &Call, | ||
&RID](spv::Op opcode, Constant *constant) { | ||
// | ||
// Generate instruction like: | ||
|
@@ -4974,7 +4979,7 @@ void SPIRVProducerPass::HandleDeferredInstruction() { | |
SPIRVInstruction *Placeholder = DeferredInsts[i].second; | ||
SPIRVOperandVec Operands; | ||
|
||
auto nextDeferred = [&i, &Inst, &DeferredInsts, &Placeholder]() { | ||
auto nextDeferred = [&i, &DeferredInsts, &Placeholder]() { | ||
++i; | ||
assert(DeferredInsts.size() > i); | ||
assert(Inst == DeferredInsts[i].first); | ||
|
@@ -5456,10 +5461,12 @@ void SPIRVProducerPass::WriteWordCountAndOpcode(const SPIRVInstruction &Inst) { | |
void SPIRVProducerPass::WriteOperand(const SPIRVOperand &Op) { | ||
SPIRVOperandType OpTy = Op.getType(); | ||
switch (OpTy) { | ||
#if !defined(__clang__) | ||
default: { | ||
llvm_unreachable("Unsupported SPIRV Operand Type???"); | ||
break; | ||
} | ||
#endif | ||
case SPIRVOperandType::NUMBERID: { | ||
WriteOneWord(Op.getNumID()); | ||
break; | ||
|
@@ -6501,9 +6508,11 @@ void SPIRVProducerPass::AddArgumentReflection( | |
case clspv::ArgKind::Sampler: | ||
ext_inst = reflection::ExtInstArgumentSampler; | ||
break; | ||
#if !defined(__clang__) | ||
default: | ||
llvm_unreachable("Unhandled argument reflection"); | ||
break; | ||
#endif | ||
} | ||
Ops << ext_inst << kernel_decl << getSPIRVInt32Constant(ordinal); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/Users/jgavris/code/clspv/lib/ReplaceOpenCLBuiltinPass.cpp:3346:25: warning: hexadecimal floating literals are a C++17 feature [-Wc++17-extensions] const double k_pi = 0x1.921fb54442d18p+1;