Skip to content

Commit fdad907

Browse files
committed
Revert "Add debug info support for inlined and specialized generic variables."
There is an assertion failure building the source compatibility suite that needs to be investigated. This reverts commit 91f6f34.
1 parent a6952de commit fdad907

File tree

18 files changed

+70
-282
lines changed

18 files changed

+70
-282
lines changed

docs/ABI/Mangling.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,6 @@ Function Specializations
785785

786786
specialization ::= type '_' type* 'Tg' SPEC-INFO // Generic re-abstracted specialization
787787
specialization ::= type '_' type* 'TG' SPEC-INFO // Generic not re-abstracted specialization
788-
specialization ::= type '_' type* 'Ti' SPEC-INFO // Inlined function with generic substitutions.
789788

790789
The types are the replacement types of the substitution list.
791790

include/swift/AST/SubstitutionMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class SubstitutionMap {
153153
/// existential.
154154
bool hasOpenedExistential() const;
155155

156-
/// Query whether any replacement types in the map contain dynamic Self.
156+
/// Query whether any replacement type sin the map contain dynamic Self.
157157
bool hasDynamicSelf() const;
158158

159159
/// Whether the replacement types are all canonical.

include/swift/Demangling/DemangleNodes.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ NODE(ResilientProtocolWitnessTable)
8787
NODE(GenericSpecialization)
8888
NODE(GenericSpecializationNotReAbstracted)
8989
NODE(GenericSpecializationParam)
90-
NODE(InlinedGenericFunction)
9190
NODE(GenericTypeMetadataPattern)
9291
CONTEXT_NODE(Getter)
9392
NODE(Global)

include/swift/SIL/TypeSubstCloner.h

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "swift/SIL/SILCloner.h"
2525
#include "swift/SIL/DynamicCasts.h"
2626
#include "swift/SILOptimizer/Utils/Local.h"
27-
#include "swift/SILOptimizer/Utils/SpecializationMangler.h"
2827
#include "llvm/Support/Debug.h"
2928

3029
namespace swift {
@@ -280,84 +279,6 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
280279
super::visitDestroyValueInst(Destroy);
281280
}
282281

283-
/// One abstract function in the debug info can only have one set of variables
284-
/// and types. This function determines whether applying the substitutions in
285-
/// \p SubsMap on the generic signature \p Sig will change the generic type
286-
/// parameters in the signature. This is used to decide whether it's necessary
287-
/// to clone a unique copy of the function declaration with the substitutions
288-
/// applied for the debug info.
289-
static bool substitutionsChangeGenericTypeParameters(SubstitutionMap SubsMap,
290-
GenericSignature *Sig) {
291-
292-
// If there are no substitutions, just reuse
293-
// the original decl.
294-
if (SubsMap.empty())
295-
return false;
296-
297-
auto Params = Sig->getSubstitutableParams();
298-
return std::any_of(Params.begin(), Params.end(), [&](Type ParamType) {
299-
Type Substitution = Type(ParamType).subst(SubsMap);
300-
return !Substitution->isOpenedExistential() &&
301-
(Substitution->getCanonicalType() !=
302-
ParamType->getCanonicalType());
303-
});
304-
}
305-
306-
enum { ForInlining = true };
307-
/// Helper function to clone the parent function of a SILDebugScope if
308-
/// necessary when inlining said function into a new generic context.
309-
/// \param SubsMap - the substitutions of the inlining/specialization process.
310-
/// \param RemappedSig - the generic signature
311-
static SILFunction *remapParentFunction(SILModule &M,
312-
SILFunction *ParentFunction,
313-
SubstitutionMap SubsMap,
314-
GenericSignature *RemappedSig,
315-
bool ForInlining = false) {
316-
// If the original, non-inlined version of the function had no generic
317-
// environment, there is no need to remap it.
318-
auto *OriginalEnvironment = ParentFunction->getGenericEnvironment();
319-
if (!RemappedSig || !OriginalEnvironment)
320-
return ParentFunction;
321-
322-
if (SubsMap.hasArchetypes())
323-
SubsMap = SubsMap.mapReplacementTypesOutOfContext();
324-
325-
if (!substitutionsChangeGenericTypeParameters(SubsMap, RemappedSig))
326-
return ParentFunction;
327-
328-
// Clone the function with the substituted type for the debug info.
329-
Mangle::GenericSpecializationMangler Mangler(
330-
ParentFunction, SubsMap, IsNotSerialized, false, ForInlining);
331-
std::string MangledName = Mangler.mangle(RemappedSig);
332-
333-
if (ParentFunction->getName() == MangledName)
334-
return ParentFunction;
335-
if (auto *CachedFn = M.lookUpFunction(MangledName))
336-
ParentFunction = CachedFn;
337-
else {
338-
// Create a new function with this mangled name with an empty
339-
// body. There won't be any IR generated for it (hence the linkage),
340-
// but the symbol will be refered to by the debug info metadata.
341-
ParentFunction = M.getOrCreateFunction(
342-
ParentFunction->getLocation(), MangledName, SILLinkage::Shared,
343-
ParentFunction->getLoweredFunctionType(), ParentFunction->isBare(),
344-
ParentFunction->isTransparent(), ParentFunction->isSerialized(), 0,
345-
ParentFunction->isThunk(), ParentFunction->getClassSubclassScope());
346-
// Increment the ref count for the inlined function, so it doesn't
347-
// get deleted before we can emit abstract debug info for it.
348-
if (!ParentFunction->isZombie()) {
349-
ParentFunction->setInlined();
350-
// If the function was newly created with an empty body mark it as
351-
// undead.
352-
if (ParentFunction->empty()) {
353-
M.eraseFunction(ParentFunction);
354-
ParentFunction->setGenericEnvironment(OriginalEnvironment);
355-
}
356-
}
357-
}
358-
return ParentFunction;
359-
}
360-
361282
/// The Swift module that the cloned function belongs to.
362283
ModuleDecl *SwiftMod;
363284
/// The substitutions list for the specialization.
@@ -368,7 +289,7 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
368289
SILFunction &Original;
369290
/// True, if used for inlining.
370291
bool Inlining;
371-
};
292+
};
372293

