File: unused.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 (68 lines) | stat: -rw-r--r-- 2,722 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
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