mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Now that Swift decides whether or not we need stack protection we should force LLVM to emit stack protection when we request it.
26 lines
804 B
Swift
26 lines
804 B
Swift
// RUN: %target-swift-frontend -enable-stack-protector -Onone -emit-ir %s -o - | %FileCheck %s
|
|
// RUN: %target-swift-frontend -enable-stack-protector -O -emit-ir %s -o - | %FileCheck %s
|
|
|
|
// REQUIRES: swift_in_compiler
|
|
|
|
@_silgen_name("escape")
|
|
func f(_ arg: UnsafePointer<Int>)
|
|
|
|
@_silgen_name("noescape")
|
|
func g(_ arg: Int)
|
|
|
|
// CHECK: define {{.*}}swiftcc void @"$s15stack_protector21requestStackProtectoryyF"() [[SSPATTRS:#[0-9]+]] {
|
|
public func requestStackProtector() {
|
|
var x: Int = 0
|
|
f(&x)
|
|
}
|
|
|
|
// CHECK-NOT: define {{.*}}swiftcc void @"$s15stack_protector16noStackProtectoryyF"() [[SSPATTRS]] {
|
|
public func noStackProtector() {
|
|
var x: Int = 27
|
|
g(x)
|
|
g(x) // avoid function merging by calling `g` two times
|
|
}
|
|
// CHECK: [[SSPATTRS]] = { sspreq {{.*}}"stack-protector-buffer-size"="8"
|
|
|