Skip to content

Commit 8571ea0

Browse files
committed
tests: add a test in mem-behavior.sil for global let variables
1 parent 614a635 commit 8571ea0

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

test/SILOptimizer/mem-behavior.sil

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,13 +805,44 @@ bb0(%0 : $*C, %1 : $*C):
805805
return %2 : $C
806806
}
807807

808+
sil_global hidden [let] @globalC : $C
809+
sil_global hidden @globalCVar : $C
810+
811+
// CHECK-LABEL: @testGlobalLet
812+
// CHECK: PAIR #1.
813+
// CHECK-NEXT: %3 = apply %2() : $@convention(thin) () -> ()
814+
// CHECK-NEXT: %0 = global_addr @globalC : $*C
815+
// CHECK-NEXT: r=1,w=0
816+
sil hidden @testGlobalLet : $@convention(thin) () -> () {
817+
bb0:
818+
%0 = global_addr @globalC : $*C
819+
%1 = load %0 : $*C
820+
%2 = function_ref @nouser_func : $@convention(thin) () -> () // user: %3
821+
%3 = apply %2() : $@convention(thin) () -> ()
822+
%8 = tuple ()
823+
return %8 : $()
824+
}
825+
826+
// CHECK-LABEL: @testGlobalVar
827+
// CHECK: PAIR #1.
828+
// CHECK-NEXT: %3 = apply %2() : $@convention(thin) () -> ()
829+
// CHECK-NEXT: %0 = global_addr @globalCVar : $*C
830+
// CHECK-NEXT: r=1,w=1
831+
sil hidden @testGlobalVar : $@convention(thin) () -> () {
832+
bb0:
833+
%0 = global_addr @globalCVar : $*C
834+
%1 = load %0 : $*C
835+
%2 = function_ref @nouser_func : $@convention(thin) () -> () // user: %3
836+
%3 = apply %2() : $@convention(thin) () -> ()
837+
%8 = tuple ()
838+
return %8 : $()
839+
}
840+
808841
// ===-----------------------------------------------------------------------===
809842
// Test the effect of a [deinit] access on a global 'let'
810843
//
811844
// Test <rdar://60046018> Assert: (v->getType().isAddress()), getAccessedAddress
812845

813-
sil_global hidden [let] @globalC : $C
814-
815846
// CHECK-LABEL: @testDeinitInstVsNonAddressValue
816847
// CHECK: PAIR #3.
817848
// CHECK-NEXT: load %{{.*}} : $*C

0 commit comments

Comments
 (0)