Skip to content

Commit dcb905d

Browse files
Merge pull request #81352 from AnthonyLatsis/rebranch
Manually merge branch 'main' into rebranch
2 parents 1c887a8 + 0c53692 commit dcb905d

File tree

361 files changed

+6502
-8573
lines changed

Some content is hidden

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

361 files changed

+6502
-8573
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@
223223
/test/Generics/ @hborla @slavapestov
224224
/test/Generics/inverse* @kavon
225225
/test/IDE/ @ahoppen @bnbarham @hamishknight @rintaro
226-
/test/IRGen/ @rjmccall
226+
/test/IRGen/ @AnthonyLatsis @rjmccall
227227
/test/Index/ @ahoppen @bnbarham @hamishknight @rintaro
228228
/test/Interop/ @zoecarver @egorzhdan @Xazax-hun @j-hui @fahadnayyar @susmonteiro @hnrklssn
229229
/test/Macros/SwiftifyImport @hnrklssn @Xazax-hun

Runtimes/Core/core/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ add_library(swiftCore
188188
StringWordBreaking.swift
189189
Substring.swift
190190
SwiftNativeNSArray.swift
191-
SwiftSettings.swift
192191
TemporaryAllocation.swift
193192
ThreadLocalStorage.swift
194193
UIntBuffer.swift

SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ struct AliasAnalysis {
262262
case let copy as SourceDestAddrInstruction:
263263
let mayRead = memLoc.mayAlias(with: copy.source, self)
264264
let mayWrite = memLoc.mayAlias(with: copy.destination, self)
265-
var effects = SideEffects.Memory(read: mayRead, write: mayWrite || (mayRead && copy.isTakeOfSrc))
266-
if !copy.isInitializationOfDest {
265+
var effects = SideEffects.Memory(read: mayRead, write: mayWrite || (mayRead && copy.isTakeOfSource))
266+
if !copy.isInitializationOfDestination {
267267
effects.merge(with: defaultEffects(of: copy, on: memLoc))
268268
}
269269
return effects

SwiftCompilerSources/Sources/Optimizer/DataStructures/Set.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,44 @@ struct SpecificInstructionSet<InstType: Instruction> : IntrusiveSet {
177177
}
178178
}
179179

180+
/// An `InstructionSet` which also provides a `count` property.
181+
struct SpecificInstructionSetWithCount<InstType: Instruction> : IntrusiveSet {
182+
private(set) var count = 0
183+
private var underlyingSet: SpecificInstructionSet<InstType>
184+
185+
init(_ context: some Context) {
186+
self.underlyingSet = SpecificInstructionSet(context)
187+
}
188+
189+
func contains(_ inst: InstType) -> Bool { underlyingSet.contains(inst) }
190+
191+
var isEmpty: Bool { count == 0 }
192+
193+
/// Returns true if `inst` was not contained in the set before inserting.
194+
@discardableResult
195+
mutating func insert(_ inst: InstType) -> Bool {
196+
if underlyingSet.insert(inst) {
197+
count += 1
198+
return true
199+
}
200+
return false
201+
}
202+
203+
mutating func erase(_ inst: InstType) {
204+
if underlyingSet.contains(inst) {
205+
count -= 1
206+
assert(count >= 0)
207+
}
208+
underlyingSet.erase(inst)
209+
}
210+
211+
var description: String { underlyingSet.description }
212+
213+
mutating func deinitialize() { underlyingSet.deinitialize() }
214+
}
215+
180216
typealias InstructionSet = SpecificInstructionSet<Instruction>
217+
typealias InstructionSetWithCount = SpecificInstructionSetWithCount<Instruction>
181218

182219
/// A set of operands.
183220
///

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ swift_compiler_sources(Optimizer
3333
SimplificationPasses.swift
3434
StackPromotion.swift
3535
StripObjectHeaders.swift
36+
TempRValueElimination.swift
3637
)

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ComputeSideEffects.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ private struct CollectedEffects {
108108
addEffects(.read, to: copy.source)
109109
addEffects(.write, to: copy.destination)
110110

111-
if !copy.isTakeOfSrc {
111+
if !copy.isTakeOfSource {
112112
addEffects(.copy, to: copy.source)
113113
}
114-
if !copy.isInitializationOfDest {
114+
if !copy.isInitializationOfDestination {
115115
addDestroyEffects(ofAddress: copy.destination)
116116
}
117117

@@ -494,7 +494,7 @@ private struct ArgumentEscapingWalker : ValueDefUseWalker, AddressDefUseWalker {
494494
case let copy as CopyAddrInst:
495495
if address == copy.sourceOperand &&
496496
!address.value.hasTrivialType &&
497-
(!function.hasOwnership || copy.isTakeOfSrc) {
497+
(!function.hasOwnership || copy.isTakeOfSource) {
498498
foundTakingLoad = true
499499
}
500500
return .continueWalk

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LetPropertyLowering.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private func constructLetInitRegion(
153153

154154
case let copy as CopyAddrInst
155155
where copy.destination.isLetFieldAddress(of: markUninitialized):
156-
assert(copy.isInitializationOfDest)
156+
assert(copy.isInitializationOfDestination)
157157
initRegion.insert(inst)
158158

159159
case let beginAccess as BeginAccessInst

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceDiagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ private struct LifetimeVariable {
342342

343343
private init(introducer: Value, _ context: some Context) {
344344
if let arg = introducer as? FunctionArgument {
345-
self.varDecl = arg.varDecl
345+
self.varDecl = arg.findVarDecl()
346346
self.sourceLoc = arg.sourceLoc
347347
self.isArgument = true
348348
self.isClosureCapture = arg.isClosureCapture

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceScopeFixup.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -194,19 +194,7 @@ private func createEndCOWMutationIfNeeded(lifetimeDep: LifetimeDependence, _ con
194194
}
195195
scoped = beginApply
196196
// None of the below cases can generate a mutable address.
197-
case let .owned:
198-
fallthrough
199-
case let .borrowed:
200-
fallthrough
201-
case let .local:
202-
fallthrough
203-
case let .initialized:
204-
fallthrough
205-
case let .caller:
206-
fallthrough
207-
case let .global:
208-
fallthrough
209-
case let .unknown:
197+
case .owned, .borrowed, .local, .initialized, .caller, .global, .unknown:
210198
return
211199
}
212200

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/NamedReturnValueOptimization.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private func findCopyForNRVO(for outArg: FunctionArgument) -> CopyAddrInst? {
7878
// %local = alloc_stack $T
7979
// store %in to %local : $*T
8080
// copy_addr %local to [init] %out : $*T
81-
if !copyToArg.isTakeOfSrc {
81+
if !copyToArg.isTakeOfSource {
8282
return nil
8383
}
8484

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/RedundantLoadElimination.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ extension CopyAddrInst : LoadingInstruction {
158158
return false
159159
}
160160
if !parentFunction.hasOwnership {
161-
if !isTakeOfSrc || !isInitializationOfDest {
161+
if !isTakeOfSource || !isInitializationOfDestination {
162162
// For simplicity, bail if we would have to insert compensating retains and releases.
163163
return false
164164
}

0 commit comments

Comments
 (0)