Skip to content

Commit

Permalink
suppress GCC false positive
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingerZhu committed Nov 4, 2024
1 parent c0adc04 commit a7d6245
Showing 1 changed file with 12 additions and 46 deletions.
58 changes: 12 additions & 46 deletions src/Conversion/ConvertFuncToGCCJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
using namespace mlir;
using namespace mlir::gccjit;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
namespace {

class GCCJITFunctionRewriter {
Expand Down Expand Up @@ -241,60 +243,23 @@ void ConvertFuncToGCCJITPass::runOnOperation() {
signalPassFailure();
}

template <typename SourceOp>
class GCCJITLoweringPattern : public ConversionPattern {
template <typename T>
class GCCJITLoweringPattern : public mlir::OpConversionPattern<T> {
protected:
const SymbolTable &symbolTable;

public:
const GCCJITTypeConverter *getTypeConverter() const {
return static_cast<const GCCJITTypeConverter *>(this->typeConverter);
}

public:
using OpAdaptor = typename SourceOp::Adaptor;
template <typename... Args>
GCCJITLoweringPattern(const SymbolTable &symbolTable,
const TypeConverter &typeConverter,
MLIRContext *context, PatternBenefit benefit = 1)
: ConversionPattern(typeConverter, SourceOp::getOperationName(), benefit,
context),
const GCCJITTypeConverter &typeConverter,
Args &&...args)
: mlir::OpConversionPattern<T>(typeConverter,
std::forward<Args>(args)...),
symbolTable(symbolTable) {}

/// Wrappers around the ConversionPattern methods that pass the derived op
/// type.
LogicalResult match(Operation *op) const final {
return match(cast<SourceOp>(op));
}
void rewrite(Operation *op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const final {
auto sourceOp = cast<SourceOp>(op);
rewrite(sourceOp, OpAdaptor(operands, sourceOp), rewriter);
}
LogicalResult
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const final {
auto sourceOp = cast<SourceOp>(op);
return matchAndRewrite(sourceOp, OpAdaptor(operands, sourceOp), rewriter);
}

/// Rewrite and Match methods that operate on the SourceOp type. These must be
/// overridden by the derived pattern class.
virtual LogicalResult match(SourceOp op) const {
llvm_unreachable("must override match or matchAndRewrite");
}
virtual void rewrite(SourceOp op, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const {
llvm_unreachable("must override matchAndRewrite or a rewrite method");
}
virtual LogicalResult
matchAndRewrite(SourceOp op, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const {
if (failed(match(op)))
return failure();
rewrite(op, adaptor, rewriter);
return success();
}

private:
using ConversionPattern::matchAndRewrite;
};

NewStructOp packValues(mlir::Location loc, mlir::ValueRange values,
Expand Down Expand Up @@ -405,6 +370,7 @@ class CallIndirectOpLowering
}
};
} // namespace
#pragma GCC diagnostic pop

void mlir::gccjit::populateFuncToGCCJITPatterns(
MLIRContext *context, GCCJITTypeConverter &typeConverter,
Expand Down

0 comments on commit a7d6245

Please sign in to comment.