[mlir] Cleanup: Fix warnings in MLIR

Tested with gcc-10. Other compilers may generate additional warnings. This does not fix all warnings. There are a few extra ones in LLVMCore and MLIR.

* `OpEmitter::getAttrNameIndex`: -Wunused-function (function is private and not used anywhere)
* `PrintOpPass` copy constructor: -Wextra ("Base class should be explicitly initialized in the copy constructor")
* `LegalizeForLLVMExport.cpp`: -Woverflow (overflow is expected, silence warning by making the cast explicit)

Differential Revision: https://reviews.llvm.org/D107525
This commit is contained in:
Matthias Springer
2021-08-06 10:28:12 +09:00
parent e6a3944ea9
commit 66b1e629d8
3 changed files with 2 additions and 13 deletions

View File

@@ -115,7 +115,7 @@ struct DotOpConversion : public ConvertOpToLLVMPattern<DotOp> {
auto opType = adaptor.a().getType();
Type llvmIntType = IntegerType::get(&getTypeConverter()->getContext(), 8);
// Dot product of all elements, broadcasted to all elements.
auto attr = rewriter.getI8IntegerAttr(0xff);
auto attr = rewriter.getI8IntegerAttr(static_cast<int8_t>(0xff));
Value scale =
rewriter.create<LLVM::ConstantOp>(op.getLoc(), llvmIntType, attr);
rewriter.replaceOpWithNewOp<DotIntrOp>(op, opType, adaptor.a(), adaptor.b(),

View File

@@ -71,7 +71,7 @@ public:
class PrintOpPass : public ViewOpGraphPassBase<PrintOpPass> {
public:
PrintOpPass(raw_ostream &os) : os(os) {}
PrintOpPass(const PrintOpPass &o) : os(o.os.getOStream()) {}
PrintOpPass(const PrintOpPass &o) : PrintOpPass(o.os.getOStream()) {}
void runOnOperation() override {
emitGraph([&]() {

View File

@@ -341,10 +341,6 @@ private:
// Generate methods for accessing the attribute names of this operation.
void genAttrNameGetters();
// Return the index of the given attribute name. This is a relative ordering
// for this name, used in attribute getters.
unsigned getAttrNameIndex(StringRef attrName) const;
// Generates the OpAsmOpInterface for this operation if possible.
void genOpAsmInterface();
@@ -750,13 +746,6 @@ void OpEmitter::genAttrNameGetters() {
}
}
unsigned OpEmitter::getAttrNameIndex(StringRef attrName) const {
auto it = attributeNames.find(attrName);
assert(it != attributeNames.end() && "expected attribute name to have been "
"registered in genAttrNameGetters");
return it->second;
}
void OpEmitter::genAttrGetters() {
FmtContext fctx;
fctx.withBuilder("::mlir::Builder((*this)->getContext())");