Files
swift-mirror/test/IRGen/stack_protector.swift
Erik Eckstein 1ae1c51022 IRGen: add sppreq instead of sspstrong for functions which need stack protection.
Now that Swift decides whether or not we need stack protection we should force LLVM to emit stack protection when we request it.
2022-09-08 08:42:25 +02:00

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"