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 StringRef getArgument() const final { return "test-print-callgraph"; } 23 StringRef getDescription() const final { 24 return "Print the contents of a constructed callgraph."; 25 } 26 void runOnOperation() override { 27 llvm::errs() << "Testing : " << getOperation()->getAttr("test.name") 28 << "\n"; 29 getAnalysis<CallGraph>().print(llvm::errs()); 30 } 31 }; 32 } // namespace 33 34 namespace mlir { 35 namespace test { 36 void registerTestCallGraphPass() { PassRegistration<TestCallGraphPass>(); } 37 } // namespace test 38 } // namespace mlir 39