Skip to content

Commit d33bd9f

Browse files
Merge pull request #5462 from swiftwasm/main
[pull] swiftwasm from main
2 parents cf0de40 + 767fdfc commit d33bd9f

File tree

113 files changed

+3079
-1731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+3079
-1731
lines changed

SwiftCompilerSources/Sources/Basic/Utils.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,21 @@ public struct StringRef : CustomStringConvertible, NoReflectionChildren {
6464

6565
public var string: String { _bridged.string }
6666
public var description: String { string }
67-
67+
68+
public var count: Int {
69+
Int(_bridged.__bytes_endUnsafe() - _bridged.__bytes_beginUnsafe())
70+
}
71+
72+
public subscript(index: Int) -> UInt8 {
73+
let buffer = UnsafeBufferPointer<UInt8>(start: _bridged.__bytes_beginUnsafe(),
74+
count: count)
75+
return buffer[index]
76+
}
77+
6878
public static func ==(lhs: StringRef, rhs: StaticString) -> Bool {
6979
let lhsBuffer = UnsafeBufferPointer<UInt8>(
7080
start: lhs._bridged.__bytes_beginUnsafe(),
71-
count: Int(lhs._bridged.__bytes_endUnsafe() - lhs._bridged.__bytes_beginUnsafe()))
81+
count: lhs.count)
7282
return rhs.withUTF8Buffer { (rhsBuffer: UnsafeBufferPointer<UInt8>) in
7383
if lhsBuffer.count != rhsBuffer.count { return false }
7484
return lhsBuffer.elementsEqual(rhsBuffer, by: ==)

SwiftCompilerSources/Sources/Optimizer/DataStructures/Worklist.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,4 @@ struct Worklist<Set: IntrusiveSet> : CustomStringConvertible, NoReflectionChildr
7474

7575
typealias BasicBlockWorklist = Worklist<BasicBlockSet>
7676
typealias InstructionWorklist = Worklist<InstructionSet>
77+
typealias ValueWorklist = Worklist<ValueSet>

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ swift_compiler_sources(Optimizer
1212
ComputeEscapeEffects.swift
1313
ComputeSideEffects.swift
1414
InitializeStaticGlobals.swift
15+
ObjectOutliner.swift
1516
ObjCBridgingOptimization.swift
1617
MergeCondFails.swift
1718
NamedReturnValueOptimization.swift

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/InitializeStaticGlobals.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ let initializeStaticGlobalsPass = FunctionPass(name: "initialize-static-globals"
5656
return
5757
}
5858

59-
context.createStaticInitializer(for: allocInst.global,
60-
initValue: storeToGlobal.source as! SingleValueInstruction)
59+
var cloner = StaticInitCloner(cloneTo: allocInst.global, context)
60+
defer { cloner.deinitialize() }
61+
62+
_ = cloner.clone(storeToGlobal.source)
63+
6164
context.erase(instruction: allocInst)
6265
context.erase(instruction: storeToGlobal)
6366
}

0 commit comments

Comments
 (0)