// RUN: %target-swift-frontend %s -sil-verify-all -g -Xllvm -sil-print-types -emit-sil -o - | %FileCheck --check-prefix=CHECK-SIL %s // RUN: %target-swift-frontend -disable-debugger-shadow-copies -primary-file %s -emit-ir -g -o - | %FileCheck %s import Builtin import Swift struct MyStruct { var x: Builtin.Int64 var y: Builtin.Int64 } struct SmallStruct { var z : Builtin.Int64 } sil_scope 1 { loc "file.swift":7:6 parent @test_fragment : $@convention(thin) () -> () } // Testing op_fragment w/ debug_value sil hidden @test_fragment : $@convention(thin) () -> () { bb0: %2 = alloc_stack $MyStruct, var, name "my_struct", loc "file.swift":8:9, scope 1 // CHECK: %[[MY_STRUCT:.+]] = alloca %{{.*}}MyStruct // CHECK: #dbg_declare({{.*}} %[[MY_STRUCT]], ![[VAR_DECL_MD:[0-9]+]] // CHECK: %[[SMALL_STRUCT:.+]] = alloca %{{.*}}SmallStruct // CHECK: #dbg_declare({{.*}} %[[SMALL_STRUCT]], ![[SMALL_VAR_DECL_MD:[0-9]+]] %3 = struct_element_addr %2 : $*MyStruct, #MyStruct.x, loc "file.swift":9:17, scope 1 // CHECK: %[[FIELD_X:.*]] = getelementptr {{.*}} %[[MY_STRUCT]] // CHECK-SIL: debug_value %{{[0-9]+}} : $*Builtin.Int64 // CHECK-SIL-SAME: (name "my_struct", loc "file.swift":8:9) // CHECK-SIL-SAME: type $MyStruct, expr op_deref:op_fragment:#MyStruct.x debug_value %3 : $*Builtin.Int64, var, (name "my_struct", loc "file.swift":8:9, scope 1), type $MyStruct, expr op_deref:op_fragment:#MyStruct.x, loc "file.swift":9:17, scope 1 %4 = alloc_stack $SmallStruct, var, name "small_struct", loc "file.swift":10:11, scope 1 %5 = struct_element_addr %4 : $*SmallStruct, #SmallStruct.z, loc "file.swift":11:13, scope 1 // CHECK: %[[FIELD_Z:.*]] = getelementptr {{.*}} %[[SMALL_STRUCT]] // If the fragment covers the whole struct, we're not generating the // DW_OP_LLVM_fragment part. debug_value %5 : $*Builtin.Int64, var, (name "small_struct", loc "file.swift":10:11, scope 1), type $SmallStruct, expr op_deref:op_fragment:#SmallStruct.z, loc "file.swift":11:13, scope 1 dealloc_stack %4 : $*SmallStruct dealloc_stack %2 : $*MyStruct %r = tuple() return %r : $() } sil_scope 2 { loc "file.swift":14:6 parent @test_alloc_stack : $@convention(thin) () -> () } // Testing di-expression w/ alloc_stack sil hidden @test_alloc_stack : $@convention(thin) () -> () { bb0: %my_struct = alloc_stack $MyStruct, var, name "my_struct", loc "file.swift":15:9, scope 2 // CHECK: %[[MY_STRUCT:.+]] = alloca %{{.*}}MyStruct // CHECK: #dbg_declare(ptr %[[MY_STRUCT]], ![[VAR_DECL_MD:[0-9]+]] // CHECK-SIL: alloc_stack $Int, var // CHECK-SIL-SAME: (name "my_struct", loc "file.swift":15:9) // CHECK-SIL-SAME: type $MyStruct, expr op_fragment:#MyStruct.x %field_x = alloc_stack $Int, var, (name "my_struct", loc "file.swift":15:9, scope 2), type $MyStruct, expr op_fragment:#MyStruct.x, loc "file.swift":16:17, scope 2 // CHECK: %[[FIELD_X:.+]] = alloca %TSi // CHECK: #dbg_declare(ptr %[[FIELD_X]], ![[VAR_DECL_MD]] // CHECK-SAME: !DIExpression(DW_OP_LLVM_fragment, 0, 64) dealloc_stack %field_x : $*Int dealloc_stack %my_struct: $*MyStruct %r = tuple() return %r : $() } sil_scope 3 { loc "file.swift":16:7 parent @test_op_const : $@convention(thin) (Int64, Int64) -> () } // Testing op_constu and op_consts sil hidden @test_op_const : $@convention(thin) (Int64, Int64) -> () { bb0(%arg : $Int64, %arg2 : $Int64): debug_value %arg : $Int64, let, name "the_arg", argno 1, expr op_constu:77, loc "file.swift":17:2, scope 3 debug_value %arg2 : $Int64, let, name "the_2nd_arg", argno 2, expr op_consts:-87, loc "file.swift":17:4, scope 3 %r = tuple() return %r : $() } sil_scope 4 { loc "file.swift":18:8 parent @test_arithmetic : $@convention(thin) (Int64, Int64) -> () } // Testing basic arithmetic operators like op_plus and op_minus sil hidden @test_arithmetic : $@convention(thin) (Int64, Int64) -> () { bb0(%arg : $Int64, %arg2 : $Int64): debug_value %arg : $Int64, let, name "the_arg", argno 1, expr op_constu:3:op_plus, loc "file.swift":19:2, scope 4 debug_value %arg2 : $Int64, let, name "the_2nd_arg", argno 2, expr op_constu:5:op_minus, loc "file.swift":19:4, scope 4 %r = tuple() return %r : $() }