mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Optimizer: support static initialization of global arrays
The buffer of global arrays could already be statically initialized. The missing piece was the array itself, which is basically a reference to the array buffer. For example: ``` var a = [1, 2, 3] ``` ends up in two statically initialized globals: 1. the array buffer, which contains the elements 2. the variable `a` which is a single reference (= pointer) of the array buffer This optimization removes the need for lazy initialization of such variables. rdar://127757554
This commit is contained in:
@@ -250,7 +250,7 @@ private func getInitializerFromInitFunction(of globalAddr: GlobalAddrInst, _ con
|
||||
}
|
||||
let initFn = initFnRef.referencedFunction
|
||||
context.notifyDependency(onBodyOf: initFn)
|
||||
guard let (_, storeToGlobal) = getGlobalInitialization(of: initFn, allowGlobalValue: true) else {
|
||||
guard let (_, storeToGlobal) = getGlobalInitialization(of: initFn, forStaticInitializer: false, context) else {
|
||||
return nil
|
||||
}
|
||||
return storeToGlobal.source
|
||||
|
||||
Reference in New Issue
Block a user