File: raw_layout_multifile.swift

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 (62 lines) | stat: -rw-r--r-- 2,094 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
// RUN: %empty-directory(%t)
// RUN: %{python} %utils/chex.py < %s > %t/raw_layout_multifile.swift
// RUN: %target-swift-frontend -enable-experimental-feature BuiltinModule -enable-experimental-feature RawLayout -emit-ir -O -Xllvm -sil-disable-pass=deinit-devirtualizer -disable-availability-checking %s %S/Inputs/raw_layout_multifile_b.swift | %FileCheck %t/raw_layout_multifile.swift --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize

// REQUIRES: swift_feature_BuiltinModule
// REQUIRES: swift_feature_RawLayout

@_rawLayout(like: Int32)
public struct Foo<T>: ~Copyable {}

// CHECK-LABEL: @"$s{{[A-Za-z0-9_]*}}5MyIntVWV" = {{.*}} %swift.vwtable
// size
// CHECK-SAME:  , {{i64|i32}} 4
// stride
// CHECK-SAME:  , {{i64|i32}} 4
// flags: alignment 3, noncopyable, non-bitwise-borrowable
// CHECK-SAME:  , <i32 0x1800003>
struct MyInt: ~Copyable {
  let x: Int32Fake
}

// CHECK-LABEL: @"$s{{[A-Za-z0-9_]*}}9BadBufferVWV" = {{.*}} %swift.vwtable
// size
// CHECK-SAME:  , {{i64|i32}} 48
// stride
// CHECK-SAME:  , {{i64|i32}} 48
// flags: alignment 7, noncopyable, non-bitwise-borrowable, is not inline
// CHECK-SAME:  , <i32 0x1820007>
struct BadBuffer: ~Copyable {
  let buf = SmallVectorOf3<Int64?>()
}

// CHECK-LABEL: @"$s{{[A-Za-z0-9_]*}}5WeirdVWV" = {{.*}} %swift.vwtable
// size
// CHECK-SAME:  , {{i64|i32}} 8
// stride
// CHECK-SAME:  , {{i64|i32}} 8
// flags-32: alignment 7, noncopyable, non-bitwise-borrowable, is not inline
// CHECK-SAME-32:  , <i32 0x1820007>
// flags-64: alignment 7, noncopyable, non-bitwise-borrowable
// CHECK-SAME-64:  , <i32 0x1800007>
struct Weird: ~Copyable {
  let value = UnsafeCell<Int64>()
}

// Force emission of Weird's descriptor to be lazy...
public func something() -> Int64 {
  let x = Weird()
  return x.value.address.pointee
}

// Force emission of BadBuffer's descriptor to be lazy...
public func something2() -> Int64? {
  let buf = BadBuffer()
  return buf.buf.address[1]
}

// Force emission of MyInt's descriptor to be lazy...
public func something3() -> Int32 {
  let x = MyInt(x: Int32Fake())
  return x.x.address.pointee
}