Files
swift-mirror/test/DebugInfo/simple.sil
Adrian Prantl 64cbec3805 Add SIL syntax for declaring debug variables.
Debug variable info may be attached to debug_value, debug_value_addr,
alloc_box, and alloc_stack instructions.

In order to write textual SIL -> SIL testcases that exercise the handling
of debug information by SIL passes, we need to make a couple of additions
to the textual SIL language. In memory, the debug information attached to
SIL instructions references information from the AST. If we want to create
debug info from parsing a textual .sil file, these bits need to be made
explicit.

Performance Notes: This is memory neutral for compilations from Swift
source code, because the variable name is still stored in the AST. For
compilations from textual source the variable name is stored in tail-
allocated memory following the SIL instruction that introduces the
variable.

<rdar://problem/22707128>
2015-12-14 10:29:50 -08:00

24 lines
1.0 KiB
Plaintext

// RUN: %target-swift-frontend %s -g -emit-ir -o - | FileCheck %s
sil_stage canonical
import Builtin
import Swift
sil @square : $@convention(thin) (Int32) -> Int32 {
bb0(%0 : $Int32):
debug_value %0 : $Int32, let, name "x" // id: %1
%3 = struct_extract %0 : $Int32, #Int32._value // user: %6
%4 = struct_extract %0 : $Int32, #Int32._value // user: %6
%5 = integer_literal $Builtin.Int1, -1 // user: %6
%6 = builtin "smul_with_overflow_Int32"(%3 : $Builtin.Int32, %4 : $Builtin.Int32, %5 : $Builtin.Int1) : $(Builtin.Int32, Builtin.Int1) // users: %7, %8
%7 = tuple_extract %6 : $(Builtin.Int32, Builtin.Int1), 0 // user: %10
%8 = tuple_extract %6 : $(Builtin.Int32, Builtin.Int1), 1 // user: %9
cond_fail %8 : $Builtin.Int1 // id: %9
%10 = struct $Int32 (%7 : $Builtin.Int32) // user: %11
// CHECK: ret i32 %{{.*}}, !dbg ![[LOC:.*]]
// CHECK: ![[LOC]] = !DILocation(line: [[@LINE+1]],
return %10 : $Int32 // id: %11
}