1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
%# -*- mode: sil -*-
// RUN: %empty-directory(%t)
// RUN: %gyb %s > %t/arc-sequence-opts-loops.sil
// RUN: %target-sil-opt -enable-sil-verify-all -arc-sequence-opts %t/arc-sequence-opts-loops.sil -enable-loop-arc=0 | %FileCheck %t/arc-sequence-opts-loops.sil
%# Ignore the following admonition; it applies to the resulting .sil
%# test file only.
// DO NOT MODIFY THIS TEST FILE. IT IS AUTOMATICALLY GENERATED BY GYB.
sil_stage canonical
import Builtin
// Utilities
sil @user : $@convention(thin) (Builtin.NativeObject) -> ()
// Loop form 1 consists of CFG of the following form:
//
// BB0 -> BB1
// BB1 -> BB1
// BB1 -> BB2
//
// Thus it is a simple loop without any interior basic blocks.
//
// We generate test retain release pairs at
% for i in range(16):
// CHECK-LABEL: sil @loop_form_1_${i} : $@convention(thin) (Builtin.NativeObject) -> () {
sil @loop_form_1_${i} : $@convention(thin) (Builtin.NativeObject) -> () {
// CHECK: bb0
bb0(%0 : $Builtin.NativeObject):
% if i & 1:
// CHECK-NEXT: strong_retain
strong_retain %0 : $Builtin.NativeObject
% end
// CHECK-NEXT: br bb
br bb1
// CHECK: bb1:
bb1:
% if (i & 2) and not (i & 4):
// CHECK-NEXT: strong_retain
% end
% if i & 2:
strong_retain %0 : $Builtin.NativeObject
% end
% if not (i & 2) and (i & 4):
// CHECK-NEXT: strong_release
% end
% if i & 4:
strong_release %0 : $Builtin.NativeObject
% end
// CHECK-NEXT: cond_br
cond_br undef, bb2, bb3
bb2:
br bb1
// CHECK: bb3:
bb3:
% if i & 8:
// CHECK-NEXT: strong_release
strong_release %0 : $Builtin.NativeObject
% end
%%1 = tuple ()
return %1 : $()
}
% end
// Loop form 2 consists of CFGs of the following form:
//
// BB0 -> BB1
// BB1 -> BB2
// BB2 -> BB1
// BB2 -> BB3
//
// I.e. a loop with a body of 2 and the jump into the loop not at the
// latch.
% for i in range(3):
% for j in range(4):
sil @loop_form_2_${i}_${j} : $@convention(thin) (Builtin.NativeObject) -> () {
// CHECK: bb0({{.*}}):
bb0(%0 : $Builtin.NativeObject):
% if i & 1:
// CHECK-NEXT: strong_retain
strong_retain %0 : $Builtin.NativeObject
% end
br bb1
// CHECK: bb1:
bb1:
% if j == 0:
// CHECK-NEXT: strong_retain
strong_retain %0 : $Builtin.NativeObject
% end
% if j == 1:
// CHECK-NEXT: strong_release
strong_release %0 : $Builtin.NativeObject
% end
br bb2
// CHECK: bb2:
bb2:
% if j == 2:
// CHECK-NEXT: strong_retain
strong_retain %0 : $Builtin.NativeObject
% end
% if j == 3:
// CHECK-NEXT: strong_release
strong_release %0 : $Builtin.NativeObject
% end
cond_br undef, bb3, bb4
bb3:
br bb1
// CHECK: bb4:
bb4:
% if i & 2:
// CHECK-NEXT: strong_release
strong_release %0 : $Builtin.NativeObject
% end
%%1 = tuple ()
return %1 : $()
}
% end
|