Skip to content

Commit 2389286

Browse files
authored
Merge pull request #17892 from slavapestov/unique-id-be-gone
SILOptimizer: Remove 'unique ID' from FSO mangling
2 parents 90025ca + 330be4a commit 2389286

File tree

6 files changed

+9
-29
lines changed

6 files changed

+9
-29
lines changed

docs/ABI/Mangling.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ The type is the function type of the specialized function.
797797

798798
::
799799

800-
specialization ::= spec-arg* 'Tf' SPEC-INFO UNIQUE-ID? ARG-SPEC-KIND* '_' ARG-SPEC-KIND // Function signature specialization kind
800+
specialization ::= spec-arg* 'Tf' SPEC-INFO ARG-SPEC-KIND* '_' ARG-SPEC-KIND // Function signature specialization kind
801801

802802
The ``<ARG-SPEC-KIND>`` describes how arguments are specialized.
803803
Some kinds need arguments, which precede ``Tf``.
@@ -818,8 +818,6 @@ Some kinds need arguments, which precede ``Tf``.
818818

819819
FRAGILE ::= 'q'
820820

821-
UNIQUE-ID ::= NATURAL // Used to make unique function names
822-
823821
ARG-SPEC-KIND ::= 'n' // Unmodified argument
824822
ARG-SPEC-KIND ::= 'c' // Consumes n 'type' arguments which are closed over types in argument order
825823
// and one 'identifier' argument which is the closure symbol name

include/swift/Demangling/Demangler.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,7 @@ class Demangler : public NodeFactory {
454454
NodePointer addFuncSpecParamNumber(NodePointer Param,
455455
FunctionSigSpecializationParamKind Kind);
456456

457-
NodePointer demangleSpecAttributes(Node::Kind SpecKind,
458-
bool demangleUniqueID = false);
457+
NodePointer demangleSpecAttributes(Node::Kind SpecKind);
459458

460459
NodePointer demangleWitness();
461460
NodePointer demangleSpecialType();

include/swift/SILOptimizer/Utils/SpecializationMangler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class FunctionSignatureSpecializationMangler : public SpecializationMangler {
158158
void setArgumentBoxToStack(unsigned OrigArgIdx);
159159
void setReturnValueOwnedToUnowned();
160160

161-
std::string mangle(int UniqueID = 0);
161+
std::string mangle();
162162

163163
private:
164164
void mangleConstantProp(LiteralInst *LI);

lib/Demangling/Demangler.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,7 +1873,7 @@ NodePointer Demangler::demangleGenericSpecialization(Node::Kind SpecKind) {
18731873

18741874
NodePointer Demangler::demangleFunctionSpecialization() {
18751875
NodePointer Spec = demangleSpecAttributes(
1876-
Node::Kind::FunctionSignatureSpecialization, /*demangleUniqueID*/ true);
1876+
Node::Kind::FunctionSignatureSpecialization);
18771877
unsigned ParamIdx = 0;
18781878
while (Spec && !nextIf('_')) {
18791879
Spec = addChild(Spec, demangleFuncSpecParam(ParamIdx));
@@ -2069,24 +2069,14 @@ NodePointer Demangler::addFuncSpecParamNumber(NodePointer Param,
20692069
Node::Kind::FunctionSignatureSpecializationParamPayload, Str));
20702070
}
20712071

2072-
NodePointer Demangler::demangleSpecAttributes(Node::Kind SpecKind,
2073-
bool demangleUniqueID) {
2072+
NodePointer Demangler::demangleSpecAttributes(Node::Kind SpecKind) {
20742073
bool isFragile = nextIf('q');
20752074

20762075
int PassID = (int)nextChar() - '0';
20772076
if (PassID < 0 || PassID > 9)
20782077
return nullptr;
20792078

2080-
int Idx = -1;
2081-
if (demangleUniqueID)
2082-
Idx = demangleNatural();
2083-
2084-
NodePointer SpecNd = nullptr;
2085-
if (Idx >= 0) {
2086-
SpecNd = createNode(SpecKind, Idx);
2087-
} else {
2088-
SpecNd = createNode(SpecKind);
2089-
}
2079+
NodePointer SpecNd = createNode(SpecKind);
20902080
if (isFragile)
20912081
SpecNd->addChild(createNode(Node::Kind::SpecializationIsFragile),
20922082
*this);

lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,8 @@ FunctionSignatureTransformDescriptor::createOptimizedSILFunctionName() {
186186
}
187187

188188
SILModule &M = F->getModule();
189-
int UniqueID = 0;
190-
std::string MangledName;
191-
do {
192-
MangledName = Mangler.mangle(UniqueID);
193-
++UniqueID;
194-
} while (M.hasFunction(MangledName));
189+
auto MangledName = Mangler.mangle();
190+
assert(!M.hasFunction(MangledName));
195191

196192
return MangledName;
197193
}

lib/SILOptimizer/Utils/SpecializationMangler.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,10 @@ mangleReturnValue(ReturnValueModifierIntBase RetMod) {
339339
}
340340
}
341341

342-
std::string FunctionSignatureSpecializationMangler::mangle(int UniqueID) {
342+
std::string FunctionSignatureSpecializationMangler::mangle() {
343343
ArgOpStorage.clear();
344344
beginMangling();
345345

346-
if (UniqueID)
347-
ArgOpBuffer << UniqueID;
348-
349346
for (unsigned i : indices(OrigArgs)) {
350347
ArgumentModifierIntBase ArgMod;
351348
NullablePtr<SILInstruction> Inst;

0 commit comments

Comments
 (0)