File: loadable_by_address_issue73018.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 (87 lines) | stat: -rw-r--r-- 5,502 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// RUN: %target-swift-frontend %s  -Xllvm -sil-print-after=loadable-address -Xllvm -verify-continue-on-failure -c -o %t/t.o 2>&1 | %FileCheck %s

// This used to trigger an assertion due to LoadableByAddress not doing proper mapping of
// switch_enum arguments during rewriting

import Builtin
import Swift

typealias X = Int
typealias LargeX = (() -> X, () -> X, () -> X, () -> X, () -> X, () -> X, () -> X, () -> X, () -> X)

enum enum1 {
case bb0(LargeX)
}

enum enum2 {
case bb0(LargeX)
}

enum large_enum {
case bb1((enum1, X))
case bb2((enum2, X))
}

sil @test1 : $@convention(thin) (@guaranteed large_enum) -> () {
// CHECK-LABEL: sil @test1
bb0(%arg : $large_enum):
  %loc = alloc_stack $(@callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
                       @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
                       @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
                       @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,                       
                       @callee_guaranteed () -> @owned X)
  switch_enum %arg : $large_enum, case #large_enum.bb1!enumelt: bb1, case #large_enum.bb2!enumelt: bb2

bb1(%e1 : $(enum1, X)):
  // CHECK: %[[ADDR1:.*]] = unchecked_take_enum_data_addr %{{.*}} : $*enum1, #enum1.bb0!enumelt
  // CHECK: copy_addr [take] %[[ADDR1]] to [init] %1 : $*(@callee_guaranteed () -> @owned Int, @callee_guaranteed () -> @owned Int, @callee_guaranteed () -> @owned Int, @callee_guaranteed () -> @owned Int, @callee_guaranteed () -> @owned Int, @callee_guaranteed () -> @owned Int, @callee_guaranteed () -> @owned Int, @callee_guaranteed () -> @owned Int, @callee_guaranteed () -> @owned Int)
  %e11 = tuple_extract %e1 : $(enum1, X), 0
  switch_enum %e11 : $enum1, case #enum1.bb0!enumelt: bb11

bb11(%p1 : $((@callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
              @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
              @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,              
              @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
              @callee_guaranteed () -> @owned X))):
  br bb3(%p1 : $((@callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
                  @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
                  @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
                  @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,                  
                  @callee_guaranteed () -> @owned X)))                      

bb2(%e2 : $(enum2, X)):
  // CHECK: %[[ADDR2:.*]] = unchecked_take_enum_data_addr %{{.*}} : $*enum2, #enum2.bb0!enumelt
  // CHECK: copy_addr [take] %[[ADDR2]] to [init] %1 : $*(@callee_guaranteed () -> @owned Int, @callee_guaranteed () -> @owned Int, @callee_guaranteed () -> @owned Int, @callee_guaranteed () -> @owned Int, @callee_guaranteed () -> @owned Int, @callee_guaranteed () -> @owned Int, @callee_guaranteed () -> @owned Int, @callee_guaranteed () -> @owned Int, @callee_guaranteed () -> @owned Int)
  %e22 = tuple_extract %e2 : $(enum2, X), 0
  switch_enum %e22 : $enum2, case #enum2.bb0!enumelt: bb22

bb22(%p2 : $((@callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
              @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
              @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
              @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
              @callee_guaranteed () -> @owned X))):
  br bb3(%p2 : $((@callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
                  @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,  
                  @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
                  @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,            
                  @callee_guaranteed () -> @owned X)))                      

bb3(%p3 : $((@callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
             @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
             @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
             @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,              
             @callee_guaranteed () -> @owned X))):
  store %p3 to %loc : $*(@callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
                         @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
                         @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
                         @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,              
                         @callee_guaranteed () -> @owned X)
            
  dealloc_stack %loc : $*(@callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
                          @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
                          @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,
                          @callee_guaranteed () -> @owned X, @callee_guaranteed () -> @owned X,              
                          @callee_guaranteed () -> @owned X)
  %t = tuple ()
  return %t : $()
}