Files
swift-mirror/test/DebugInfo/transparent.swift
Adrian Prantl c241ff305e Emit compiler-generated debug locations for outlined transparent functions.
In the majority of the use-cases transparent functions are inlined by
the mandatory inliner which by design drops all debug info and
pretends the inlined instructions were always part of the
caller. Since an outlined copy of the function is often still
generated, attaching debug locations to it is inconsistent and can
create the false impression that it were possible to set a breakpoint
in such a function when in reality these functions are only there for
very few edge cases.

<rdar://problem/40258813>
2018-05-17 16:38:04 -07:00

30 lines
752 B
Swift

// RUN: %target-swift-frontend %s -O -I %t -emit-ir -g -o - | %FileCheck %s
func use<T>(_ t: T) {}
@inline(never)
public func noinline(_ x: Int64) -> Int64 { return x }
@_transparent
public func transparent(_ y: Int64) -> Int64 {
var local = y
return noinline(local)
}
let z = transparent(0)
use(z)
// Check that a transparent function has no debug information.
// CHECK: define {{.*}}$S11transparentAA
// CHECK-SAME: !dbg ![[SP:[0-9]+]]
// CHECK-NEXT: entry:
// CHECK-NEXT: !dbg ![[ZERO:[0-9]+]]
// CHECK-NEXT: !dbg ![[ZERO]]
// CHECK-NEXT: }
// CHECK: ![[SP]] = {{.*}}name: "transparent"
// CHECK-SAME: file: ![[FILE:[0-9]+]]
// CHECK-NOT: line:
// CHECK: ![[FILE]] = {{.*}}"<compiler-generated>"
// CHECK: ![[ZERO]] = !DILocation(line: 0,