Files
swift-mirror/test/SILOptimizer/stack-nesting-lowered.sil
T
John McCall 9b6777ff59 Allow alloc_pack_metadata to be marked as [non_nested].
This is inserted by SIL passes and so may not always be properly nested
with respect to non-unreorderable allocations such as async lets.
2026-04-08 17:56:47 -04:00

41 lines
1.4 KiB
Plaintext

// RUN: %target-sil-opt -sil-disable-input-verify -test-runner %s -o /dev/null 2>&1 | %FileCheck %s
import Builtin
import Swift
sil_stage lowered
struct VGStruct<each T> {}
sil private @priority_helper : $@convention(thin) (UInt8, UInt8) -> () {
bb0(%0 : $UInt8, %1 : $UInt8):
unreachable
}
// alloc_pack_metadata must be markable as non-nested
// CHECK-LABEL: sil [ossa] @test_mark_alloc_pack_metadata_non_nested :
// CHECK: builtin "taskAddPriorityEscalationHandler"
// CHECK-NEXT: [[ALLOC:%.*]] = alloc_pack_metadata [non_nested] $()
// CHECK-NEXT: metatype $@thick VGStruct<Int, Int>.Type
// CHECK-NEXT: builtin "taskRemovePriorityEscalationHandler"
// CHECK-NEXT: dealloc_pack_metadata [[ALLOC]]
// CHECK-LABEL: // end sil function 'test_mark_alloc_pack_metadata_non_nested'
sil [ossa] @test_mark_alloc_pack_metadata_non_nested : $@convention(thin) @async () -> () {
bb0:
specify_test "stack_nesting_fixup"
%fn = function_ref @priority_helper : $@convention(thin) (UInt8, UInt8) -> ()
%thick_fn = thin_to_thick_function %fn to $@noescape @callee_guaranteed (UInt8, UInt8) -> ()
%handler = builtin "taskAddPriorityEscalationHandler"(%thick_fn) : $UnsafeRawPointer
%a = alloc_pack_metadata $()
%metatype = metatype $@thick VGStruct<Int, Int>.Type
%out = builtin "taskRemovePriorityEscalationHandler"(%handler) : $()
dealloc_pack_metadata %a
%ret = tuple ()
return %ret : $()
}