File: multithread_module.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 (79 lines) | stat: -rw-r--r-- 2,368 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
69
70
71
72
73
74
75
76
77
78
79
// RUN: %empty-directory(%t)

// RUN: %target-swift-frontend %S/Inputs/multithread_module/main.swift -emit-ir -o %t/main.ll %/s -o %t/mt_module.ll -num-threads 2 -O -g -module-name test
// RUN: %FileCheck --check-prefix=CHECK-MAINLL %s <%t/main.ll
// RUN: %FileCheck --check-prefix=CHECK-MODULELL %s <%t/mt_module.ll

// RUN: %target-swift-frontend -c %S/Inputs/multithread_module/main.swift -o %t/main.o %s -o %t/mt_module.o -num-threads 2 -O -g -module-name test
// RUN: %target-build-swift %t/main.o %t/mt_module.o -o %t/a.out
// RUN: %target-codesign %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s
// REQUIRES: executable_test
// REQUIRES: optimized_stdlib,swift_stdlib_no_asserts


// Test compilation of a module in multi-threaded compilation.
// The main purpose of the test is to check that the generated LLVM modules are not corrupt
// and that linking succeeds.

// CHECK: 28
// CHECK: 125
// CHECK: 42
// CHECK: 237

public func testit(_ x: Int) -> Int {
	return incrementit(x)
}

public class Base {
	func memberfunc(_ x: Int) -> Int {
		return x + 1
	}
}

public var g2 = 123

@inline(never)
func callmember(_ b: Base) -> Int {
	return b.memberfunc(g2)
}

@inline(never)
private func privateInc(_ x: Int) -> Int {
	return x + 3
}

func callPrivInc(_ x: Int) -> Int {
	return privateInc(x)
}

// Check if we use the correct linkage for a transparent function
public var transparentfuncptr = transparentfunc

protocol MyProto {
	func protofunc() -> Int
}

@inline(never)
func callproto(_ p: MyProto) {
	print(p.protofunc())
}

public func mutateBaseArray(_ arr: inout [Base], _ x: Base) {
  arr.append(x)
}


// Check the llvm IR files:

// Check if all specializations from stdlib functions are created in the same LLVM module.

// CHECK-MAINLL-DAG: define {{.*}} @"$ss{{(12_|22_Contiguous)}}ArrayBufferV20_consumeAndCreateNew14bufferIsUnique15minimumCapacity13growForAppendAByxGSb_SiSbtF4test8MyStructV_Tg5"

// Check if the DI filename is correct and not "<unknown>".

// CHECK-MAINLL: [[F:![0-9]+]] = !DIFile(filename: "{{.*}}IRGen/Inputs/multithread_module/main.swift", directory: "{{.*}}")
// CHECK-MAINLL: DICompileUnit(language: DW_LANG_Swift, file: [[F]],

// CHECK-MODULELL: [[F:![0-9]]] = !DIFile(filename: "{{.*}}IRGen/multithread_module.swift", directory: "{{.*}}")
// CHECK-MODULELL: DICompileUnit(language: DW_LANG_Swift, file: [[F]],