diff options
| author | River Riddle <riverriddle@google.com> | 2019-09-23 11:43:43 -0700 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-09-23 11:44:13 -0700 |
| commit | 8cb405a8bed4a6a3782591c5eb447a83857f94c8 (patch) | |
| tree | 46cfeaaec3c25341950d693f6455a29c3ebc4d29 /mlir/test/Analysis | |
| parent | 8965011fadf24f4986b0d9c00fc6af0f2b13ee28 (diff) | |
| download | bcm5719-llvm-8cb405a8bed4a6a3782591c5eb447a83857f94c8.tar.gz bcm5719-llvm-8cb405a8bed4a6a3782591c5eb447a83857f94c8.zip | |
Add initial callgraph support.
Using the two call interfaces, CallOpInterface and CallableOpInterface, this change adds support for an initial multi-level CallGraph. This call graph builds a set of nodes for each callable region, and connects them via edges. An edge may be any of the following types:
* Abstract
- An edge not produced by a call operation, used for connecting to internal nodes from external nodes.
* Call
- A call edge is an edge defined via a call-like operation.
* Child
- This is an artificial edge connecting nested callgraph nodes.
This callgraph will be used, and improved upon, to begin supporting more interesting interprocedural analyses and transformation. In a followup, this callgraph will be used to support more complex inlining support.
PiperOrigin-RevId: 270724968
Diffstat (limited to 'mlir/test/Analysis')
| -rw-r--r-- | mlir/test/Analysis/test-callgraph.mlir | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/mlir/test/Analysis/test-callgraph.mlir b/mlir/test/Analysis/test-callgraph.mlir new file mode 100644 index 00000000000..39e4fb8ba27 --- /dev/null +++ b/mlir/test/Analysis/test-callgraph.mlir @@ -0,0 +1,52 @@ +// RUN: mlir-opt %s -test-print-callgraph 2>&1 | FileCheck %s --dump-input-on-failure + +// CHECK-LABEL: Testing : "simple" +module attributes {test.name = "simple"} { + + // CHECK: Node{{.*}}func_a + func @func_a() { + return + } + + func @func_b() + + // CHECK: Node{{.*}}func_c + // CHECK-NEXT: Call-Edge{{.*}}External-Node + func @func_c() { + call @func_b() : () -> () + return + } + + // CHECK: Node{{.*}}func_d + // CHECK-NEXT: Call-Edge{{.*}}func_c + func @func_d() { + call @func_c() : () -> () + return + } + + // CHECK: Node{{.*}}func_e + // CHECK-DAG: Call-Edge{{.*}}func_c + // CHECK-DAG: Call-Edge{{.*}}func_d + // CHECK-DAG: Call-Edge{{.*}}func_e + func @func_e() { + call @func_c() : () -> () + call @func_d() : () -> () + call @func_e() : () -> () + return + } + + // CHECK: Node{{.*}}func_f + // CHECK: Child-Edge{{.*}}test.functional_region_op + // CHECK: Call-Edge{{.*}}test.functional_region_op + func @func_f() { + // CHECK: Node{{.*}}test.functional_region_op + // CHECK: Call-Edge{{.*}}func_f + %fn = "test.functional_region_op"() ({ + call @func_f() : () -> () + "test.return"() : () -> () + }) : () -> (() -> ()) + + call_indirect %fn() : () -> () + return + } +} |

