@@ -455,7 +455,7 @@ module @llvm_unreachable {
455455 func.func private @fn_with_llvm_unreachable (%arg0: tensor <4 x4 xf32 >) -> tensor <4 x4 xi1 > {
456456 llvm.unreachable
457457 }
458- func.func private @main (%arg0: tensor <4 x4 xf32 >) {
458+ func.func @main (%arg0: tensor <4 x4 xf32 >) {
459459 %0 = call @fn_with_llvm_unreachable (%arg0 ) : (tensor <4 x4 xf32 >) -> tensor <4 x4 xi1 >
460460 llvm.return
461461 }
@@ -649,3 +649,49 @@ func.func @callee(%arg0: index, %arg1: index, %arg2: index) -> index {
649649 %res = call @mutl_parameter (%arg0 , %arg1 , %arg2 ) : (index , index , index ) -> (index )
650650 return %res : index
651651}
652+
653+ // -----
654+
655+ // Test the elimination of dead functions.
656+
657+ // CHECK-NOT: func private @single_private_func
658+ func.func private @single_private_func (%arg0: i64 ) -> (i64 ) {
659+ %c0_i64 = arith.constant 0 : i64
660+ %2 = arith.cmpi eq , %arg0 , %c0_i64 : i64
661+ cf.cond_br %2 , ^bb1 , ^bb2
662+ ^bb1 : // pred: ^bb0
663+ %c1_i64 = arith.constant 1 : i64
664+ return %c1_i64 : i64
665+ ^bb2 : // pred: ^bb0
666+ %c3_i64 = arith.constant 3 : i64
667+ return %c3_i64 : i64
668+ }
669+
670+ // -----
671+
672+ // Test the elimination of dead functions.
673+
674+ // CHECK-NOT: @single_parameter
675+ func.func private @single_parameter (%arg0: index ) {
676+ return
677+ }
678+
679+ // CHECK-NOT: @mutl_parameter
680+ func.func private @mutl_parameter (%arg0: index , %arg1: index , %arg2: index ) -> index {
681+ return %arg1 : index
682+ }
683+
684+ // CHECK-NOT: @eliminate_parameter
685+ func.func private @eliminate_parameter (%arg0: index , %arg1: index ) {
686+ call @single_parameter (%arg0 ) : (index ) -> ()
687+ return
688+ }
689+
690+ // CHECK-NOT: @callee
691+ func.func private @callee (%arg0: index , %arg1: index , %arg2: index ) -> index {
692+ // CHECK-NOT: call @eliminate_parameter
693+ call @eliminate_parameter (%arg0 , %arg1 ) : (index , index ) -> ()
694+ // CHECK-NOT: call @mutl_parameter
695+ %res = call @mutl_parameter (%arg0 , %arg1 , %arg2 ) : (index , index , index ) -> (index )
696+ return %res : index
697+ }
0 commit comments