llvm-project/mlir/test/lib/Analysis/TestCallGraph.cpp
River Riddle 3fef2d26a3 [mlir][NFC] Move passes in test/lib/Transforms/ to a directory that mirrors what they test
test/lib/Transforms/ has bitrot and become somewhat of a dumping grounds for testing pretty much any part of the project. This revision cleans this up, and moves the files within to a directory that reflects what is actually being tested.

Differential Revision: https://reviews.llvm.org/D102456
2021-05-14 10:28:11 -07:00

38 lines
1.2 KiB
C++

//===- TestCallGraph.cpp - Test callgraph construction and iteration ------===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// This file contains test passes for constructing and iterating over a
// callgraph.
//
//===----------------------------------------------------------------------===//
#include "mlir/Analysis/CallGraph.h"
#include "mlir/Pass/Pass.h"
using namespace mlir;
namespace {
struct TestCallGraphPass
: public PassWrapper<TestCallGraphPass, OperationPass<ModuleOp>> {
void runOnOperation() override {
llvm::errs() << "Testing : " << getOperation()->getAttr("test.name")
<< "\n";
getAnalysis<CallGraph>().print(llvm::errs());
}
};
} // end anonymous namespace
namespace mlir {
namespace test {
void registerTestCallGraphPass() {
PassRegistration<TestCallGraphPass> pass(
"test-print-callgraph", "Print the contents of a constructed callgraph.");
}
} // namespace test
} // namespace mlir