Skip to content

SILOptimizer: Remove 'unique ID' from FSO mangling #17892

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 1 commit into from
Jul 12, 2018
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
4 changes: 1 addition & 3 deletions docs/ABI/Mangling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ The type is the function type of the specialized function.

::

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

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

FRAGILE ::= 'q'

UNIQUE-ID ::= NATURAL // Used to make unique function names

ARG-SPEC-KIND ::= 'n' // Unmodified argument
ARG-SPEC-KIND ::= 'c' // Consumes n 'type' arguments which are closed over types in argument order
// and one 'identifier' argument which is the closure symbol name
Expand Down
3 changes: 1 addition & 2 deletions include/swift/Demangling/Demangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,7 @@ class Demangler : public NodeFactory {
NodePointer addFuncSpecParamNumber(NodePointer Param,
FunctionSigSpecializationParamKind Kind);

NodePointer demangleSpecAttributes(Node::Kind SpecKind,
bool demangleUniqueID = false);
NodePointer demangleSpecAttributes(Node::Kind SpecKind);

NodePointer demangleWitness();
NodePointer demangleSpecialType();
Expand Down
2 changes: 1 addition & 1 deletion include/swift/SILOptimizer/Utils/SpecializationMangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class FunctionSignatureSpecializationMangler : public SpecializationMangler {
void setArgumentBoxToStack(unsigned OrigArgIdx);
void setReturnValueOwnedToUnowned();

std::string mangle(int UniqueID = 0);
std::string mangle();

private:
void mangleConstantProp(LiteralInst *LI);
Expand Down
16 changes: 3 additions & 13 deletions lib/Demangling/Demangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,7 @@ NodePointer Demangler::demangleGenericSpecialization(Node::Kind SpecKind) {

NodePointer Demangler::demangleFunctionSpecialization() {
NodePointer Spec = demangleSpecAttributes(
Node::Kind::FunctionSignatureSpecialization, /*demangleUniqueID*/ true);
Node::Kind::FunctionSignatureSpecialization);
unsigned ParamIdx = 0;
while (Spec && !nextIf('_')) {
Spec = addChild(Spec, demangleFuncSpecParam(ParamIdx));
Expand Down Expand Up @@ -2069,24 +2069,14 @@ NodePointer Demangler::addFuncSpecParamNumber(NodePointer Param,
Node::Kind::FunctionSignatureSpecializationParamPayload, Str));
}

NodePointer Demangler::demangleSpecAttributes(Node::Kind SpecKind,
bool demangleUniqueID) {
NodePointer Demangler::demangleSpecAttributes(Node::Kind SpecKind) {
bool isFragile = nextIf('q');

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

int Idx = -1;
if (demangleUniqueID)
Idx = demangleNatural();

NodePointer SpecNd = nullptr;
if (Idx >= 0) {
SpecNd = createNode(SpecKind, Idx);
} else {
SpecNd = createNode(SpecKind);
}
NodePointer SpecNd = createNode(SpecKind);
if (isFragile)
SpecNd->addChild(createNode(Node::Kind::SpecializationIsFragile),
*this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,8 @@ FunctionSignatureTransformDescriptor::createOptimizedSILFunctionName() {
}

SILModule &M = F->getModule();
int UniqueID = 0;
std::string MangledName;
do {
MangledName = Mangler.mangle(UniqueID);
++UniqueID;
} while (M.hasFunction(MangledName));
auto MangledName = Mangler.mangle();
assert(!M.hasFunction(MangledName));

return MangledName;
}
Expand Down
5 changes: 1 addition & 4 deletions lib/SILOptimizer/Utils/SpecializationMangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,10 @@ mangleReturnValue(ReturnValueModifierIntBase RetMod) {
}
}

std::string FunctionSignatureSpecializationMangler::mangle(int UniqueID) {
std::string FunctionSignatureSpecializationMangler::mangle() {
ArgOpStorage.clear();
beginMangling();

if (UniqueID)
ArgOpBuffer << UniqueID;

for (unsigned i : indices(OrigArgs)) {
ArgumentModifierIntBase ArgMod;
NullablePtr<SILInstruction> Inst;
Expand Down