File: sil_combine.sil

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (73 lines) | stat: -rw-r--r-- 2,519 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// RUN: %target-sil-opt -sil-verify-all -sil-combine %s | %FileCheck %s
// RUN: %target-swift-frontend -g -O -emit-ir -primary-file %s | %FileCheck --check-prefix=CHECK-IR %s

sil_stage canonical

import Builtin
import Swift

// CHECK-LABEL: sil {{.*}} @test_nested_index_addr
// CHECK-IR-LABEL: define {{.*}} @test_nested_index_addr
sil hidden @test_nested_index_addr : $@convention(thin) (Builtin.RawPointer) -> Builtin.RawPointer {
bb0(%0 : $Builtin.RawPointer):
  %offset1 = integer_literal $Builtin.Word, 3
  %offset2 = integer_literal $Builtin.Word, 7
  // CHECK: %[[ADDR:.+]] = pointer_to_address %0
  %addr = pointer_to_address %0 : $Builtin.RawPointer to [strict] $*UInt8
  %addr1 = index_addr %addr : $*UInt8, %offset1 : $Builtin.Word
  // CHECK: debug_value %[[ADDR]] : $*UInt8, let, name "hello"
  // CHECK-SAME: expr op_constu:3:op_plus:op_deref
  // CHECK-IR: call void @llvm.dbg.value(metadata ptr %0, metadata ![[DBG_VAR:[0-9]+]],
  // CHECK-IR-SAME: !DIExpression(DW_OP_constu, 3, DW_OP_plus, DW_OP_deref)
  debug_value %addr1 : $*UInt8, let, name "hello", expr op_deref
  %addr2 = index_addr %addr1 : $*UInt8, %offset2 : $Builtin.Word
  %ptr = address_to_pointer %addr2 : $*UInt8 to $Builtin.RawPointer
  return %ptr : $Builtin.RawPointer
}

public struct S {}
public struct C {
  var x: MP
}

enum MP {
  case A(S)
  case B(S)
}

// CHECK-LABEL: sil @expand_alloc_stack_of_enum_without_take
// CHECK:        [[A:%[0-9]+]] = alloc_stack $S
// CHECK-NOT:      name "a"
// CHECK-NEXT:   debug_value undef : $*MP, let, name "a", expr op_fragment:#C.x
// CHECK-NEXT:   debug_value undef : $*MP, let, name "b"
// CHECK:      bb1:
// CHECK-NEXT:   store %0 to [[A]]
// CHECK:      bb2:
// CHECK-NEXT:   store %0 to [[A]]
// CHECK:      bb3:
// CHECK:        destroy_addr [[A]]
// CHECK: } // end sil function 'expand_alloc_stack_of_enum_without_take'
sil @expand_alloc_stack_of_enum_without_take : $@convention(method) (S) -> () {
bb0(%0 : $S):
  %1 = alloc_stack $MP, let, name "a", expr op_fragment:#C.x
  debug_value %1 : $*MP, let, name "b", expr op_deref
  cond_br undef, bb1, bb2
bb1:
  %2 = init_enum_data_addr %1 : $*MP, #MP.A!enumelt
  store %0 to %2 : $*S
  inject_enum_addr %1 : $*MP, #MP.A!enumelt
  br bb3
bb2:
  %3 = init_enum_data_addr %1 : $*MP, #MP.A!enumelt
  store %0 to %3 : $*S
  inject_enum_addr %1 : $*MP, #MP.A!enumelt
  br bb3
bb3:
  destroy_addr %1 : $*MP
  dealloc_stack %1 : $*MP
  %11 = tuple ()
  return %11 : $()
}


// CHECK-IR: ![[DBG_VAR]] = !DILocalVariable(name: "hello"