Skip to content

Commit 9ed4d36

Browse files
committed
Delete lifetime dependence mangling
Mangling this information for future directions like component lifetimes becomes complex and the current mangling scheme isn't scalable anyway. Deleting this support for now.
1 parent 911933e commit 9ed4d36

18 files changed

+43
-140
lines changed

docs/ABI/Mangling.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -748,10 +748,6 @@ Types
748748
differentiable ::= 'Yjr' // @differentiable(reverse) on function type
749749
differentiable ::= 'Yjd' // @differentiable on function type
750750
differentiable ::= 'Yjl' // @differentiable(_linear) on function type
751-
#if SWIFT_RUNTIME_VERSION >= 5.TBD
752-
lifetime-dependence ::= 'Yli' INDEX-SUBSET '_' // inherit lifetime dependence
753-
lifetime-dependence ::= 'Yls' INDEX-SUBSET '_' // scoped lifetime dependence
754-
#endif
755751
type-list ::= list-type '_' list-type* // list of types
756752
type-list ::= empty-list
757753

include/swift/AST/ASTMangler.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ class ASTMangler : public Mangler {
9191
/// a critical role.
9292
bool AllowTypedThrows = true;
9393

94-
/// If enabled, lifetime dependencies can be encoded in the mangled name.
95-
bool AllowLifetimeDependencies = true;
96-
9794
/// If enabled, declarations annotated with @_originallyDefinedIn are mangled
9895
/// as if they're part of their original module. Disabled for debug mangling,
9996
/// because lldb wants to find declarations in the modules they're currently

include/swift/Demangling/Demangle.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ enum class MangledDifferentiabilityKind : char {
136136
Linear = 'l',
137137
};
138138

139-
enum class MangledLifetimeDependenceKind : char { Inherit = 'i', Scope = 's' };
140-
141139
/// The pass that caused the specialization to occur. We use this to make sure
142140
/// that two passes that generate similar changes do not yield the same
143141
/// mangling. This currently cannot happen, so this is just a safety measure

include/swift/Demangling/DemangleNodes.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ NODE(AsyncRemoved)
389389

390390
// Added in Swift 5.TBD
391391
NODE(ObjectiveCProtocolSymbolicReference)
392-
NODE(LifetimeDependence)
393392

394393
NODE(OutlinedInitializeWithCopyNoValueWitness)
395394
NODE(OutlinedAssignWithTakeNoValueWitness)

include/swift/Demangling/Demangler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,6 @@ class Demangler : public NodeFactory {
635635
bool demangleBoundGenerics(Vector<NodePointer> &TypeListList,
636636
NodePointer &RetroactiveConformances);
637637

638-
NodePointer demangleLifetimeDependence();
639-
640638
void dump();
641639

642640
public:

lib/AST/ASTMangler.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3251,10 +3251,6 @@ void ASTMangler::appendFunctionResultType(
32513251
} else {
32523252
appendType(resultType, sig, forDecl);
32533253
}
3254-
3255-
if (AllowLifetimeDependencies && lifetimeDependence.has_value()) {
3256-
appendLifetimeDependence(*lifetimeDependence);
3257-
}
32583254
}
32593255

32603256
void ASTMangler::appendTypeList(Type listTy, GenericSignature sig,
@@ -3307,31 +3303,12 @@ void ASTMangler::appendParameterTypeListElement(
33073303
if (flags.isCompileTimeConst())
33083304
appendOperator("Yt");
33093305

3310-
if (AllowLifetimeDependencies && lifetimeDependence) {
3311-
appendLifetimeDependence(*lifetimeDependence);
3312-
}
3313-
33143306
if (!name.empty())
33153307
appendIdentifier(name.str());
33163308
if (flags.isVariadic())
33173309
appendOperator("d");
33183310
}
33193311

3320-
void ASTMangler::appendLifetimeDependence(LifetimeDependenceInfo info) {
3321-
if (auto *inheritIndices = info.getInheritIndices()) {
3322-
assert(!inheritIndices->isEmpty());
3323-
appendOperator("Yli");
3324-
appendIndexSubset(inheritIndices);
3325-
appendOperator("_");
3326-
}
3327-
if (auto *scopeIndices = info.getScopeIndices()) {
3328-
assert(!scopeIndices->isEmpty());
3329-
appendOperator("Yls");
3330-
appendIndexSubset(scopeIndices);
3331-
appendOperator("_");
3332-
}
3333-
}
3334-
33353312
void ASTMangler::appendTupleTypeListElement(Identifier name, Type elementType,
33363313
GenericSignature sig,
33373314
const ValueDecl *forDecl) {

lib/Demangling/Demangler.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -989,11 +989,6 @@ NodePointer Demangler::demangleTypeAnnotation() {
989989
case 'u':
990990
return createType(
991991
createWithChild(Node::Kind::Sending, popTypeAndGetChild()));
992-
case 'l': {
993-
auto *node = demangleLifetimeDependence();
994-
addChild(node, popTypeAndGetChild());
995-
return createType(node);
996-
}
997992
default:
998993
return nullptr;
999994
}
@@ -3154,31 +3149,6 @@ NodePointer Demangler::demangleDifferentiableFunctionType() {
31543149
Node::Kind::DifferentiableFunctionType, (Node::IndexType)kind);
31553150
}
31563151

3157-
static std::optional<MangledLifetimeDependenceKind>
3158-
getMangledLifetimeDependenceKind(char nextChar) {
3159-
switch (nextChar) {
3160-
case 's':
3161-
return MangledLifetimeDependenceKind::Scope;
3162-
case 'i':
3163-
return MangledLifetimeDependenceKind::Inherit;
3164-
}
3165-
return std::nullopt;
3166-
}
3167-
3168-
NodePointer Demangler::demangleLifetimeDependence() {
3169-
auto kind = getMangledLifetimeDependenceKind(nextChar());
3170-
if (!kind.has_value()) {
3171-
return nullptr;
3172-
}
3173-
auto result = createNode(Node::Kind::LifetimeDependence);
3174-
result =
3175-
addChild(result, createNode(Node::Kind::Index, (Node::IndexType)*kind));
3176-
result = addChild(result, demangleIndexSubset());
3177-
if (!nextIf('_'))
3178-
return nullptr;
3179-
return result;
3180-
}
3181-
31823152
std::string Demangler::demangleBridgedMethodParams() {
31833153
if (nextIf('_'))
31843154
return std::string();

lib/Demangling/NodePrinter.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,6 @@ class NodePrinter {
646646
case Node::Kind::SymbolicExtendedExistentialType:
647647
case Node::Kind::HasSymbolQuery:
648648
case Node::Kind::ObjectiveCProtocolSymbolicReference:
649-
case Node::Kind::LifetimeDependence:
650649
case Node::Kind::DependentGenericInverseConformanceRequirement:
651650
return false;
652651
}
@@ -1777,21 +1776,6 @@ NodePointer NodePrinter::print(NodePointer Node, unsigned depth,
17771776
Printer << "@noDerivative ";
17781777
print(Node->getChild(0), depth + 1);
17791778
return nullptr;
1780-
case Node::Kind::LifetimeDependence: {
1781-
auto kind = (MangledLifetimeDependenceKind)Node->getChild(0)->getIndex();
1782-
switch (kind) {
1783-
case MangledLifetimeDependenceKind::Inherit:
1784-
Printer << "inherit lifetime dependence: ";
1785-
break;
1786-
case MangledLifetimeDependenceKind::Scope:
1787-
Printer << "scope lifetime dependence: ";
1788-
break;
1789-
}
1790-
print(Node->getChild(1), depth + 1);
1791-
Printer << " ";
1792-
print(Node->getChild(2), depth + 1);
1793-
return nullptr;
1794-
}
17951779
case Node::Kind::NonObjCAttribute:
17961780
Printer << "@nonobjc ";
17971781
return nullptr;

lib/Demangling/OldRemangler.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,10 +1943,6 @@ ManglingError Remangler::mangleNoDerivative(Node *node, unsigned depth) {
19431943
return mangleSingleChildNode(node, depth + 1); // type
19441944
}
19451945

1946-
ManglingError Remangler::mangleLifetimeDependence(Node *node, unsigned depth) {
1947-
return MANGLING_ERROR(ManglingError::UnsupportedNodeKind, node);
1948-
}
1949-
19501946
ManglingError Remangler::mangleTuple(Node *node, unsigned depth) {
19511947
size_t NumElems = node->getNumChildren();
19521948
if (NumElems > 0 &&

lib/Demangling/Remangler.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,16 +2240,6 @@ ManglingError Remangler::mangleNoDerivative(Node *node, unsigned depth) {
22402240
return ManglingError::Success;
22412241
}
22422242

2243-
ManglingError Remangler::mangleLifetimeDependence(Node *node, unsigned depth) {
2244-
RETURN_IF_ERROR(mangleChildNode(node, 2, depth + 1));
2245-
Buffer
2246-
<< "Yl"
2247-
<< (char)node->getChild(0)->getIndex(); // mangle lifetime dependence kind
2248-
RETURN_IF_ERROR(mangleChildNode(node, 1, depth + 1)); // mangle index subset
2249-
Buffer << "_";
2250-
return ManglingError::Success;
2251-
}
2252-
22532243
ManglingError Remangler::mangleInfixOperator(Node *node, unsigned depth) {
22542244
mangleIdentifierImpl(node, /*isOperator*/ true);
22552245
Buffer << "oi";

lib/IRGen/IRGenMangler.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ IRGenMangler::mangleTypeForReflection(IRGenModule &IGM,
163163
AllowConcurrencyStandardSubstitutions);
164164
llvm::SaveAndRestore<bool> savedIsolatedAny(AllowIsolatedAny);
165165
llvm::SaveAndRestore<bool> savedTypedThrows(AllowTypedThrows);
166-
llvm::SaveAndRestore<bool> savedLifetimeDependencies(AllowLifetimeDependencies);
167166
if (auto runtimeCompatVersion = getSwiftRuntimeCompatibilityVersionForTarget(
168167
ctx.LangOpts.Target)) {
169168

@@ -179,7 +178,6 @@ IRGenMangler::mangleTypeForReflection(IRGenModule &IGM,
179178
if (*runtimeCompatVersion < llvm::VersionTuple(6, 0)) {
180179
AllowIsolatedAny = false;
181180
AllowTypedThrows = false;
182-
AllowLifetimeDependencies = false;
183181
}
184182
}
185183

test/SIL/explicit_lifetime_dependence_specifiers.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Builtin
77

88
struct BufferView : ~Escapable {
99
let ptr: UnsafeRawBufferPointer
10-
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers10BufferViewVyACYlsSU_SWcfC : $@convention(method) (UnsafeRawBufferPointer, @thin BufferView.Type) -> _scope(0) @owned BufferView {
10+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers10BufferViewVyACSWcfC : $@convention(method) (UnsafeRawBufferPointer, @thin BufferView.Type) -> _scope(0) @owned BufferView {
1111
init(_ ptr: UnsafeRawBufferPointer) -> dependsOn(ptr) Self {
1212
self.ptr = ptr
1313
}
@@ -23,17 +23,17 @@ struct BufferView : ~Escapable {
2323
init(independent ptr: UnsafeRawBufferPointer) {
2424
self.ptr = ptr
2525
}
26-
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers10BufferViewVyACYlsUSU_SW_SaySiGhtcfC : $@convention(method) (UnsafeRawBufferPointer, @guaranteed Array<Int>, @thin BufferView.Type) -> _scope(1) @owned BufferView {
26+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers10BufferViewVyACSW_SaySiGhtcfC : $@convention(method) (UnsafeRawBufferPointer, @guaranteed Array<Int>, @thin BufferView.Type) -> _scope(1) @owned BufferView {
2727
init(_ ptr: UnsafeRawBufferPointer, _ a: borrowing Array<Int>) -> dependsOn(a) Self {
2828
self.ptr = ptr
2929
return self
3030
}
31-
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers10BufferViewVyACYliUSU_SW_AA7WrapperVtcfC : $@convention(method) (UnsafeRawBufferPointer, @owned Wrapper, @thin BufferView.Type) -> _inherit(1) @owned BufferView {
31+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers10BufferViewVyACSW_AA7WrapperVtcfC : $@convention(method) (UnsafeRawBufferPointer, @owned Wrapper, @thin BufferView.Type) -> _inherit(1) @owned BufferView {
3232
init(_ ptr: UnsafeRawBufferPointer, _ a: consuming Wrapper) -> dependsOn(a) Self {
3333
self.ptr = ptr
3434
return self
3535
}
36-
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers10BufferViewVyACYliUSUU_YlsUUSU_SW_AA7WrapperVSaySiGhtcfC : $@convention(method) (UnsafeRawBufferPointer, @owned Wrapper, @guaranteed Array<Int>, @thin BufferView.Type) -> _inherit(1) _scope(2) @owned BufferView {
36+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers10BufferViewVyACSW_AA7WrapperVSaySiGhtcfC : $@convention(method) (UnsafeRawBufferPointer, @owned Wrapper, @guaranteed Array<Int>, @thin BufferView.Type) -> _inherit(1) _scope(2) @owned BufferView {
3737
init(_ ptr: UnsafeRawBufferPointer, _ a: consuming Wrapper, _ b: borrowing Array<Int>) -> dependsOn(a) dependsOn(b) Self {
3838
self.ptr = ptr
3939
return self
@@ -58,25 +58,25 @@ func testBasic() {
5858
}
5959
}
6060

61-
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers6deriveyAA10BufferViewVYlsS_ADF : $@convention(thin) (@guaranteed BufferView) -> _scope(0) @owned BufferView {
61+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers6deriveyAA10BufferViewVADF : $@convention(thin) (@guaranteed BufferView) -> _scope(0) @owned BufferView {
6262
func derive(_ x: borrowing BufferView) -> dependsOn(scoped x) BufferView {
6363
return BufferView(independent: x.ptr)
6464
}
6565

66-
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers16consumeAndCreateyAA10BufferViewVYliS_ADnF : $@convention(thin) (@owned BufferView) -> _inherit(0) @owned BufferView {
66+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers16consumeAndCreateyAA10BufferViewVADnF : $@convention(thin) (@owned BufferView) -> _inherit(0) @owned BufferView {
6767
func consumeAndCreate(_ x: consuming BufferView) -> dependsOn(x) BufferView {
6868
return BufferView(independent: x.ptr)
6969
}
7070

71-
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers17deriveThisOrThat1yAA10BufferViewVYlsSS_AD_ADtF : $@convention(thin) (@guaranteed BufferView, @guaranteed BufferView) -> _scope(0, 1) @owned BufferView {
71+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers17deriveThisOrThat1yAA10BufferViewVAD_ADtF : $@convention(thin) (@guaranteed BufferView, @guaranteed BufferView) -> _scope(0, 1) @owned BufferView {
7272
func deriveThisOrThat1(_ this: borrowing BufferView, _ that: borrowing BufferView) -> dependsOn(scoped this, that) BufferView {
7373
if (Int.random(in: 1..<100) == 0) {
7474
return BufferView(independent: this.ptr)
7575
}
7676
return BufferView(independent: that.ptr)
7777
}
7878

79-
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers17deriveThisOrThat2yAA10BufferViewVYliUS_YlsSU_AD_ADntF : $@convention(thin) (@guaranteed BufferView, @owned BufferView) -> _inherit(1) _scope(0) @owned BufferView {
79+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers17deriveThisOrThat2yAA10BufferViewVAD_ADntF : $@convention(thin) (@guaranteed BufferView, @owned BufferView) -> _inherit(1) _scope(0) @owned BufferView {
8080
func deriveThisOrThat2(_ this: borrowing BufferView, _ that: consuming BufferView) -> dependsOn(scoped this) dependsOn(that) BufferView {
8181
if (Int.random(in: 1..<100) == 0) {
8282
return BufferView(independent: this.ptr)
@@ -91,12 +91,12 @@ struct Wrapper : ~Escapable {
9191
init(_ view: consuming BufferView) {
9292
self.view = view
9393
}
94-
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers7WrapperV8getView1AA10BufferViewVYlsS_yF : $@convention(method) (@guaranteed Wrapper) -> _scope(0) @owned BufferView {
94+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers7WrapperV8getView1AA10BufferViewVyF : $@convention(method) (@guaranteed Wrapper) -> _scope(0) @owned BufferView {
9595
borrowing func getView1() -> dependsOn(scoped self) BufferView {
9696
return view
9797
}
9898

99-
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers7WrapperV8getView2AA10BufferViewVYliS_yF : $@convention(method) (@owned Wrapper) -> _inherit(0) @owned BufferView {
99+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers7WrapperV8getView2AA10BufferViewVyF : $@convention(method) (@owned Wrapper) -> _inherit(0) @owned BufferView {
100100
consuming func getView2() -> dependsOn(self) BufferView {
101101
return view
102102
}
@@ -109,12 +109,12 @@ struct Container : ~Escapable {
109109
}
110110
}
111111

112-
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers16getConsumingViewyAA06BufferG0VYliS_AA9ContainerVnF : $@convention(thin) (@owned Container) -> _inherit(0) @owned BufferView {
112+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers16getConsumingViewyAA06BufferG0VAA9ContainerVnF : $@convention(thin) (@owned Container) -> _inherit(0) @owned BufferView {
113113
func getConsumingView(_ x: consuming Container) -> dependsOn(x) BufferView {
114114
return BufferView(independent: x.ptr)
115115
}
116116

117-
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers16getBorrowingViewyAA06BufferG0VYlsS_AA9ContainerVF : $@convention(thin) (@guaranteed Container) -> _scope(0) @owned BufferView {
117+
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers16getBorrowingViewyAA06BufferG0VAA9ContainerVF : $@convention(thin) (@guaranteed Container) -> _scope(0) @owned BufferView {
118118
func getBorrowingView(_ x: borrowing Container) -> dependsOn(scoped x) BufferView {
119119
return BufferView(independent: x.ptr)
120120
}

0 commit comments

Comments
 (0)