1// RUN: mlir-opt -allow-unregistered-dialect %s -inline -split-input-file | FileCheck %s 2 3// This file tests the callgraph dead code elimination performed by the inliner. 4 5// Function is already dead. 6// CHECK-NOT: func private @dead_function 7func.func private @dead_function() { 8 return 9} 10 11// Function becomes dead after inlining. 12// CHECK-NOT: func private @dead_function_b 13func.func @dead_function_b() { 14 return 15} 16 17// CHECK: func @live_function() 18func.func @live_function() { 19 call @dead_function_b() : () -> () 20 return 21} 22 23// Same as above, but a transitive example. 24 25// CHECK: func @live_function_b 26func.func @live_function_b() { 27 return 28} 29// CHECK-NOT: func private @dead_function_c 30func.func private @dead_function_c() { 31 call @live_function_b() : () -> () 32 return 33} 34// CHECK-NOT: func private @dead_function_d 35func.func private @dead_function_d() { 36 call @dead_function_c() : () -> () 37 call @dead_function_c() : () -> () 38 return 39} 40// CHECK: func @live_function_c 41func.func @live_function_c() { 42 call @dead_function_c() : () -> () 43 call @dead_function_d() : () -> () 44 return 45} 46 47// Function is referenced by non-callable top-level user. 48// CHECK: func private @live_function_d 49func.func private @live_function_d() { 50 return 51} 52 53"live.user"() {use = @live_function_d} : () -> () 54 55// ----- 56 57// This test checks that the inliner can properly handle the deletion of 58// functions in different SCCs that are referenced by calls materialized during 59// canonicalization. 60// CHECK: func @live_function_e 61func.func @live_function_e() { 62 call @dead_function_e() : () -> () 63 return 64} 65// CHECK-NOT: func @dead_function_e 66func.func private @dead_function_e() -> () { 67 "test.fold_to_call_op"() {callee=@dead_function_f} : () -> () 68 return 69} 70// CHECK-NOT: func private @dead_function_f 71func.func private @dead_function_f() { 72 return 73} 74