Skip to content

Optimizer: Rework peephole optimizations to replace existential (archetypes) with concrete types #79674

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 22 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
48db890
SIL: be more tolerant when a user is deleted during use-list iteration.
eeckstein Feb 17, 2025
eadfbf6
Swift AST: add some APIs to `Type` and `CanonicalType`
eeckstein Feb 18, 2025
8adec32
SIL: fix two comments in Type.swift
eeckstein Feb 18, 2025
3105733
Swift SIL: add some Instruction APIs
eeckstein Feb 18, 2025
f7466ea
SIL: fix bridging of SILDebugVariable
eeckstein Feb 27, 2025
db03a55
Swift SIL: add some Builder APIs
eeckstein Feb 18, 2025
4595d5d
SIL Builder: make `createInitExistentialMetatype` more usable by pass…
eeckstein Feb 18, 2025
de841fd
Fix a comment about SILCombine "passes" in Passes.def
eeckstein Feb 27, 2025
df81283
SILCombine: make it possible to add a Swift simplification to an exis…
eeckstein Feb 27, 2025
35097b5
Optimizer: simplify `unconditional_checked_cast` to existential metat…
eeckstein Feb 18, 2025
810064b
Cleanup and additions to AST and SIL Type/CanonicalType
eeckstein Feb 27, 2025
7bbd9a9
SIL: add `var Instruction.typeDependentOperands`
eeckstein Feb 27, 2025
213da24
SIL: add an overload of `Sequence<Operand>.users(ofType:)` which retu…
eeckstein Feb 27, 2025
5016e35
Optimizer: add two small utilities for instructions
eeckstein Feb 27, 2025
0f55220
SIL: add `var FullApplySite.singleDirectErrorResult`
eeckstein Feb 27, 2025
67925ea
Swift AST: add `GenericSignature`
eeckstein Feb 28, 2025
431401c
Swift AST: add an initializer to `SubstitutionMap`
eeckstein Feb 18, 2025
77dab77
Swift SIL: make isLegalFormalType available in AST.Type
eeckstein Mar 7, 2025
71de3d9
Optimizer: replace existential archetypes with concrete types in appl…
eeckstein Feb 27, 2025
5572c83
SILOptimizer: replace existential archetypes with concrete types in w…
eeckstein Feb 27, 2025
4603530
Optimizer: improve simplification of alloc_stack
eeckstein Feb 27, 2025
26c7310
Swift AST: Fix debug description of `Type`
eeckstein Feb 28, 2025
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
Prev Previous commit
Next Next commit
Swift SIL: make isLegalFormalType available in AST.Type
  • Loading branch information
eeckstein committed Mar 7, 2025
commit 77dab77702396a518d75b149809dfb10599dd6f1
1 change: 1 addition & 0 deletions SwiftCompilerSources/Sources/AST/Type.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public protocol TypeProperties {
extension TypeProperties {
public var description: String { String(taking: type.bridged.getDebugDescription()) }

public var isLegalFormalType: Bool { type.bridged.isLegalFormalType() }
public var hasTypeParameter: Bool { type.bridged.hasTypeParameter() }
public var hasLocalArchetype: Bool { type.bridged.hasLocalArchetype() }
public var isExistentialArchetype: Bool { type.bridged.isExistentialArchetype() }
Expand Down
2 changes: 1 addition & 1 deletion SwiftCompilerSources/Sources/SIL/Type.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public struct Type : CustomStringConvertible, NoReflectionChildren {
public var isBuiltinVector: Bool { bridged.isBuiltinVector() }
public var builtinVectorElementType: Type { bridged.getBuiltinVectorElementType().type }

public var isLegalFormalType: Bool { bridged.isLegalFormalType() }
public var isLegalFormalType: Bool { astType.isLegalFormalType }

public func isBuiltinInteger(withFixedWidth width: Int) -> Bool {
bridged.isBuiltinFixedWidthInteger(width)
Expand Down
1 change: 1 addition & 0 deletions include/swift/AST/ASTBridging.h
Original file line number Diff line number Diff line change
Expand Up @@ -3004,6 +3004,7 @@ struct BridgedASTType {
BRIDGED_INLINE swift::Type unbridged() const;
BRIDGED_INLINE BridgedOwnedString getDebugDescription() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedCanType getCanonicalType() const;
BRIDGED_INLINE bool isLegalFormalType() const;
BRIDGED_INLINE bool hasTypeParameter() const;
BRIDGED_INLINE bool hasLocalArchetype() const;
BRIDGED_INLINE bool isExistentialArchetype() const;
Expand Down
4 changes: 4 additions & 0 deletions include/swift/AST/ASTBridgingImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ BridgedCanType BridgedASTType::getCanonicalType() const {
return unbridged()->getCanonicalType();
}

bool BridgedASTType::isLegalFormalType() const {
return unbridged()->isLegalFormalType();
}

bool BridgedASTType::hasTypeParameter() const {
return unbridged()->hasTypeParameter();
}
Expand Down
1 change: 0 additions & 1 deletion include/swift/SIL/SILBridging.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ struct BridgedType {
BRIDGED_INLINE bool isBuiltinInteger() const;
BRIDGED_INLINE bool isBuiltinFloat() const;
BRIDGED_INLINE bool isBuiltinVector() const;
BRIDGED_INLINE bool isLegalFormalType() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getBuiltinVectorElementType() const;
BRIDGED_INLINE bool isBuiltinFixedWidthInteger(SwiftInt width) const;
BRIDGED_INLINE bool isExactSuperclassOf(BridgedType t) const;
Expand Down
4 changes: 0 additions & 4 deletions include/swift/SIL/SILBridgingImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,6 @@ bool BridgedType::isBuiltinVector() const {
return unbridged().isBuiltinVector();
}

bool BridgedType::isLegalFormalType() const {
return unbridged().getASTType()->isLegalFormalType();
}

BridgedType BridgedType::getBuiltinVectorElementType() const {
return unbridged().getBuiltinVectorElementType();
}
Expand Down