373294
} // end namespace swift
374295

include/swift/SILOptimizer/Utils/GenericCloner.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ class GenericCloner : public TypeSubstCloner<GenericCloner> {
3434
IsSerialized_t Serialized;
3535
const ReabstractionInfo &ReInfo;
3636
CloneCollector::CallbackType Callback;
37-
llvm::SmallDenseMap<const SILDebugScope *, const SILDebugScope *, 8>
38-
RemappedScopeCache;
3937

4038
public:
4139
friend class SILCloner<GenericCloner>;
@@ -92,9 +90,6 @@ class GenericCloner : public TypeSubstCloner<GenericCloner> {
9290
/// by initCloned.
9391
void populateCloned();
9492
SILFunction *getCloned() { return &getBuilder().getFunction(); }
95-
96-
const SILDebugScope *remapScope(const SILDebugScope *DS);
97-
9893
};
9994

10095
} // end namespace swift

include/swift/SILOptimizer/Utils/SpecializationMangler.h

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ class SpecializationMangler : public Mangle::ASTMangler {
4848
protected:
4949
SpecializationMangler(SpecializationPass P, IsSerialized_t Serialized,
5050
SILFunction *F)
51-
: Pass(P), Serialized(Serialized), Function(F),
52-
ArgOpBuffer(ArgOpStorage) {}
51+
: Pass(P), Serialized(Serialized), Function(F), ArgOpBuffer(ArgOpStorage) {}
5352

5453
SILFunction *getFunction() const { return Function; }
5554

@@ -68,17 +67,17 @@ class GenericSpecializationMangler : public SpecializationMangler {
6867

6968
SubstitutionMap SubMap;
7069
bool isReAbstracted;
71-
bool isInlined;
7270

7371
public:
74-
GenericSpecializationMangler(SILFunction *F, SubstitutionMap SubMap,
75-
IsSerialized_t Serialized, bool isReAbstracted,
76-
bool isInlined = false)
77-
: SpecializationMangler(SpecializationPass::GenericSpecializer,
78-
Serialized, F),
79-
SubMap(SubMap), isReAbstracted(isReAbstracted), isInlined(isInlined) {}
80-
81-
std::string mangle(GenericSignature *Sig = nullptr);
72+
73+
GenericSpecializationMangler(SILFunction *F,
74+
SubstitutionMap SubMap,
75+
IsSerialized_t Serialized,
76+
bool isReAbstracted)
77+
: SpecializationMangler(SpecializationPass::GenericSpecializer, Serialized, F),
78+
SubMap(SubMap), isReAbstracted(isReAbstracted) {}
79+
80+
std::string mangle();
8281
};
8382

8483
class PartialSpecializationMangler : public SpecializationMangler {
@@ -89,10 +88,10 @@ class PartialSpecializationMangler : public SpecializationMangler {
8988
public:
9089
PartialSpecializationMangler(SILFunction *F,
9190
CanSILFunctionType SpecializedFnTy,
92-
IsSerialized_t Serialized, bool isReAbstracted)
93-
: SpecializationMangler(SpecializationPass::GenericSpecializer,
94-
Serialized, F),
95-
SpecializedFnTy(SpecializedFnTy), isReAbstracted(isReAbstracted) {}
91+
IsSerialized_t Serialized,
92+
bool isReAbstracted)
93+
: SpecializationMangler(SpecializationPass::GenericSpecializer, Serialized, F),
94+
SpecializedFnTy(SpecializedFnTy), isReAbstracted(isReAbstracted) {}
9695

9796
std::string mangle();
9897
};

lib/Demangling/Demangler.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,13 +1731,11 @@ NodePointer Demangler::demangleThunkOrSpecialization() {
17311731
Thunk = addChild(Thunk, popNode(Node::Kind::Type));
17321732
return addChild(Thunk, Ty2);
17331733
}
1734-
case 'g':
1734+
case'g':
17351735
return demangleGenericSpecialization(Node::Kind::GenericSpecialization);
1736-
case 'G':
1736+
case'G':
17371737
return demangleGenericSpecialization(Node::Kind::
17381738
GenericSpecializationNotReAbstracted);
1739-
case 'i':
1740-
return demangleGenericSpecialization(Node::Kind::InlinedGenericFunction);
17411739
case'p': {
17421740
NodePointer Spec = demangleSpecAttributes(Node::Kind::
17431741
GenericPartialSpecialization);
@@ -1868,8 +1866,7 @@ NodePointer Demangler::demangleGenericSpecialization(Node::Kind SpecKind) {
18681866
if (!TyList)
18691867
return nullptr;
18701868
for (NodePointer Ty : *TyList) {
1871-
Spec->addChild(createWithChild(Node::Kind::GenericSpecializationParam, Ty),
1872-
*this);
1869+
Spec->addChild(createWithChild(Node::Kind::GenericSpecializationParam, Ty), *this);
18731870
}
18741871
return Spec;
18751872
}

lib/Demangling/NodePrinter.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ class NodePrinter {
351351
case Node::Kind::GenericSpecialization:
352352
case Node::Kind::GenericSpecializationNotReAbstracted:
353353
case Node::Kind::GenericSpecializationParam:
354-
case Node::Kind::InlinedGenericFunction:
355354
case Node::Kind::GenericTypeMetadataPattern:
356355
case Node::Kind::Getter:
357356
case Node::Kind::Global:
@@ -1182,9 +1181,6 @@ NodePointer NodePrinter::print(NodePointer Node, bool asPrefixContext) {
11821181
case Node::Kind::GenericSpecializationNotReAbstracted:
11831182
printSpecializationPrefix(Node, "generic not re-abstracted specialization");
11841183
return nullptr;
1185-
case Node::Kind::InlinedGenericFunction:
1186-
printSpecializationPrefix(Node, "inlined generic function");
1187-
return nullptr;
11881184
case Node::Kind::SpecializationIsFragile:
11891185
Printer << "preserving fragile attribute";
11901186
return nullptr;

lib/Demangling/OldRemangler.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,6 @@ void Remangler::mangleGenericSpecialization(Node *node) {
534534
// Start another mangled name.
535535
Out << "__T";
536536
}
537-
538537
void Remangler::mangleGenericSpecializationNotReAbstracted(Node *node) {
539538
Out << "TSr";
540539
mangleChildNodes(node); // GenericSpecializationParams
@@ -546,17 +545,6 @@ void Remangler::mangleGenericSpecializationNotReAbstracted(Node *node) {
546545
Out << "__T";
547546
}
548547

549-
void Remangler::mangleInlinedGenericFunction(Node *node) {
550-
Out << "TSi";
551-
mangleChildNodes(node); // GenericSpecializationParams
552-
553-
// Specializations are just prepended to already-mangled names.
554-
resetSubstitutions();
555-
556-
// Start another mangled name.
557-
Out << "__T";
558-
}
559-
560548
void Remangler::mangleGenericPartialSpecialization(Node *node) {
561549
unreachable("todo");
562550
}

lib/Demangling/Remangler.cpp

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,20 +1122,8 @@ void Remangler::mangleGenericSpecialization(Node *node) {
11221122
}
11231123
assert(!FirstParam && "generic specialization with no substitutions");
11241124

1125-
switch (node->getKind()) {
1126-
case Node::Kind::GenericSpecialization:
1127-
Buffer << "Tg";
1128-
break;
1129-
case Node::Kind::GenericSpecializationNotReAbstracted:
1130-
Buffer << "TG";
1131-
break;
1132-
case Node::Kind::InlinedGenericFunction:
1133-
Buffer << "Ti";
1134-
break;
1135-
default:
1136-
unreachable("unsupported node");
1137-
}
1138-
1125+
Buffer << (node->getKind() ==
1126+
Node::Kind::GenericSpecializationNotReAbstracted ? "TG" : "Tg");
11391127
for (NodePointer Child : *node) {
11401128
if (Child->getKind() != Node::Kind::GenericSpecializationParam)
11411129
mangle(Child);
@@ -1146,11 +1134,6 @@ void Remangler::mangleGenericSpecializationNotReAbstracted(Node *node) {
11461134
mangleGenericSpecialization(node);
11471135
}
11481136

1149-
void Remangler::mangleInlinedGenericFunction(Node *node) {
1150-
mangleGenericSpecialization(node);
1151-
}
1152-
1153-
11541137
void Remangler::mangleGenericSpecializationParam(Node *node) {
11551138
unreachable("handled inline");
11561139
}
@@ -1178,7 +1161,6 @@ void Remangler::mangleGlobal(Node *node) {
11781161
case Node::Kind::FunctionSignatureSpecialization:
11791162
case Node::Kind::GenericSpecialization:
11801163
case Node::Kind::GenericSpecializationNotReAbstracted:
1181-
case Node::Kind::InlinedGenericFunction:
11821164
case Node::Kind::GenericPartialSpecialization:
11831165
case Node::Kind::GenericPartialSpecializationNotReAbstracted:
11841166
case Node::Kind::OutlinedBridgedMethod:

0 commit comments

Comments
 (0)