[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / mlir / test / lib / Analysis / TestMemRefBoundCheck.cpp
blob73ea6dddf2b29f913a05ca03ae9c767191e21410
1 //===- TestMemRefBoundCheck.cpp - Test out of bound access checks ---------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements a pass to check memref accesses for out of bound
10 // accesses.
12 //===----------------------------------------------------------------------===//
14 #include "mlir/Dialect/Affine/Analysis/AffineAnalysis.h"
15 #include "mlir/Dialect/Affine/Analysis/AffineStructures.h"
16 #include "mlir/Dialect/Affine/Analysis/Utils.h"
17 #include "mlir/Dialect/Affine/IR/AffineOps.h"
18 #include "mlir/IR/Builders.h"
19 #include "mlir/Pass/Pass.h"
20 #include "llvm/ADT/TypeSwitch.h"
21 #include "llvm/Support/Debug.h"
23 #define DEBUG_TYPE "memref-bound-check"
25 using namespace mlir;
27 namespace {
29 /// Checks for out of bound memref access subscripts..
30 struct TestMemRefBoundCheck
31 : public PassWrapper<TestMemRefBoundCheck, OperationPass<>> {
32 MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(TestMemRefBoundCheck)
34 StringRef getArgument() const final { return "test-memref-bound-check"; }
35 StringRef getDescription() const final {
36 return "Check memref access bounds";
38 void runOnOperation() override;
41 } // namespace
43 void TestMemRefBoundCheck::runOnOperation() {
44 getOperation()->walk([](Operation *opInst) {
45 TypeSwitch<Operation *>(opInst)
46 .Case<AffineReadOpInterface, AffineWriteOpInterface>(
47 [](auto op) { (void)boundCheckLoadOrStoreOp(op); });
49 // TODO: do this for DMA ops as well.
50 });
53 namespace mlir {
54 namespace test {
55 void registerMemRefBoundCheck() { PassRegistration<TestMemRefBoundCheck>(); }
56 } // namespace test
57 } // namespace mlir