Files
swift-mirror/test/SILGen/local_captures.swift
Slava Pestov 94ce4c2ac3 SIL: Only give closures shared linkage if they're going to be serialized
Otherwise, we don't want them to be linkonce_odr at the LLVM level
to avoid unnecessary link-time overhead.
2017-03-31 20:26:27 -07:00

26 lines
836 B
Swift

// RUN: %target-swift-frontend -parse-as-library -emit-silgen %s | %FileCheck %s
// Check that we don't crash if a local function references another local
// function without captures.
// CHECK-LABEL: sil hidden @_T014local_captures10globalfuncyycyF : $@convention(thin) () -> @owned @callee_owned () -> ()
func globalfunc() -> () -> () {
// CHECK-LABEL: sil private @_T014local_captures10globalfuncyycyF0A4FuncL_yyF : $@convention(thin) () -> ()
func localFunc() {
}
// CHECK-LABEL: sil private @_T014local_captures10globalfuncyycyF6callitL_yyF : $@convention(thin) () -> ()
func callit() {
localFunc()
}
// CHECK-LABEL: sil private @_T014local_captures10globalfuncyycyF5getitL_yycyF : $@convention(thin) () -> @owned @callee_owned () -> ()
func getit() -> () -> () {
return localFunc
}
callit()
return getit()
}