1 //===- TestCallGraph.cpp - Test callgraph construction and iteration ------===//
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 contains test passes for constructing and iterating over a
10 // callgraph.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "mlir/Analysis/CallGraph.h"
15 #include "mlir/Pass/Pass.h"
16 
17 using namespace mlir;
18 
19 namespace {
20 struct TestCallGraphPass
21     : public PassWrapper<TestCallGraphPass, OperationPass<ModuleOp>> {
22   void runOnOperation() override {
23     llvm::errs() << "Testing : " << getOperation()->getAttr("test.name")
24                  << "\n";
25     getAnalysis<CallGraph>().print(llvm::errs());
26   }
27 };
28 } // end anonymous namespace
29 
30 namespace mlir {
31 namespace test {
32 void registerTestCallGraphPass() {
33   PassRegistration<TestCallGraphPass> pass(
34       "test-print-callgraph", "Print the contents of a constructed callgraph.");
35 }
36 } // namespace test
37 } // namespace mlir
38