Files
swift-mirror/test/SIL/verifier_loweredsil_failures.sil
John McCall 90995b82f4 Teach the SIL verifier to enforce stronger rules around
edges into dead-end regions.

- Only treat edges *into* dead-end regions as special; edges internal
  the region must use the normal rules.

- Conservatively merge information along those edges rather than just
  picking one at random. This requires us to not walk into the region
  until we've processed all of the edges to it.

- Make sure we prevent *any* stack allocations from being deallocated
  if the stack is inconsistent entering a block.

Additionally, fix a bug which was incorrectly treating all blocks that
don't themselves exit the function as ultimately leading to unreachable,
which had inadvertently largely turned off the consistency check.
2025-10-11 02:12:19 -04:00

38 lines
1.6 KiB
Plaintext

// RUN: %target-sil-opt -emit-sorted-sil -verify-continue-on-failure -o /dev/null %s 2>&1 | %FileCheck %s
// REQUIRES: asserts
sil_stage lowered
import Builtin
class C {}
// CHECK-LABEL: Begin Error in function alloc_pack_metadata_before_tuple
// CHECK: SIL verification failed: Introduces instruction of kind which cannot emit on-stack pack metadata:
// CHECK-LABEL: End Error in function alloc_pack_metadata_before_tuple
sil @alloc_pack_metadata_before_tuple : $@convention(thin) () -> () {
%marker = alloc_pack_metadata $()
%retval = tuple ()
dealloc_pack_metadata %marker : $*()
return %retval : $()
}
// CHECK-LABEL: Begin Error in function dealloc_pack_metadata_with_bad_operand
// CHECK: SIL verification failed: deallocating allocation that is not the top of the stack
// CHECK-LABEL: End Error in function dealloc_pack_metadata_with_bad_operand
// CHECK-LABEL: Begin Error in function dealloc_pack_metadata_with_bad_operand
// CHECK: SIL verification failed: return with stack allocs that haven't been deallocated
// CHECK-LABEL: End Error in function dealloc_pack_metadata_with_bad_operand
// CHECK-LABEL: Begin Error in function dealloc_pack_metadata_with_bad_operand
// CHECK: SIL verification failed: Must have alloc_pack_metadata operand
// CHECK-LABEL: End Error in function dealloc_pack_metadata_with_bad_operand
sil @dealloc_pack_metadata_with_bad_operand : $@convention(thin) <each T> () -> () {
%marker = alloc_pack_metadata $()
// To make the %marker legal.
%out = apply undef<Pack{repeat each T}>() : $@convention(thin) <each T>() -> ()
dealloc_pack_metadata %out : $()
%retval = tuple ()
return %retval : $()
}