@@ -1924,6 +1924,60 @@ entry(%addr : $*T):
1924
1924
return %retval : $()
1925
1925
}
1926
1926
1927
+ // The move_value is lexical so the corresponding alloc_stack must be marked
1928
+ // lexical too.
1929
+ // CHECK-LABEL: sil [ossa] @testMoveValueLexical : {{.*}} {
1930
+ // CHECK: alloc_stack [lexical]
1931
+ // CHECK-LABEL: } // end sil function 'testMoveValueLexical'
1932
+ sil [ossa] @testMoveValueLexical : $@convention(thin) <T> () -> () {
1933
+ %getT = function_ref @getT : $@convention(thin) <T> () -> @out T
1934
+ %instance = apply %getT<T>() : $@convention(thin) <T> () -> @out T
1935
+ %moved = move_value [lexical] %instance : $T
1936
+ destroy_value %moved : $T
1937
+ %retval = tuple ()
1938
+ return %retval : $()
1939
+ }
1940
+
1941
+ // Verify that the temporary storage is lexical and moved out of
1942
+ // (copy_addr [take]).
1943
+ // CHECK-LABEL: sil [ossa] @testMoveValueLexicalAndReturn : {{.*}} {
1944
+ // CHECK: {{bb[0-9]+}}([[RETVAL:%[^,]+]] :
1945
+ // CHECK: [[STACK:%[^,]+]] = alloc_stack [lexical]
1946
+ // CHECK: copy_addr [take] [[STACK]] to [init] [[RETVAL]]
1947
+ // CHECK-LABEL: } // end sil function 'testMoveValueLexicalAndReturn'
1948
+ sil [ossa] @testMoveValueLexicalAndReturn : $@convention(thin) <T> () -> @out T {
1949
+ %getT = function_ref @getT : $@convention(thin) <T> () -> @out T
1950
+ %instance = apply %getT<T>() : $@convention(thin) <T> () -> @out T
1951
+ %moved = move_value [lexical] %instance : $T
1952
+ return %moved : $T
1953
+ }
1954
+
1955
+ // Verify that a move_value gets no stack storage if it's from an argument.
1956
+ // CHECK-LABEL: sil [ossa] @testMoveValueLexicalArgument : {{.*}} {
1957
+ // CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] :
1958
+ // CHECK: destroy_addr [[INSTANCE]]
1959
+ // CHECK-LABEL: } // end sil function 'testMoveValueLexicalArgument'
1960
+ sil [ossa] @testMoveValueLexicalArgument : $@convention(thin) <T> (@in T) -> () {
1961
+ entry(%instance : @owned $T):
1962
+ %moved = move_value [lexical] %instance : $T
1963
+ destroy_value %moved : $T
1964
+ %retval = tuple ()
1965
+ return %retval : $()
1966
+ }
1967
+
1968
+ // Only lexical move_values should mark the alloc_stack lexical.
1969
+ // CHECK-LABEL: sil [ossa] @testMoveValueNonlexical : {{.*}} {
1970
+ // CHECK-NOT: alloc_stack [lexical]
1971
+ // CHECK-LABEL: } // end sil function 'testMoveValueNonlexical'
1972
+ sil [ossa] @testMoveValueNonlexical : $@convention(thin) <T> () -> () {
1973
+ %getT = function_ref @getT : $@convention(thin) <T> () -> @out T
1974
+ %instance = apply %getT<T>() : $@convention(thin) <T> () -> @out T
1975
+ %moved = move_value %instance : $T
1976
+ destroy_value %moved : $T
1977
+ %retval = tuple ()
1978
+ return %retval : $()
1979
+ }
1980
+
1927
1981
// CHECK-LABEL: sil hidden [ossa] @testOpaqueYield :
1928
1982
// CHECK: bb0(%0 : @guaranteed $TestGeneric<T>):
1929
1983
// CHECK: [[REF:%.*]] = ref_element_addr %0 : $TestGeneric<T>, #TestGeneric.borrowedGeneric
0 commit comments