Files
swift-mirror/test/ClangImporter/enum-stack-protection.swift
Erik Eckstein 9aff288be4 Optimizer: re-implement the pointer_to_address SILCombine peephole optimizations in swift
Which consists of
* removing redundant `address_to_pointer`-`pointer_to_address` pairs
* optimize `index_raw_pointer` of a manually computed stride to `index_addr`
* remove or increase the alignment based on a "assumeAlignment" builtin

This is a big code cleanup but also has some functional differences for the `address_to_pointer`-`pointer_to_address` pair removal:

* It's not done if the resulting SIL would result in a (detectable) use-after-dealloc_stack memory lifetime failure.
* It's not done if `copy_value`s must be inserted or borrow-scopes must be extended to comply with ownership rules (this was the task of the OwnershipRAUWHelper).

Inserting copies is bad anyway.
Extending borrow-scopes would only be required if the original lifetime of the pointer extends a borrow scope - which shouldn't happen in save code. Therefore this is a very rare case which is not worth handling.
2024-12-21 08:28:22 +01:00

20 lines
506 B
Swift

// RUN: %target-swift-frontend -import-objc-header %S/Inputs/enum-stack-protection.h %s -Onone -module-name=test -emit-sil | %FileCheck %s
// Check that accessing an imported enum doesn't trigger stack protection.
// CHECK-LABEL: sil @$s4test6testityyF : $@convention(thin) () -> () {
// CHECK-NOT: stack_protection
// CHECK: } // end sil function '$s4test6testityyF'
public func testit() {
var s = S()
s.a = 1
s.b = 2
s.c = 3
useit(s)
}
@inline(never)
public func useit(_ s: S) {
}