File: raw_layout_multifile.swift

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 (59 lines) | stat: -rw-r--r-- 1,969 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
// 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 -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

@_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
}