Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.6 KiB
C++
Raw Permalink Normal View History

//===- TestMemRefBoundCheck.cpp - Test out of bound access checks ---------===//
2018-10-30 17:43:06 -07:00
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2018-10-30 17:43:06 -07:00
//
//===----------------------------------------------------------------------===//
2018-10-30 17:43:06 -07:00
//
2019-10-20 00:11:03 -07:00
// This file implements a pass to check memref accesses for out of bound
2018-10-30 17:43:06 -07:00
// accesses.
//
//===----------------------------------------------------------------------===//
#include "mlir/Analysis/AffineAnalysis.h"
#include "mlir/Analysis/AffineStructures.h"
2018-11-08 17:31:01 -08:00
#include "mlir/Analysis/Utils.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
2018-10-30 17:43:06 -07:00
#include "mlir/IR/Builders.h"
2019-02-19 17:17:46 -08:00
#include "mlir/Pass/Pass.h"
#include "llvm/ADT/TypeSwitch.h"
2018-10-30 17:43:06 -07:00
#include "llvm/Support/Debug.h"
#define DEBUG_TYPE "memref-bound-check"
using namespace mlir;
namespace {
/// Checks for out of bound memef access subscripts..
struct TestMemRefBoundCheck
: public PassWrapper<TestMemRefBoundCheck, FunctionPass> {
void runOnFunction() override;
2018-10-30 17:43:06 -07:00
};
} // end anonymous namespace
void TestMemRefBoundCheck::runOnFunction() {
getFunction().walk([](Operation *opInst) {
TypeSwitch<Operation *>(opInst).Case<AffineLoadOp, AffineStoreOp>(
[](auto op) { boundCheckLoadOrStoreOp(op); });
// TODO(bondhugula): do this for DMA ops as well.
});
2018-10-30 17:43:06 -07:00
}
2018-11-06 18:34:18 -08:00
namespace mlir {
void registerMemRefBoundCheck() {
PassRegistration<TestMemRefBoundCheck>(
"test-memref-bound-check", "Check memref access bounds in a Function");
}
} // namespace mlir