From 949c2bad6787b575504b691e1b4a9d262c07e52e Mon Sep 17 00:00:00 2001 From: Valeriy Van Date: Sun, 8 Jun 2025 11:22:45 +0300 Subject: [PATCH 1/4] Fix some typos in SwiftCompilerSources/Sources --- .../Sources/AST/SubstitutionMap.swift | 2 +- .../Sources/Optimizer/Analysis/AliasAnalysis.swift | 14 +++++++------- .../DataStructures/InstructionRange.swift | 2 +- .../FunctionPasses/CopyToBorrowOptimization.swift | 2 +- .../FunctionPasses/DeadStoreElimination.swift | 2 +- .../LifetimeDependenceDiagnostics.swift | 8 ++++---- .../LifetimeDependenceInsertion.swift | 6 +++--- .../LifetimeDependenceScopeFixup.swift | 6 +++--- .../FunctionPasses/ObjCBridgingOptimization.swift | 4 ++-- .../Optimizer/FunctionPasses/StackPromotion.swift | 2 +- .../SimplifyMarkDependence.swift | 2 +- .../Sources/Optimizer/Utilities/BorrowUtils.swift | 2 +- .../Optimizer/Utilities/ForwardingUtils.swift | 2 +- .../Utilities/GenericSpecialization.swift | 4 ++-- .../Utilities/LifetimeDependenceUtils.swift | 12 ++++++------ .../Optimizer/Utilities/LocalVariableUtils.swift | 4 ++-- .../Optimizer/Utilities/OwnershipLiveness.swift | 2 +- SwiftCompilerSources/Sources/SIL/Function.swift | 2 +- SwiftCompilerSources/Sources/SIL/Operand.swift | 2 +- .../Sources/SIL/Utilities/AccessUtils.swift | 4 ++-- 20 files changed, 42 insertions(+), 42 deletions(-) diff --git a/SwiftCompilerSources/Sources/AST/SubstitutionMap.swift b/SwiftCompilerSources/Sources/AST/SubstitutionMap.swift index 494a55e35749d..c967fe543b1d6 100644 --- a/SwiftCompilerSources/Sources/AST/SubstitutionMap.swift +++ b/SwiftCompilerSources/Sources/AST/SubstitutionMap.swift @@ -68,7 +68,7 @@ public struct SubstitutionMap: CustomStringConvertible, NoReflectionChildren { TypeArray(bridged: bridged.getReplacementTypes()) } - /// The single replacement type if it's guarnateed that the substitution map has a single replacement type. + /// The single replacement type if it's guaranteed that the substitution map has a single replacement type. public var replacementType: Type { assert(replacementTypes.count == 1) return replacementTypes[0] diff --git a/SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift b/SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift index 7c319deb6293a..0fcb88671b803 100644 --- a/SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift +++ b/SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift @@ -97,8 +97,8 @@ struct AliasAnalysis { return false } } - // Finaly use escape info to check if one address "escapes" to the other address. - return v1.allContainedAddresss.canAddressAlias(with: v2.allContainedAddresss, context) + // Finally use escape info to check if one address "escapes" to the other address. + return v1.allContainedAddresses.canAddressAlias(with: v2.allContainedAddresses, context) } static func register() { @@ -339,7 +339,7 @@ struct AliasAnalysis { return .noEffects } if destroy.isDeadEnd { - // We don't have to take deinit effects into acount for a `destroy_value [dead_end]`. + // We don't have to take deinit effects into account for a `destroy_value [dead_end]`. // Such destroys are lowered to no-ops and will not call any deinit. return .noEffects } @@ -471,7 +471,7 @@ struct AliasAnalysis { } // To avoid quadratic complexity for large functions, we limit the amount of work that the EscapeUtils are - // allowed to to. This keeps the complexity linear. + // allowed to do. This keeps the complexity linear. // // This arbitrary limit is good enough for almost all functions. It lets // the EscapeUtils do several hundred up/down walks which is much more than needed in most cases. @@ -481,14 +481,14 @@ struct AliasAnalysis { for _ in function.instructions { numInsts += 1 } cache.estimatedFunctionSize = numInsts } - return 1000000 / cache.estimatedFunctionSize! + return 1_000_000 / cache.estimatedFunctionSize! } /// Returns true if the `instruction` (which in general writes to memory) is immutable in a certain scope, /// defined by `address`. /// /// That means that even if we don't know anything about `instruction`, we can be sure - /// that `instruction` cannot write to `address`, if it's inside the addresse's scope. + /// that `instruction` cannot write to `address`, if it's inside the address's scope. /// An immutable scope is for example a read-only `begin_access`/`end_access` scope. /// Another example is a borrow scope of an immutable copy-on-write buffer. private func isImmutable(instruction: Instruction, inScopeOf address: Value) -> Bool { @@ -797,7 +797,7 @@ private struct FullApplyEffectsVisitor : EscapeVisitorWithResult { // In contrast to a full apply, the effects of a partial_apply don't depend on the callee // (a partial_apply doesn't call anything, it just creates a thick function pointer). -// The only effects come from capturing the arguments (either consuming or guaranteeed). +// The only effects come from capturing the arguments (either consuming or guaranteed). private struct PartialApplyEffectsVisitor : EscapeVisitorWithResult { let partialApply: PartialApplyInst var result = SideEffects.Memory.noEffects diff --git a/SwiftCompilerSources/Sources/Optimizer/DataStructures/InstructionRange.swift b/SwiftCompilerSources/Sources/Optimizer/DataStructures/InstructionRange.swift index 7c9a5c4456ca2..078d8fd5cd8af 100644 --- a/SwiftCompilerSources/Sources/Optimizer/DataStructures/InstructionRange.swift +++ b/SwiftCompilerSources/Sources/Optimizer/DataStructures/InstructionRange.swift @@ -240,7 +240,7 @@ extension InstructionRange { } return .containsEnd } - // Neither end-point is contained. If a backward path walk encouters this range, then it must overlap this + // Neither end-point is contained. If a backward path walk encounters this range, then it must overlap this // range. Otherwise, it is disjoint. var backwardBlocks = BasicBlockWorklist(context) defer { backwardBlocks.deinitialize() } diff --git a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/CopyToBorrowOptimization.swift b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/CopyToBorrowOptimization.swift index d9abef94fe499..3e00c4eea75ab 100644 --- a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/CopyToBorrowOptimization.swift +++ b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/CopyToBorrowOptimization.swift @@ -39,7 +39,7 @@ import SIL /// ``` /// The optimization can be done if: -/// * In caseof a `load`: during the (forward-extended) lifetime of the loaded value the +/// * In case of a `load`: during the (forward-extended) lifetime of the loaded value the /// memory location is not changed. /// * In case of a `copy_value`: the (guaranteed) lifetime of the source operand extends /// the lifetime of the copied value. diff --git a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/DeadStoreElimination.swift b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/DeadStoreElimination.swift index 43c798f6879e5..c7c4a1fa44986 100644 --- a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/DeadStoreElimination.swift +++ b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/DeadStoreElimination.swift @@ -76,7 +76,7 @@ let deadStoreElimination = FunctionPass(name: "dead-store-elimination") { private func tryEliminate(store: StoreInst, complexityBudget: inout Int, _ context: FunctionPassContext) { // Check if the type can be expanded without a significant increase to code - // size. This pass splits values into its consitutent parts which effectively + // size. This pass splits values into its constituent parts which effectively // expands the value into projections which can increase code size. if !store.hasValidOwnershipForDeadStoreElimination || !store.source.type.shouldExpand(context) { return diff --git a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceDiagnostics.swift b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceDiagnostics.swift index 1f6b83ae66d03..b7ba62ef98e4b 100644 --- a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceDiagnostics.swift +++ b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceDiagnostics.swift @@ -66,7 +66,7 @@ let lifetimeDependenceDiagnosticsPass = FunctionPass( // For now, if the mark_dependence wasn't recognized as a lifetime dependency, or if the dependencies uses are not // in scope, conservatively settle it as escaping. For example, it is not uncommon for the pointer value returned // by `unsafeAddress` to outlive its `self` argument. This will not be diagnosed as an error, but the - // mark_dependence will hanceforth be treated as an unknown use by the optimizer. In the future, we should not + // mark_dependence will henceforth be treated as an unknown use by the optimizer. In the future, we should not // need to set this flag during diagnostics because, for escapable types, mark_dependence [unresolved] will all be // settled during an early LifetimeNormalization pass. markDep.settleToEscaping(context) @@ -422,8 +422,8 @@ private struct LifetimeVariable { /// /// This supports store-to-yield. Storing to a yield is an escape unless the yielded memory location depends on another /// lifetime that already depends on the current scope. When setter depends on 'newValue', 'newValue' is stored to the -/// yielded address, and the yielded addrses depends on the lifetime of 'self'. A mark_dependence should have already -/// been inserted for that lifetime depenence: +/// yielded address, and the yielded addresses depends on the lifetime of 'self'. A mark_dependence should have already +/// been inserted for that lifetime dependence: /// /// (%a, %t) = begin_apply %f(%self) /// : $@yield_once @convention(method) (@inout Self) -> _inherit(0) @yields @inout Self.field @@ -459,7 +459,7 @@ extension DependentAddressUseDefWalker: AddressUseDefWalker { } } -/// Walk down lifetime depenence uses. For each check that all dependent +/// Walk down lifetime dependence uses. For each check that all dependent /// leaf uses are non-escaping and within the dependence scope. The walk /// starts with add address for .access dependencies. The walk can /// transition from an address to a value at a load. The walk can diff --git a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceInsertion.swift b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceInsertion.swift index a8aca92654baf..c7d91746f7974 100644 --- a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceInsertion.swift +++ b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceInsertion.swift @@ -191,8 +191,8 @@ private extension LifetimeDependentApply.LifetimeSourceInfo { // (a) the result or yield is never returned from this function // // (b) the inherited lifetime has a dependence root within this function (it comes from a dependent function - // argument or scoped dependence). In this case, when that depedence root is diagnosed, the analysis will find - // transtive uses of this apply's result. + // argument or scoped dependence). In this case, when that dependence root is diagnosed, the analysis will find + // transitive uses of this apply's result. // // (c) the dependent value is passed to another call with a dependent inout argument, or it is stored to a yielded // address of a coroutine that has a dependent inout argument. In this case, a mark_dependence will already be @@ -346,7 +346,7 @@ func gatherVariableIntroducers(for value: Value, _ context: Context) /// /// dependsOn(lvalue.computed) // finds the temporary value directly returned by a getter. /// -/// SILGen emits temporary copies that violate lifetime dependence semantcs. This utility looks through such temporary +/// SILGen emits temporary copies that violate lifetime dependence semantics. This utility looks through such temporary /// copies, stopping at a value that introduces an immutable variable: move_value [var_decl] or begin_borrow [var_decl], /// or at an access of a mutable variable: begin_access [read] or begin_access [modify]. /// diff --git a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceScopeFixup.swift b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceScopeFixup.swift index f99418675a8d5..61ad296db0519 100644 --- a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceScopeFixup.swift +++ b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceScopeFixup.swift @@ -666,7 +666,7 @@ extension ScopeExtension { log("Scope fixup for dependent uses:\n\(useRange)") - // Lifetime dependenent uses may not be dominated by `innermostScope`. The dependent value may be used by a phi or + // Lifetime dependent uses may not be dominated by `innermostScope`. The dependent value may be used by a phi or // stored into a memory location. The access may be conditional relative to such uses. If any use was not dominated, // then `useRange` will include the function entry. There is no way to directly check if `useRange` is // valid. `useRange.blockRange.isValid` is not a strong enough check because it will always succeed when @@ -695,12 +695,12 @@ extension ScopeExtension { var extendedUseRange = InstructionRange(begin: useRange.begin!, ends: useRange.ends, context) // Insert the first instruction of the exit blocks to mimic `useRange`. There is no way to directly copy - // `useRange`. Inserting the exit block instructions is innacurate, but for the purpose of canExtend() below, it has + // `useRange`. Inserting the exit block instructions is inaccurate, but for the purpose of canExtend() below, it has // the same effect as a copy of `useRange`. extendedUseRange.insert(contentsOf: useRange.exits) defer { extendedUseRange.deinitialize() } - // Append each scope that needs extention to scopesToExtend from the inner to the outer scope. + // Append each scope that needs extension to scopesToExtend from the inner to the outer scope. for extScope in scopes.reversed() { // An outer scope might not originally cover one of its inner scopes. Therefore, extend 'extendedUseRange' to to // cover this scope's end instructions. The extended scope must at least cover the original scopes because the diff --git a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ObjCBridgingOptimization.swift b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ObjCBridgingOptimization.swift index 96c9cd67efe64..aa41fce4829e6 100644 --- a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ObjCBridgingOptimization.swift +++ b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ObjCBridgingOptimization.swift @@ -248,7 +248,7 @@ private func removeBridgingCodeInPredecessors(of block: BasicBlock, _ context: F /// ``` /// switch_enum %0 // returned instruction /// some_bb(%1): -/// %2 = enum #some(%1) // only in case of ObjC -> Swift briding +/// %2 = enum #some(%1) // only in case of ObjC -> Swift bridging /// %3 = apply %bridging(%2) // returned by `isBridging` /// %4 = enum #some(%3) /// br continue_bb(%4) @@ -338,7 +338,7 @@ func isBridgeToSwiftCall(_ value: Value) -> ApplyInst? { let funcName = bridgingFunc.name guard bridgingFunc.hasSemanticsAttribute("bridgeFromObjectiveC") || // Currently the semantics attribute is not used, so test for specific functions, too. - // TODO: remove those checks once the briding functions are annotate with "bridgeFromObjectiveC" + // TODO: remove those checks once the bridging functions are annotated with "bridgeFromObjectiveC" // in Foundation. // // String._unconditionallyBridgeFromObjectiveC(_:) diff --git a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/StackPromotion.swift b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/StackPromotion.swift index a39b04eeb8efd..2d0fe05b96f38 100644 --- a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/StackPromotion.swift +++ b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/StackPromotion.swift @@ -286,7 +286,7 @@ private struct ComputeOuterBlockrange : EscapeVisitorWithResult { result.insert(operandsDefinitionBlock) // We need to explicitly add predecessor blocks of phis because they - // are not necesesarily visited during the down-walk in `isEscaping()`. + // are not necessarily visited during the down-walk in `isEscaping()`. // This is important for the special case where there is a back-edge from the // inner range to the inner rage's begin-block: // diff --git a/SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyMarkDependence.swift b/SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyMarkDependence.swift index 59e2956e9b99b..f115401d90cb3 100644 --- a/SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyMarkDependence.swift +++ b/SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyMarkDependence.swift @@ -19,7 +19,7 @@ extension MarkDependenceInst : OnoneSimplifiable, SILCombineSimplifiable { func simplify(_ context: SimplifyContext) { if isRedundant || // A literal lives forever, so no mark_dependence is needed. - // This pattern can occur after StringOptimization when a utf8CString of a literal is replace + // This pattern can occur after StringOptimization when a utf8CString of a literal is replaced // by the string_literal itself. value.isLiteral { diff --git a/SwiftCompilerSources/Sources/Optimizer/Utilities/BorrowUtils.swift b/SwiftCompilerSources/Sources/Optimizer/Utilities/BorrowUtils.swift index 95d619c2e9585..c1b0c4daa6376 100644 --- a/SwiftCompilerSources/Sources/Optimizer/Utilities/BorrowUtils.swift +++ b/SwiftCompilerSources/Sources/Optimizer/Utilities/BorrowUtils.swift @@ -465,7 +465,7 @@ func computeBorrowLiveRange(for value: Value, _ context: FunctionPassContext) for beginBorrow in value.getBorrowIntroducers(context) { /// FIXME: Remove calls to computeKnownLiveness() as soon as lifetime completion runs immediately after /// SILGen. Instead, this should compute linear liveness for borrowed value by switching over BeginBorrowValue, just - /// like LifetimeDependenc.Scope.computeRange(). + /// like LifetimeDependence.Scope.computeRange(). ranges.push((beginBorrow, computeKnownLiveness(for: beginBorrow.value, context))) } return ranges diff --git a/SwiftCompilerSources/Sources/Optimizer/Utilities/ForwardingUtils.swift b/SwiftCompilerSources/Sources/Optimizer/Utilities/ForwardingUtils.swift index 56122160a64c8..dc856c7814755 100644 --- a/SwiftCompilerSources/Sources/Optimizer/Utilities/ForwardingUtils.swift +++ b/SwiftCompilerSources/Sources/Optimizer/Utilities/ForwardingUtils.swift @@ -303,7 +303,7 @@ extension ForwardingDefUseWalker { /// gatherLifetimeIntroducers(). /// /// TODO: make the visitor non-escaping once Swift supports stored -/// non-escaping closues. +/// non-escaping closures. func visitForwardedUses(introducer: Value, _ context: Context, visitor: @escaping (ForwardingUseResult) -> WalkResult) -> WalkResult { diff --git a/SwiftCompilerSources/Sources/Optimizer/Utilities/GenericSpecialization.swift b/SwiftCompilerSources/Sources/Optimizer/Utilities/GenericSpecialization.swift index 0bd2c9c2f3b91..8b19076a39a7b 100644 --- a/SwiftCompilerSources/Sources/Optimizer/Utilities/GenericSpecialization.swift +++ b/SwiftCompilerSources/Sources/Optimizer/Utilities/GenericSpecialization.swift @@ -175,7 +175,7 @@ func specializeWitnessTable(for conformance: Conformance, } /// Specializes the default methods of a non-generic witness table. -/// Default implementations (in protocol extentions) of non-generic protocol methods have a generic +/// Default implementations (in protocol extensions) of non-generic protocol methods have a generic /// self argument. Specialize such methods with the concrete type. Note that it is important to also /// specialize inherited conformances so that the concrete self type is correct, even for derived classes. private func specializeDefaultMethods(for conformance: Conformance, @@ -238,7 +238,7 @@ private func specializeDefaultMethods(for conformance: Conformance, private extension Function { // True, if this is a non-generic method which might have a generic self argument. - // Default implementations (in protocol extentions) of non-generic protocol methods have a generic + // Default implementations (in protocol extensions) of non-generic protocol methods have a generic // self argument. func isNonGenericWitnessMethod(_ context: some Context) -> Bool { switch loweredFunctionType.invocationGenericSignatureOfFunction.genericParameters.count { diff --git a/SwiftCompilerSources/Sources/Optimizer/Utilities/LifetimeDependenceUtils.swift b/SwiftCompilerSources/Sources/Optimizer/Utilities/LifetimeDependenceUtils.swift index b94b7bc60f718..a51a773a95b0d 100644 --- a/SwiftCompilerSources/Sources/Optimizer/Utilities/LifetimeDependenceUtils.swift +++ b/SwiftCompilerSources/Sources/Optimizer/Utilities/LifetimeDependenceUtils.swift @@ -382,7 +382,7 @@ extension LifetimeDependence.Scope { } extension LifetimeDependence.Scope { - /// Ignore "irrelevent" borrow scopes: load_borrow or begin_borrow without [var_decl] + /// Ignore "irrelevant" borrow scopes: load_borrow or begin_borrow without [var_decl] func ignoreBorrowScope(_ context: some Context) -> LifetimeDependence.Scope? { guard case let .borrowed(beginBorrowVal) = self else { return nil @@ -560,7 +560,7 @@ protocol LifetimeDependenceDefUseWalker : ForwardingDefUseWalker, } extension LifetimeDependenceDefUseWalker { - // Use a distict context name to avoid rdar://123424566 (Unable to open existential) + // Use a distinct context name to avoid rdar://123424566 (Unable to open existential) var walkerContext: Context { context } } @@ -824,7 +824,7 @@ extension LifetimeDependenceDefUseWalker { // Helpers extension LifetimeDependenceDefUseWalker { - // Visit uses of borrowing instruction (operandOwnerhip == .borrow). + // Visit uses of borrowing instruction (operandOwnership == .borrow). private mutating func visitAllBorrowUses( of operand: Operand, by borrowInst: BorrowingInstruction) -> WalkResult { switch borrowInst { @@ -855,7 +855,7 @@ extension LifetimeDependenceDefUseWalker { } } - // Visit a dependent local variable (alloc_box), or temporary storage (alloc_stack). The depenedency is typically from + // Visit a dependent local variable (alloc_box), or temporary storage (alloc_stack). The dependency is typically from // storing a dependent value at `address`, but may be from an outright `mark_dependence_addr`. // // This handles stores of the entire value and stores into a member. Storing into a member makes the entire aggregate @@ -1110,7 +1110,7 @@ private struct LifetimeDependenceUsePrinter : LifetimeDependenceDefUseWalker { /// /// dependsOn(lvalue.computed) // finds the temporary value directly returned by a getter. /// -/// SILGen emits temporary copies that violate lifetime dependence semantcs. This utility looks through such temporary +/// SILGen emits temporary copies that violate lifetime dependence semantics. This utility looks through such temporary /// copies, stopping at a value that introduces an immutable variable: move_value [var_decl] or begin_borrow [var_decl], /// or at an access of a mutable variable: begin_access [read] or begin_access [modify]. /// @@ -1238,7 +1238,7 @@ extension LifetimeDependenceUseDefAddressWalker { if let addressorSelf = beginAccess.unsafeAddressorSelf { return walkUp(newLifetime: addressorSelf) } - // Ignore the acces scope for trivial values regardless of whether it is singly-initialized. Trivial values do not + // Ignore the access scope for trivial values regardless of whether it is singly-initialized. Trivial values do not // need to be kept alive in memory and can be safely be overwritten in the same scope. Lifetime dependence only // cares that the loaded value is within the lexical scope of the trivial value's variable declaration. Rather // than skipping all access scopes, call 'walkUp' on each nested access in case one of them needs to redirect the diff --git a/SwiftCompilerSources/Sources/Optimizer/Utilities/LocalVariableUtils.swift b/SwiftCompilerSources/Sources/Optimizer/Utilities/LocalVariableUtils.swift index 310426e251ef1..1ac7f8d5034eb 100644 --- a/SwiftCompilerSources/Sources/Optimizer/Utilities/LocalVariableUtils.swift +++ b/SwiftCompilerSources/Sources/Optimizer/Utilities/LocalVariableUtils.swift @@ -12,7 +12,7 @@ /// /// SIL operates on three kinds of addressable memory: /// -/// 1. Temporary RValues. These are recognied by AddressInitializationWalker. These largely disappear with opaque SIL +/// 1. Temporary RValues. These are recognized by AddressInitializationWalker. These largely disappear with opaque SIL /// values. /// /// 2. Local variables. These are always introduced by either a VarDeclInstruction or a Function argument with non-nil @@ -774,7 +774,7 @@ extension LocalVariableReachableAccess { /// This performs a forward CFG walk to find all uses of this local variable reachable after `begin`. /// - /// If `lifetime` is true, then this gathers the full known lifetime, includeing destroys and reassignments ignoring + /// If `lifetime` is true, then this gathers the full known lifetime, including destroys and reassignments ignoring /// escapes. /// /// If `lifetime` is false, then this returns `false` if the walk ended early because of a reachable escape. diff --git a/SwiftCompilerSources/Sources/Optimizer/Utilities/OwnershipLiveness.swift b/SwiftCompilerSources/Sources/Optimizer/Utilities/OwnershipLiveness.swift index 2538aed77439b..3f1ad6afde0e5 100644 --- a/SwiftCompilerSources/Sources/Optimizer/Utilities/OwnershipLiveness.swift +++ b/SwiftCompilerSources/Sources/Optimizer/Utilities/OwnershipLiveness.swift @@ -84,7 +84,7 @@ func computeKnownLiveness(for definingValue: Value, visitInnerUses: Bool = false visitInnerUses: visitInnerUses, context).acquireRange } -/// If any interior pointer may escape, then record the first instance here. If 'ignoseEscape' is true, this +/// If any interior pointer may escape, then record the first instance here. If 'ignoreEscape' is true, this /// immediately aborts the walk, so further instances are unavailable. /// /// .escaping may either be a non-address operand with diff --git a/SwiftCompilerSources/Sources/SIL/Function.swift b/SwiftCompilerSources/Sources/SIL/Function.swift index 0a01a2114b408..04439500a23c3 100644 --- a/SwiftCompilerSources/Sources/SIL/Function.swift +++ b/SwiftCompilerSources/Sources/SIL/Function.swift @@ -189,7 +189,7 @@ final public class Function : CustomStringConvertible, HasShortDescription, Hash // If Package-CMO is enabled, we serialize package, public, and @usableFromInline decls as // [serialized_for_package]. - // Their bodies must not, however, leak into @inlinable functons (that are [serialized]) + // Their bodies must not, however, leak into @inlinable functions (that are [serialized]) // since they are inlined outside of their defining module. // // If this callee is [serialized_for_package], the caller must be either non-serialized diff --git a/SwiftCompilerSources/Sources/SIL/Operand.swift b/SwiftCompilerSources/Sources/SIL/Operand.swift index e9703c9433ec7..322ba7bf41984 100644 --- a/SwiftCompilerSources/Sources/SIL/Operand.swift +++ b/SwiftCompilerSources/Sources/SIL/Operand.swift @@ -262,7 +262,7 @@ public enum OperandOwnership { /// Escape a pointer into a value which cannot be tracked or verified. /// - /// PointerEscape operands indicate a SIL deficiency to suffuciently model dependencies. They never arise from user-level escapes. + /// PointerEscape operands indicate a SIL deficiency to sufficiently model dependencies. They never arise from user-level escapes. case pointerEscape /// Bitwise escape. Escapes the nontrivial contents of the value. OSSA does not enforce the lifetime of the escaping bits. The programmer must explicitly force lifetime extension. (ref_to_unowned, unchecked_trivial_bitcast) diff --git a/SwiftCompilerSources/Sources/SIL/Utilities/AccessUtils.swift b/SwiftCompilerSources/Sources/SIL/Utilities/AccessUtils.swift index 2fbcf88d9e7f7..a64827e2cecf6 100644 --- a/SwiftCompilerSources/Sources/SIL/Utilities/AccessUtils.swift +++ b/SwiftCompilerSources/Sources/SIL/Utilities/AccessUtils.swift @@ -120,7 +120,7 @@ public enum AccessBase : CustomStringConvertible, Hashable { } } - /// Return 'nil' for global varabiables and unidentified addresses. + /// Return 'nil' for global variables and unidentified addresses. public var address: Value? { switch self { case .global, .unidentified: return nil @@ -746,7 +746,7 @@ extension Value { // Although an AccessPathWalker is created for each call of these properties, // it's very unlikely that this will end up in memory allocations. // Only in the rare case of `pointer_to_address` -> `address_to_pointer` pairs, which - // go through phi-arguments, the AccessPathWalker will allocate memnory in its cache. + // go through phi-arguments, the AccessPathWalker will allocate memory in its cache. /// Computes the access base of this address value. public var accessBase: AccessBase { accessPath.base } From 8a0c1db16490a1cdfe6c59d51c32af89f909480c Mon Sep 17 00:00:00 2001 From: Valeriy Van Date: Sun, 8 Jun 2025 11:26:01 +0300 Subject: [PATCH 2/4] Fix typo in property allContainedAddresss -> allContainedAddresses --- .../Sources/Optimizer/Analysis/AliasAnalysis.swift | 2 +- .../Sources/Optimizer/TestPasses/EscapeInfoDumper.swift | 6 +++--- SwiftCompilerSources/Sources/SIL/Value.swift | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift b/SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift index 0fcb88671b803..f1eb258c3fa49 100644 --- a/SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift +++ b/SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift @@ -148,7 +148,7 @@ struct AliasAnalysis { bridgedObj: BridgedValue) -> Bool in let context = FunctionPassContext(_bridged: bridgedCtxt) let aa = AliasAnalysis(bridged: bridgedAliasAnalysis, context: context) - let addr = bridgedAddr.value.allContainedAddresss + let addr = bridgedAddr.value.allContainedAddresses // This is similar to `canReferenceSameFieldFn`, except that all addresses of all objects are // considered which are transitively visible from `bridgedObj`. diff --git a/SwiftCompilerSources/Sources/Optimizer/TestPasses/EscapeInfoDumper.swift b/SwiftCompilerSources/Sources/Optimizer/TestPasses/EscapeInfoDumper.swift index 873ba9bac330e..d13427a94c5c9 100644 --- a/SwiftCompilerSources/Sources/Optimizer/TestPasses/EscapeInfoDumper.swift +++ b/SwiftCompilerSources/Sources/Optimizer/TestPasses/EscapeInfoDumper.swift @@ -109,7 +109,7 @@ let addressEscapeInfoDumper = FunctionPass(name: "dump-addr-escape-info") { for value in valuesToCheck { print("value:\(value)") for apply in applies { - if value.allContainedAddresss.isEscaping(using: Visitor(apply: apply), context) { + if value.allContainedAddresses.isEscaping(using: Visitor(apply: apply), context) { print(" ==> \(apply)") } else { print(" - \(apply)") @@ -127,8 +127,8 @@ let addressEscapeInfoDumper = FunctionPass(name: "dump-addr-escape-info") { print(lhs) print(rhs) - let projLhs = lhs.allContainedAddresss - let projRhs = rhs.allContainedAddresss + let projLhs = lhs.allContainedAddresses + let projRhs = rhs.allContainedAddresses let mayAlias = projLhs.canAddressAlias(with: projRhs, context) if mayAlias != projRhs.canAddressAlias(with: projLhs, context) { fatalError("canAddressAlias(with:) must be symmetric") diff --git a/SwiftCompilerSources/Sources/SIL/Value.swift b/SwiftCompilerSources/Sources/SIL/Value.swift index 829a3cd41b048..c0397df172d59 100644 --- a/SwiftCompilerSources/Sources/SIL/Value.swift +++ b/SwiftCompilerSources/Sources/SIL/Value.swift @@ -243,9 +243,9 @@ extension Value { /// struct S { var c1: C; var c2: C } /// let s: S /// - /// `s.allContainedAddresss` refers to `s.c1.x`, `s.c1.y`, `s.c2.x` and `s.c2.y` + /// `s.allContainedAddresses` refers to `s.c1.x`, `s.c1.y`, `s.c2.x` and `s.c2.y` /// - public var allContainedAddresss: ProjectedValue { + public var allContainedAddresses: ProjectedValue { if type.isAddress { // This is the regular case: the path selects any sub-fields of an address. return at(SmallProjectionPath(.anyValueFields)) From dd2468cf587ddf9202fc326ab5e270747fe97bbb Mon Sep 17 00:00:00 2001 From: Valeriy Van Date: Sun, 8 Jun 2025 11:27:30 +0300 Subject: [PATCH 3/4] Fix typo in local var --- .../FunctionPasses/LifetimeDependenceInsertion.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceInsertion.swift b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceInsertion.swift index c7d91746f7974..f801ccc8f1bc2 100644 --- a/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceInsertion.swift +++ b/SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceInsertion.swift @@ -219,8 +219,8 @@ private extension LifetimeDependentApply.LifetimeSourceInfo { return } // Create a new dependence on the apply's access to the argument. - for varIntoducer in gatherVariableIntroducers(for: source.value, context) { - let scope = LifetimeDependence.Scope(base: varIntoducer, context) + for varIntroducer in gatherVariableIntroducers(for: source.value, context) { + let scope = LifetimeDependence.Scope(base: varIntroducer, context) log("Scoped lifetime from \(source.value)") log(" scope: \(scope)") bases.append(scope.parentValue) From 761bee9d0934f1c8736799c541b20a3beb478789 Mon Sep 17 00:00:00 2001 From: Valeriy Van Date: Sun, 8 Jun 2025 11:30:04 +0300 Subject: [PATCH 4/4] Fix typo in func replaceOpenedArchetypeInSubstituations -> replaceOpenedArchetypeInSubstitutions --- .../Optimizer/InstructionSimplification/SimplifyApply.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyApply.swift b/SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyApply.swift index 126fac51cb2e9..71e403e70a432 100644 --- a/SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyApply.swift +++ b/SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyApply.swift @@ -177,7 +177,7 @@ private func tryReplaceExistentialArchetype(of apply: ApplyInst, _ context: Simp let newApply = builder.createApply( function: apply.callee, - apply.replaceOpenedArchetypeInSubstituations(withConcreteType: concreteType, context), + apply.replaceOpenedArchetypeInSubstitutions(withConcreteType: concreteType, context), arguments: apply.replaceExistentialArchetypeInArguments(withConcreteType: concreteType, context), isNonThrowing: apply.isNonThrowing, isNonAsync: apply.isNonAsync, specializationInfo: apply.specializationInfo) @@ -197,7 +197,7 @@ private func tryReplaceExistentialArchetype(of tryApply: TryApplyInst, _ context builder.createTryApply( function: tryApply.callee, - tryApply.replaceOpenedArchetypeInSubstituations(withConcreteType: concreteType, context), + tryApply.replaceOpenedArchetypeInSubstitutions(withConcreteType: concreteType, context), arguments: tryApply.replaceExistentialArchetypeInArguments(withConcreteType: concreteType, context), normalBlock: tryApply.normalBlock, errorBlock: tryApply.errorBlock, isNonAsync: tryApply.isNonAsync, @@ -269,7 +269,7 @@ private extension FullApplySite { return Array(newArgs) } - func replaceOpenedArchetypeInSubstituations( + func replaceOpenedArchetypeInSubstitutions( withConcreteType concreteType: CanonicalType, _ context: SimplifyContext ) -> SubstitutionMap {