Skip to content

Fix some typos in SwiftCompilerSources/Sources #82090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SwiftCompilerSources/Sources/AST/SubstitutionMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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.
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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].
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(_:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -269,7 +269,7 @@ private extension FullApplySite {
return Array(newArgs)
}

func replaceOpenedArchetypeInSubstituations(
func replaceOpenedArchetypeInSubstitutions(
withConcreteType concreteType: CanonicalType,
_ context: SimplifyContext
) -> SubstitutionMap {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
Loading