mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
130 lines
2.6 KiB
Plaintext
130 lines
2.6 KiB
Plaintext
%# -*- 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
|