From 641098be5430c04e5ceb71f373c126d68a1f5869 Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Tue, 23 Mar 2021 14:28:39 -0700 Subject: [PATCH] Clean up some compiler warnings on my machine. --- lib/RefBackend/JITHelpers/JITModule.cpp | 10 +++++----- lib/RefBackend/LowerToLLVM.cpp | 9 ++------- lib/RefBackend/Runtime/Runtime.cpp | 6 +----- tools/npcomp-run-mlir/npcomp-run-mlir.cpp | 9 +++++---- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/lib/RefBackend/JITHelpers/JITModule.cpp b/lib/RefBackend/JITHelpers/JITModule.cpp index a533fbc46..693b8b1f0 100644 --- a/lib/RefBackend/JITHelpers/JITModule.cpp +++ b/lib/RefBackend/JITHelpers/JITModule.cpp @@ -76,15 +76,15 @@ static refbackrt::MutableArrayRef toRefbackrt(llvm::MutableArrayRef a) { } static std::string stringifyShape(refbackrt::ArrayRef extents) { - static constexpr char *kDynamicDimAsString = "?"; + static constexpr char kDynamicDimAsString[] = "?"; std::stringstream ss; ss << "("; - for (int i = 0; i < extents.size(); i++) { + for (int i = 0, e = extents.size(); i < e; i++) { if (extents[i] < 0) ss << kDynamicDimAsString; else ss << extents[i]; - if (i != extents.size() - 1) + if (i != e - 1) ss << "x"; } ss << ")"; @@ -135,8 +135,8 @@ JITModule::invoke(llvm::StringRef functionName, // Tag::kNone) currently without passing the ArgInfo structs down to the // Runtime level, so we deal with the output type creation here. for (int i = 0; i < metadata.numOutputs; i++) { - outputs[i] = std::move( - refbackrt::createRtValueFromOutputArgInfo(metadata.outputArgInfos[i])); + outputs[i] = + refbackrt::createRtValueFromOutputArgInfo(metadata.outputArgInfos[i]); } refbackrt::invoke( diff --git a/lib/RefBackend/LowerToLLVM.cpp b/lib/RefBackend/LowerToLLVM.cpp index 3e50aa9b6..8d1703400 100644 --- a/lib/RefBackend/LowerToLLVM.cpp +++ b/lib/RefBackend/LowerToLLVM.cpp @@ -307,7 +307,7 @@ createFuncDescriptorArray(ArrayRef funcMetadatas, Value inputDescriptorArray = builder.create(loc, inputDescriptorArrayTy); - for (int i = 0; i < funcMetadata.numInputs(); i++) { + for (int i = 0, e = funcMetadata.numInputs(); i < e; i++) { // Arg Type if (!funcMetadata.inputArgTypes().hasValue()) funcMetadata.emitError() @@ -365,7 +365,7 @@ createFuncDescriptorArray(ArrayRef funcMetadatas, Value outputDescriptorArray = builder.create(loc, outputDescriptorArrayTy); - for (int i = 0; i < funcMetadata.numOutputs(); i++) { + for (int i = 0, e = funcMetadata.numOutputs(); i < e; i++) { if (!funcMetadata.outputArgTypes().hasValue()) funcMetadata.emitError() << "numOutputs > 0 but there are no outputArgTypes?"; @@ -599,11 +599,6 @@ static Type getUnrankedMemrefDescriptorType(MLIRContext *context) { /*memorySpace=*/0)); } -static Type getDoubleType(MLIRContext *context) { - LLVMTypeConverter converter(context); - return converter.convertType(FloatType::getF64(context)); -} - static Type getFloatType(MLIRContext *context) { LLVMTypeConverter converter(context); return converter.convertType(FloatType::getF32(context)); diff --git a/lib/RefBackend/Runtime/Runtime.cpp b/lib/RefBackend/Runtime/Runtime.cpp index 28f4ab393..ff4c22f58 100644 --- a/lib/RefBackend/Runtime/Runtime.cpp +++ b/lib/RefBackend/Runtime/Runtime.cpp @@ -358,8 +358,6 @@ getExternalInputArgInfo(const refbackrt::InputDescriptor &inputDescriptor) { ret.argType = ArgType::kF64; ret.elementType = ElementType::NONE; break; - default: - assert(false && "need to update external internal map"); } // Extract shape information @@ -393,8 +391,6 @@ getExternalOutputArgInfo(const refbackrt::OutputDescriptor &outputDescriptor) { ret.argType = ArgType::kF64; ret.elementType = ElementType::NONE; break; - default: - assert(false && "need to update external internal map"); } // Extract shape information @@ -516,4 +512,4 @@ RtValue refbackrt::createRtValueFromOutputArgInfo(const OutputArgInfo &info) { return RtValue(); } } -} \ No newline at end of file +} diff --git a/tools/npcomp-run-mlir/npcomp-run-mlir.cpp b/tools/npcomp-run-mlir/npcomp-run-mlir.cpp index 643baf1b4..42b5036c2 100644 --- a/tools/npcomp-run-mlir/npcomp-run-mlir.cpp +++ b/tools/npcomp-run-mlir/npcomp-run-mlir.cpp @@ -96,8 +96,9 @@ static Type convertToMLIRType(refbackrt::ElementType type, Builder &builder) { switch (type) { case refbackrt::ElementType::F32: return builder.getF32Type(); + default: + llvm_unreachable("unsupported dtype"); } - llvm_unreachable("unsupported dtype"); } static RankedTensorType getCorrespondingMLIRTensorType(refbackrt::Tensor &tensor, @@ -122,13 +123,13 @@ static Attribute convertToMLIRAttribute(const refbackrt::RtValue &value, values.push_back(basePtr[i]); return DenseFPElementsAttr::get(type, values); } + default: + llvm_unreachable("unsupported element type"); } } else if (value.isFloat()) { return builder.getF32FloatAttr(value.toFloat()); - } else { - assert(false && "could not convert value to mlir attribute"); } - llvm_unreachable("unsupported dtype"); + llvm_unreachable("unsupported type"); } static void printOutput(const refbackrt::RtValue &value, llvm::raw_ostream &os) {