File: class_resilience.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 (43 lines) | stat: -rw-r--r-- 2,324 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
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module -enable-library-evolution -emit-module-path=%t/resilient_struct.swiftmodule -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
// RUN: %target-swift-frontend -emit-module -enable-library-evolution -emit-module-path=%t/resilient_class.swiftmodule -module-name=resilient_class %S/../Inputs/resilient_class.swift -I %t
// RUN: %target-swift-frontend -enable-objc-interop -I %t -emit-ir -enable-library-evolution %s | %FileCheck %s --check-prefixes=CHECK,CHECK-objc
// RUN: %target-swift-frontend -disable-objc-interop -I %t -emit-ir -enable-library-evolution %s | %FileCheck %s --check-prefixes=CHECK,CHECK-native
// RUN: %target-swift-frontend -I %t -emit-ir -enable-library-evolution -O %s

// REQUIRES: CPU=x86_64

sil_stage canonical

import Builtin
import Swift
import SwiftShims

import resilient_class

// Make sure that an alloc_ref of a resilient class loads the size and alignment
// of the instance from metadata.
//
// Perhaps we should not serialize allocating initializers, then this would not
// be an issue.

// CHECK-LABEL: define {{(dllexport )?}}{{(protected )?}}swiftcc void @allocResilientOutsideParent()
// CHECK:      [[T0:%.*]] = call swiftcc %swift.metadata_response @"$s15resilient_class22ResilientOutsideParentCMa"(i64 0)
// CHECK-NEXT: [[META:%.*]] = extractvalue %swift.metadata_response [[T0]], 0
// CHECK-objc-NEXT: [[SIZE_ADDR:%.*]] = getelementptr inbounds i8, ptr [[META]], i32 48
// CHECK-native-NEXT: [[SIZE_ADDR:%.*]] = getelementptr inbounds i8, ptr [[META]], i32 24
// CHECK-NEXT: [[SIZE_2:%.*]] = load i32, ptr [[SIZE_ADDR]], align 8
// CHECK-NEXT: [[SIZE:%.*]] = zext i32 [[SIZE_2]] to i64
// CHECK-objc-NEXT: [[ALIGN_ADDR:%.*]] = getelementptr inbounds i8, ptr [[META]], i32 52
// CHECK-native-NEXT: [[ALIGN_ADDR:%.*]] = getelementptr inbounds i8, ptr [[META]], i32 28
// CHECK-NEXT: [[ALIGN_2:%.*]] = load i16, ptr [[ALIGN_ADDR]], align 4
// CHECK-NEXT: [[ALIGN:%.*]] = zext i16 [[ALIGN_2]] to i64
// CHECK-NEXT: call noalias ptr @swift_allocObject(ptr [[META]], i64 [[SIZE]], i64 [[ALIGN]])

sil @allocResilientOutsideParent : $@convention(thin) () -> () {
bb0:
  %c = alloc_ref $ResilientOutsideParent
  strong_release %c : $ResilientOutsideParent
  %result = tuple ()
  return %result : $()
}