File: unused.sil

package info (click to toggle)
swiftlang 6.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,604 kB
  • sloc: cpp: 9,901,740; 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 (68 lines) | stat: -rw-r--r-- 2,722 bytes parent folder | download | duplicates (2)
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
// RUN: %target-swift-frontend -disable-autolinking-runtime-compatibility-concurrency -disable-autolinking-runtime-compatibility-dynamic-replacements -runtime-compatibility-version none -primary-file %s -emit-ir | %FileCheck -check-prefix CHECK -check-prefix NEGATIVE -check-prefix CHECK-%target-object-format %s

// REQUIRES: CPU=x86_64

sil_stage canonical
import Builtin
import Swift

sil private @foo : $@convention(thin) () -> () {
bb0:
  %0 = function_ref @bar : $@convention(thin) () -> ()
  %1 = apply %0() : $@convention(thin) () -> ()
  return %1 : $()
}

sil public_external [serialized] @bar : $@convention(thin) () -> () {
bb0:
  %1 = tuple ()
  return %1 : $()
}

sil shared @baz : $@convention(thin) () -> () {
bb0:
  %0 = function_ref @bar : $@convention(thin) () -> ()
  %1 = apply %0() : $@convention(thin) () -> ()
  return %1 : $()
}

sil shared @qux : $@convention(thin) () -> () {
bb0:
  %1 = tuple ()
  return %1 : $()
}

sil hidden @fred : $@convention(thin) () -> () {
bb0:
  %0 = function_ref @qux : $@convention(thin) () -> ()
  %1 = apply %0() : $@convention(thin) () -> ()
  return %1 : $()
}

sil @frieda : $@convention(thin) () -> () {
bb0:
  %1 = tuple ()
  return %1 : $()
}

sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  %2 = integer_literal $Builtin.Int32, 0          // user: %3
  %3 = struct $Int32 (%2 : $Builtin.Int32)        // user: %4
  return %3 : $Int32                              // id: %4
}

// CHECK-macho: @"\01l_entry_point" = private constant { i32, i32 } { i32 trunc (i64 sub (i64 ptrtoint (ptr @main to i64), i64 ptrtoint (ptr @"\01l_entry_point" to i64)) to i32), i32 0 }, section "__TEXT, __swift5_entry, regular, no_dead_strip", align 4
// CHECK-elf: @"\01l_entry_point" = private constant { i32, i32 } { i32 trunc (i64 sub (i64 ptrtoint (ptr @main to i64), i64 ptrtoint (ptr @"\01l_entry_point" to i64)) to i32), i32 0 }, section "swift5_entry", align 4

// CHECK-macho: @llvm.used = appending global [4 x ptr] [ptr @frieda, ptr @main, ptr @"\01l_entry_point", ptr @__swift_reflection_version], section "llvm.metadata"
// CHECK-elf: @llvm.used = appending global [5 x ptr] [ptr @frieda, ptr @main, ptr @"\01l_entry_point", ptr @__swift_reflection_version, ptr @_swift1_autolink_entries], section "llvm.metadata"

// CHECK: define linkonce_odr hidden swiftcc void @qux()
// CHECK: define hidden swiftcc void @fred()
// CHECK: define{{( dllexport)?}}{{( protected)?}} swiftcc void @frieda()
// CHECK: define{{( dllexport)?}}{{( protected)?}} i32 @main

// NEGATIVE-NOT: @foo
// NEGATIVE-NOT: @bar
// NEGATIVE-NOT: @baz