File: metadata_lookup_generic_objc.sil

package info (click to toggle)
swiftlang 6.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,532 kB
  • sloc: cpp: 9,901,743; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (44 lines) | stat: -rw-r--r-- 2,259 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
// RUN: %empty-directory(%t)
// RUN: %build-irgen-test-overlays
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/Inputs -I %t) %s -emit-ir | %FileCheck %s

// REQUIRES: objc_interop

import Builtin
import Swift
import gizmo

protocol Q<T> {
  associatedtype T
  func f()
}

// This used to assert/crash on a local type metadata lookup.

sil @metadata_lookup_crash : $@convention(method) (@in_guaranteed any Q<ObjcGenericClass<Gizmo>>, Builtin.Int1) -> () {
bb0(%0 : $*any Q<ObjcGenericClass<Gizmo>>, %1: $Builtin.Int1):
  %2 = open_existential_addr immutable_access %0 : $*any Q<ObjcGenericClass<Gizmo>> to $*@opened("AA505436-9CC9-11EF-8085-32F16C24A34B", any Q<ObjcGenericClass<Gizmo>>) Self
  %3 = witness_method $@opened("AA505436-9CC9-11EF-8085-32F16C24A34B", any Q<ObjcGenericClass<Gizmo>>) Self, #Q.f : <Self where Self : Q> (Self) -> () -> (), %2 : $*@opened("AA505436-9CC9-11EF-8085-32F16C24A34B", any Q<ObjcGenericClass<Gizmo>>) Self : $@convention(witness_method: Q) <τ_0_0 where τ_0_0 : Q> (@in_guaranteed τ_0_0) -> ()
  %4 = apply %3<@opened("AA505436-9CC9-11EF-8085-32F16C24A34B", any Q<ObjcGenericClass<Gizmo>>) Self>(%2) : $@convention(witness_method: Q) <τ_0_0 where τ_0_0 : Q> (@in_guaranteed τ_0_0) -> ()
  cond_br %1, bb1, bb2

bb1:
  br bb3

bb2:
  %5 = open_existential_addr immutable_access %0 : $*any Q<ObjcGenericClass<Gizmo>> to $*@opened("AA505436-9CC9-11EF-8085-42F16C24A34B", any Q<ObjcGenericClass<Gizmo>>) Self
  %6 = witness_method $@opened("AA505436-9CC9-11EF-8085-42F16C24A34B", any Q<ObjcGenericClass<Gizmo>>) Self, #Q.f : <Self where Self : Q> (Self) -> () -> (), %5 : $*@opened("AA505436-9CC9-11EF-8085-42F16C24A34B", any Q<ObjcGenericClass<Gizmo>>) Self : $@convention(witness_method: Q) <τ_0_0 where τ_0_0 : Q> (@in_guaranteed τ_0_0) -> ()
  %7 = apply %6<@opened("AA505436-9CC9-11EF-8085-42F16C24A34B", any Q<ObjcGenericClass<Gizmo>>) Self>(%5) : $@convention(witness_method: Q) <τ_0_0 where τ_0_0 : Q> (@in_guaranteed τ_0_0) -> ()
  br bb3

bb3:
  %t = tuple ()
  return %t : $()
}

// CHECK: define swiftcc void @metadata_lookup_crash
// CHECK:   call ptr @__swift_project_boxed_opaque_existential_1
// CHECK:   br i1

// CHECK:   call ptr @__swift_project_boxed_opaque_existential_1
// CHECK:   ret void