Files
swift-mirror/test/DebugInfo/linetable-do.swift
Adrian Prantl c9927f66f0 Serialize debug scope and location info in the SIL assembler language.
At the moment it is only possible to test the effects that SIL
optimization passes have on debug information by observing the
effects of a full .swift -> LLVM IR compilation. This change enable us
to write targeted testcases for single SIL optimization passes.

The new syntax is as follows:

 sil-scope-ref ::= 'scope' [0-9]+
 sil-scope ::= 'sil_scope' [0-9]+ '{'
                 sil-loc
                 'parent' scope-parent
                 ('inlined_at' sil-scope-ref )?
               '}'
 scope-parent ::= sil-function-name ':' sil-type
 scope-parent ::= sil-scope-ref
 sil-loc ::= 'loc' string-literal ':' [0-9]+ ':' [0-9]+

Each instruction may have a debug location and a SIL scope reference
at the end.  Debug locations consist of a filename, a line number, and
a column number.  If the debug location is omitted, it defaults to the
location in the SIL source file.  SIL scopes describe the position
inside the lexical scope structure that the Swift expression a SIL
instruction was generated from had originally. SIL scopes also hold
inlining information.

<rdar://problem/22706994>
2016-02-26 10:46:29 -08:00

45 lines
1.2 KiB
Swift

// RUN: %target-swift-frontend -Xllvm -sil-full-demangle %s -emit-ir -g -o - | FileCheck %s
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle %s -emit-sil -emit-verbose-sil -g -o - | FileCheck -check-prefix=CHECK-SIL %s
import StdlibUnittest
class Obj {}
func foo (a : Int64) throws -> Void {
_blackHole(a)
}
// CHECK-SIL: // main.testDoStmt () throws -> ()
func testDoStmt() throws -> Void {
_blackHole(23)
// CHECK-NOT: !DILocation(line: [[@LINE+1]]
do {
let obj = Obj()
_blackHole(obj)
try foo(100)
// CHECK-SIL: bb{{.*}}(%{{[0-9]+}} : $()):
// CHECK-SIL-NEXT: strong_release {{.*}}: $Obj{{.*}} line:[[@LINE+1]]:3:cleanup
}
// CHECK-SIL-NEXT: = tuple ()
// CHECK-SIL-NEXT: return {{.*}} line:[[@LINE+1]]
}
try testDoStmt()
// CHECK-SIL: // main.testDoWhileStmt () -> ()
func testDoWhileStmt() -> Void {
// CHECK-NOT: !DILocation(line: [[@LINE+1]]
do {
try foo(100)
// CHECK-SIL: bb{{.*}}(%{{[0-9]+}} : $()):
// CHECK-SIL-NEXT: br [[RETURN_BB:bb[0-9]+]]{{.*}} line:[[@LINE+1]]:3:cleanup
}
// CHECK-SIL: [[RETURN_BB]]:
// CHECK-SIL-NEXT: = tuple ()
// CHECK-SIL-NEXT: return
catch (let e) {
_blackHole(e)
}
}