Skip to content

Commit 186f1b3

Browse files
committed
InitializeStaticGlobals: don't merge stores to non-copyable types
A transformation must not create a `struct` instruction with a non-copyable type because this would apply that a (potential) deinit would be called for that struct.
1 parent 7752fbf commit 186f1b3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/InitializeStaticGlobals.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ private func getSequenceOfElementStores(firstStore: StoreInst) -> ([StoreInst],
181181
return nil
182182
}
183183
let structAddr = elementAddr.struct
184+
if structAddr.type.isMoveOnly {
185+
return nil
186+
}
184187
let numElements = structAddr.type.getNominalFields(in: firstStore.parentFunction).count
185188
var elementStores = Array<StoreInst?>(repeating: nil, count: numElements)
186189
var numStoresFound = 0

0 commit comments

Comments
 (0)