mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[IRGen] Correctly assign lazily-emitted global variables in multi-threaded IRGen
With multi-threaded IRGen, the global variables associated with "once" initialization tokens were not getting colocated with their actual global variables, which caused the initialization code to get split across different files. This issue manifest as autolinking errors in some projects. Fixes rdar://162400654.
This commit is contained in:
24
test/IRGen/multithread_global_var.swift
Normal file
24
test/IRGen/multithread_global_var.swift
Normal file
@@ -0,0 +1,24 @@
|
||||
// RUN: %empty-directory(%t/src)
|
||||
// RUN: split-file %s %t/src
|
||||
|
||||
// RUN: %target-swift-frontend %t/src/A.swift %t/src/B.swift -emit-ir -o %t/A.ll -o %t/B.ll -num-threads 2 -O -g -module-name test
|
||||
// RUN: %FileCheck --check-prefix=CHECK-A %s <%t/A.ll
|
||||
// RUN: %FileCheck --check-prefix=CHECK-B %s <%t/B.ll
|
||||
|
||||
//--- A.swift
|
||||
|
||||
public func f() -> String { "hello" }
|
||||
|
||||
public func g() -> Bool {
|
||||
f() == X.introduction
|
||||
}
|
||||
|
||||
// CHECK-A: @"$s4test1XV12introduction_Wz" = external hidden global
|
||||
|
||||
//--- B.swift
|
||||
|
||||
public struct X {
|
||||
public static var introduction: String = f().uppercased()
|
||||
}
|
||||
|
||||
// CHECK-B: @"$s4test1XV12introduction_Wz" = weak_odr hidden global
|
||||
Reference in New Issue
Block a user