mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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 91f6f34119.
This commit is contained in:
@@ -785,7 +785,6 @@ Function Specializations
|
||||
|
||||
specialization ::= type '_' type* 'Tg' SPEC-INFO // Generic re-abstracted specialization
|
||||
specialization ::= type '_' type* 'TG' SPEC-INFO // Generic not re-abstracted specialization
|
||||
specialization ::= type '_' type* 'Ti' SPEC-INFO // Inlined function with generic substitutions.
|
||||
|
||||
The types are the replacement types of the substitution list.
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ public:
|
||||
/// existential.
|
||||
bool hasOpenedExistential() const;
|
||||
|
||||
/// Query whether any replacement types in the map contain dynamic Self.
|
||||
/// Query whether any replacement type sin the map contain dynamic Self.
|
||||
bool hasDynamicSelf() const;
|
||||
|
||||
/// Whether the replacement types are all canonical.
|
||||
|
||||
@@ -87,7 +87,6 @@ NODE(ResilientProtocolWitnessTable)
|
||||
NODE(GenericSpecialization)
|
||||
NODE(GenericSpecializationNotReAbstracted)
|
||||
NODE(GenericSpecializationParam)
|
||||
NODE(InlinedGenericFunction)
|
||||
NODE(GenericTypeMetadataPattern)
|
||||
CONTEXT_NODE(Getter)
|
||||
NODE(Global)
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "swift/SIL/SILCloner.h"
|
||||
#include "swift/SIL/DynamicCasts.h"
|
||||
#include "swift/SILOptimizer/Utils/Local.h"
|
||||
#include "swift/SILOptimizer/Utils/SpecializationMangler.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
|
||||
namespace swift {
|
||||
@@ -280,84 +279,6 @@ protected:
|
||||
super::visitDestroyValueInst(Destroy);
|
||||
}
|
||||
|
||||
/// One abstract function in the debug info can only have one set of variables
|
||||
/// and types. This function determines whether applying the substitutions in
|
||||
/// \p SubsMap on the generic signature \p Sig will change the generic type
|
||||
/// parameters in the signature. This is used to decide whether it's necessary
|
||||
/// to clone a unique copy of the function declaration with the substitutions
|
||||
/// applied for the debug info.
|
||||
static bool substitutionsChangeGenericTypeParameters(SubstitutionMap SubsMap,
|
||||
GenericSignature *Sig) {
|
||||
|
||||
// If there are no substitutions, just reuse
|
||||
// the original decl.
|
||||
if (SubsMap.empty())
|
||||
return false;
|
||||
|
||||
auto Params = Sig->getSubstitutableParams();
|
||||
return std::any_of(Params.begin(), Params.end(), [&](Type ParamType) {
|
||||
Type Substitution = Type(ParamType).subst(SubsMap);
|
||||
return !Substitution->isOpenedExistential() &&
|
||||
(Substitution->getCanonicalType() !=
|
||||
ParamType->getCanonicalType());
|
||||
});
|
||||
}
|
||||
|
||||
enum { ForInlining = true };
|
||||
/// Helper function to clone the parent function of a SILDebugScope if
|
||||
/// necessary when inlining said function into a new generic context.
|
||||
/// \param SubsMap - the substitutions of the inlining/specialization process.
|
||||
/// \param RemappedSig - the generic signature
|
||||
static SILFunction *remapParentFunction(SILModule &M,
|
||||
SILFunction *ParentFunction,
|
||||
SubstitutionMap SubsMap,
|
||||
GenericSignature *RemappedSig,
|
||||
bool ForInlining = false) {
|
||||
// If the original, non-inlined version of the function had no generic
|
||||
// environment, there is no need to remap it.
|
||||
auto *OriginalEnvironment = ParentFunction->getGenericEnvironment();
|
||||
if (!RemappedSig || !OriginalEnvironment)
|
||||
return ParentFunction;
|
||||
|
||||
if (SubsMap.hasArchetypes())
|
||||
SubsMap = SubsMap.mapReplacementTypesOutOfContext();
|
||||
|
||||
if (!substitutionsChangeGenericTypeParameters(SubsMap, RemappedSig))
|
||||
return ParentFunction;
|
||||
|
||||
// Clone the function with the substituted type for the debug info.
|
||||
Mangle::GenericSpecializationMangler Mangler(
|
||||
ParentFunction, SubsMap, IsNotSerialized, false, ForInlining);
|
||||
std::string MangledName = Mangler.mangle(RemappedSig);
|
||||
|
||||
if (ParentFunction->getName() == MangledName)
|
||||
return ParentFunction;
|
||||
if (auto *CachedFn = M.lookUpFunction(MangledName))
|
||||
ParentFunction = CachedFn;
|
||||
else {
|
||||
// Create a new function with this mangled name with an empty
|
||||
// body. There won't be any IR generated for it (hence the linkage),
|
||||
// but the symbol will be refered to by the debug info metadata.
|
||||
ParentFunction = M.getOrCreateFunction(
|
||||
ParentFunction->getLocation(), MangledName, SILLinkage::Shared,
|
||||
ParentFunction->getLoweredFunctionType(), ParentFunction->isBare(),
|
||||
ParentFunction->isTransparent(), ParentFunction->isSerialized(), 0,
|
||||
ParentFunction->isThunk(), ParentFunction->getClassSubclassScope());
|
||||
// Increment the ref count for the inlined function, so it doesn't
|
||||
// get deleted before we can emit abstract debug info for it.
|
||||
if (!ParentFunction->isZombie()) {
|
||||
ParentFunction->setInlined();
|
||||
// If the function was newly created with an empty body mark it as
|
||||
// undead.
|
||||
if (ParentFunction->empty()) {
|
||||
M.eraseFunction(ParentFunction);
|
||||
ParentFunction->setGenericEnvironment(OriginalEnvironment);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ParentFunction;
|
||||
}
|
||||
|
||||
/// The Swift module that the cloned function belongs to.
|
||||
ModuleDecl *SwiftMod;
|
||||
/// The substitutions list for the specialization.
|
||||
@@ -368,7 +289,7 @@ protected:
|
||||
SILFunction &Original;
|
||||
/// True, if used for inlining.
|
||||
bool Inlining;
|
||||
};
|
||||
};
|
||||
|
||||
} // end namespace swift
|
||||
|
||||
|
||||
@@ -34,8 +34,6 @@ class GenericCloner : public TypeSubstCloner<GenericCloner> {
|
||||
IsSerialized_t Serialized;
|
||||
const ReabstractionInfo &ReInfo;
|
||||
CloneCollector::CallbackType Callback;
|
||||
llvm::SmallDenseMap<const SILDebugScope *, const SILDebugScope *, 8>
|
||||
RemappedScopeCache;
|
||||
|
||||
public:
|
||||
friend class SILCloner<GenericCloner>;
|
||||
@@ -92,9 +90,6 @@ private:
|
||||
/// by initCloned.
|
||||
void populateCloned();
|
||||
SILFunction *getCloned() { return &getBuilder().getFunction(); }
|
||||
|
||||
const SILDebugScope *remapScope(const SILDebugScope *DS);
|
||||
|
||||
};
|
||||
|
||||
} // end namespace swift
|
||||
|
||||
@@ -48,8 +48,7 @@ protected:
|
||||
protected:
|
||||
SpecializationMangler(SpecializationPass P, IsSerialized_t Serialized,
|
||||
SILFunction *F)
|
||||
: Pass(P), Serialized(Serialized), Function(F),
|
||||
ArgOpBuffer(ArgOpStorage) {}
|
||||
: Pass(P), Serialized(Serialized), Function(F), ArgOpBuffer(ArgOpStorage) {}
|
||||
|
||||
SILFunction *getFunction() const { return Function; }
|
||||
|
||||
@@ -68,17 +67,17 @@ class GenericSpecializationMangler : public SpecializationMangler {
|
||||
|
||||
SubstitutionMap SubMap;
|
||||
bool isReAbstracted;
|
||||
bool isInlined;
|
||||
|
||||
public:
|
||||
GenericSpecializationMangler(SILFunction *F, SubstitutionMap SubMap,
|
||||
IsSerialized_t Serialized, bool isReAbstracted,
|
||||
bool isInlined = false)
|
||||
: SpecializationMangler(SpecializationPass::GenericSpecializer,
|
||||
Serialized, F),
|
||||
SubMap(SubMap), isReAbstracted(isReAbstracted), isInlined(isInlined) {}
|
||||
|
||||
std::string mangle(GenericSignature *Sig = nullptr);
|
||||
GenericSpecializationMangler(SILFunction *F,
|
||||
SubstitutionMap SubMap,
|
||||
IsSerialized_t Serialized,
|
||||
bool isReAbstracted)
|
||||
: SpecializationMangler(SpecializationPass::GenericSpecializer, Serialized, F),
|
||||
SubMap(SubMap), isReAbstracted(isReAbstracted) {}
|
||||
|
||||
std::string mangle();
|
||||
};
|
||||
|
||||
class PartialSpecializationMangler : public SpecializationMangler {
|
||||
@@ -89,9 +88,9 @@ class PartialSpecializationMangler : public SpecializationMangler {
|
||||
public:
|
||||
PartialSpecializationMangler(SILFunction *F,
|
||||
CanSILFunctionType SpecializedFnTy,
|
||||
IsSerialized_t Serialized, bool isReAbstracted)
|
||||
: SpecializationMangler(SpecializationPass::GenericSpecializer,
|
||||
Serialized, F),
|
||||
IsSerialized_t Serialized,
|
||||
bool isReAbstracted)
|
||||
: SpecializationMangler(SpecializationPass::GenericSpecializer, Serialized, F),
|
||||
SpecializedFnTy(SpecializedFnTy), isReAbstracted(isReAbstracted) {}
|
||||
|
||||
std::string mangle();
|
||||
|
||||
@@ -1731,13 +1731,11 @@ NodePointer Demangler::demangleThunkOrSpecialization() {
|
||||
Thunk = addChild(Thunk, popNode(Node::Kind::Type));
|
||||
return addChild(Thunk, Ty2);
|
||||
}
|
||||
case 'g':
|
||||
case'g':
|
||||
return demangleGenericSpecialization(Node::Kind::GenericSpecialization);
|
||||
case 'G':
|
||||
case'G':
|
||||
return demangleGenericSpecialization(Node::Kind::
|
||||
GenericSpecializationNotReAbstracted);
|
||||
case 'i':
|
||||
return demangleGenericSpecialization(Node::Kind::InlinedGenericFunction);
|
||||
case'p': {
|
||||
NodePointer Spec = demangleSpecAttributes(Node::Kind::
|
||||
GenericPartialSpecialization);
|
||||
@@ -1868,8 +1866,7 @@ NodePointer Demangler::demangleGenericSpecialization(Node::Kind SpecKind) {
|
||||
if (!TyList)
|
||||
return nullptr;
|
||||
for (NodePointer Ty : *TyList) {
|
||||
Spec->addChild(createWithChild(Node::Kind::GenericSpecializationParam, Ty),
|
||||
*this);
|
||||
Spec->addChild(createWithChild(Node::Kind::GenericSpecializationParam, Ty), *this);
|
||||
}
|
||||
return Spec;
|
||||
}
|
||||
|
||||
@@ -351,7 +351,6 @@ private:
|
||||
case Node::Kind::GenericSpecialization:
|
||||
case Node::Kind::GenericSpecializationNotReAbstracted:
|
||||
case Node::Kind::GenericSpecializationParam:
|
||||
case Node::Kind::InlinedGenericFunction:
|
||||
case Node::Kind::GenericTypeMetadataPattern:
|
||||
case Node::Kind::Getter:
|
||||
case Node::Kind::Global:
|
||||
@@ -1182,9 +1181,6 @@ NodePointer NodePrinter::print(NodePointer Node, bool asPrefixContext) {
|
||||
case Node::Kind::GenericSpecializationNotReAbstracted:
|
||||
printSpecializationPrefix(Node, "generic not re-abstracted specialization");
|
||||
return nullptr;
|
||||
case Node::Kind::InlinedGenericFunction:
|
||||
printSpecializationPrefix(Node, "inlined generic function");
|
||||
return nullptr;
|
||||
case Node::Kind::SpecializationIsFragile:
|
||||
Printer << "preserving fragile attribute";
|
||||
return nullptr;
|
||||
|
||||
@@ -534,7 +534,6 @@ void Remangler::mangleGenericSpecialization(Node *node) {
|
||||
// Start another mangled name.
|
||||
Out << "__T";
|
||||
}
|
||||
|
||||
void Remangler::mangleGenericSpecializationNotReAbstracted(Node *node) {
|
||||
Out << "TSr";
|
||||
mangleChildNodes(node); // GenericSpecializationParams
|
||||
@@ -546,17 +545,6 @@ void Remangler::mangleGenericSpecializationNotReAbstracted(Node *node) {
|
||||
Out << "__T";
|
||||
}
|
||||
|
||||
void Remangler::mangleInlinedGenericFunction(Node *node) {
|
||||
Out << "TSi";
|
||||
mangleChildNodes(node); // GenericSpecializationParams
|
||||
|
||||
// Specializations are just prepended to already-mangled names.
|
||||
resetSubstitutions();
|
||||
|
||||
// Start another mangled name.
|
||||
Out << "__T";
|
||||
}
|
||||
|
||||
void Remangler::mangleGenericPartialSpecialization(Node *node) {
|
||||
unreachable("todo");
|
||||
}
|
||||
|
||||
@@ -1122,20 +1122,8 @@ void Remangler::mangleGenericSpecialization(Node *node) {
|
||||
}
|
||||
assert(!FirstParam && "generic specialization with no substitutions");
|
||||
|
||||
switch (node->getKind()) {
|
||||
case Node::Kind::GenericSpecialization:
|
||||
Buffer << "Tg";
|
||||
break;
|
||||
case Node::Kind::GenericSpecializationNotReAbstracted:
|
||||
Buffer << "TG";
|
||||
break;
|
||||
case Node::Kind::InlinedGenericFunction:
|
||||
Buffer << "Ti";
|
||||
break;
|
||||
default:
|
||||
unreachable("unsupported node");
|
||||
}
|
||||
|
||||
Buffer << (node->getKind() ==
|
||||
Node::Kind::GenericSpecializationNotReAbstracted ? "TG" : "Tg");
|
||||
for (NodePointer Child : *node) {
|
||||
if (Child->getKind() != Node::Kind::GenericSpecializationParam)
|
||||
mangle(Child);
|
||||
@@ -1146,11 +1134,6 @@ void Remangler::mangleGenericSpecializationNotReAbstracted(Node *node) {
|
||||
mangleGenericSpecialization(node);
|
||||
}
|
||||
|
||||
void Remangler::mangleInlinedGenericFunction(Node *node) {
|
||||
mangleGenericSpecialization(node);
|
||||
}
|
||||
|
||||
|
||||
void Remangler::mangleGenericSpecializationParam(Node *node) {
|
||||
unreachable("handled inline");
|
||||
}
|
||||
@@ -1178,7 +1161,6 @@ void Remangler::mangleGlobal(Node *node) {
|
||||
case Node::Kind::FunctionSignatureSpecialization:
|
||||
case Node::Kind::GenericSpecialization:
|
||||
case Node::Kind::GenericSpecializationNotReAbstracted:
|
||||
case Node::Kind::InlinedGenericFunction:
|
||||
case Node::Kind::GenericPartialSpecialization:
|
||||
case Node::Kind::GenericPartialSpecializationNotReAbstracted:
|
||||
case Node::Kind::OutlinedBridgedMethod:
|
||||
|
||||
@@ -70,9 +70,23 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
|
||||
llvm::DIBuilder DBuilder;
|
||||
IRGenModule &IGM;
|
||||
|
||||
/// Used for caching SILDebugScopes without inline information.
|
||||
using LocalScopeHash = std::pair<const void *, const void *>;
|
||||
struct LocalScope : public LocalScopeHash {
|
||||
LocalScope(const SILDebugScope *DS)
|
||||
: LocalScopeHash({DS->Loc.getOpaquePointerValue(),
|
||||
// If there is no parent SIL function use the scope
|
||||
// pointer as a unique id instead. This is safe
|
||||
// because such a function could also never have been
|
||||
// SIL-inlined.
|
||||
DS->Parent.getOpaqueValue()
|
||||
? DS->Parent.getOpaqueValue()
|
||||
: DS}) {}
|
||||
};
|
||||
|
||||
/// Various caches.
|
||||
/// @{
|
||||
llvm::DenseMap<const SILDebugScope *, llvm::TrackingMDNodeRef> ScopeCache;
|
||||
llvm::DenseMap<LocalScopeHash, llvm::TrackingMDNodeRef> ScopeCache;
|
||||
llvm::DenseMap<const SILDebugScope *, llvm::TrackingMDNodeRef> InlinedAtCache;
|
||||
llvm::DenseMap<const void *, SILLocation::DebugLoc> DebugLocCache;
|
||||
llvm::DenseMap<TypeBase *, llvm::TrackingMDNodeRef> DITypeCache;
|
||||
@@ -1634,7 +1648,7 @@ llvm::DIScope *IRGenDebugInfoImpl::getOrCreateScope(const SILDebugScope *DS) {
|
||||
return MainFile;
|
||||
|
||||
// Try to find it in the cache first.
|
||||
auto CachedScope = ScopeCache.find(DS);
|
||||
auto CachedScope = ScopeCache.find(LocalScope(DS));
|
||||
if (CachedScope != ScopeCache.end())
|
||||
return cast<llvm::DIScope>(CachedScope->second);
|
||||
|
||||
@@ -1646,7 +1660,7 @@ llvm::DIScope *IRGenDebugInfoImpl::getOrCreateScope(const SILDebugScope *DS) {
|
||||
if (!FnScope)
|
||||
SILFn->setDebugScope(DS);
|
||||
|
||||
auto CachedScope = ScopeCache.find(FnScope);
|
||||
auto CachedScope = ScopeCache.find(LocalScope(FnScope));
|
||||
if (CachedScope != ScopeCache.end())
|
||||
return cast<llvm::DIScope>(CachedScope->second);
|
||||
|
||||
@@ -1658,7 +1672,7 @@ llvm::DIScope *IRGenDebugInfoImpl::getOrCreateScope(const SILDebugScope *DS) {
|
||||
auto *SP = emitFunction(*SILFn, Fn);
|
||||
|
||||
// Cache it.
|
||||
ScopeCache[DS] = llvm::TrackingMDNodeRef(SP);
|
||||
ScopeCache[LocalScope(DS)] = llvm::TrackingMDNodeRef(SP);
|
||||
return SP;
|
||||
}
|
||||
|
||||
@@ -1675,7 +1689,7 @@ llvm::DIScope *IRGenDebugInfoImpl::getOrCreateScope(const SILDebugScope *DS) {
|
||||
auto *DScope = DBuilder.createLexicalBlock(Parent, File, L.Line, L.Column);
|
||||
|
||||
// Cache it.
|
||||
ScopeCache[DS] = llvm::TrackingMDNodeRef(DScope);
|
||||
ScopeCache[LocalScope(DS)] = llvm::TrackingMDNodeRef(DScope);
|
||||
return DScope;
|
||||
}
|
||||
|
||||
@@ -1707,7 +1721,7 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn,
|
||||
SILFunctionTypeRepresentation Rep,
|
||||
SILType SILTy, DeclContext *DeclCtx,
|
||||
GenericEnvironment *GE) {
|
||||
auto Cached = ScopeCache.find(DS);
|
||||
auto Cached = ScopeCache.find(LocalScope(DS));
|
||||
if (Cached != ScopeCache.end()) {
|
||||
auto SP = cast<llvm::DISubprogram>(Cached->second);
|
||||
// If we created the DISubprogram for a forward declaration,
|
||||
@@ -1830,7 +1844,7 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn,
|
||||
if (!DS)
|
||||
return nullptr;
|
||||
|
||||
ScopeCache[DS] = llvm::TrackingMDNodeRef(SP);
|
||||
ScopeCache[LocalScope(DS)] = llvm::TrackingMDNodeRef(SP);
|
||||
return SP;
|
||||
}
|
||||
|
||||
@@ -1861,8 +1875,9 @@ void IRGenDebugInfoImpl::emitVariableDeclaration(
|
||||
if (Opts.DebugInfoLevel <= IRGenDebugInfoLevel::LineTables)
|
||||
return;
|
||||
|
||||
// We cannot yet represent opened existentials.
|
||||
if (DbgTy.Type->hasOpenedExistential())
|
||||
// Currently, the DeclContext is needed to mangle archetypes. Bail out if
|
||||
// it's missing.
|
||||
if (DbgTy.Type->hasArchetype() && !DbgTy.DeclCtx)
|
||||
return;
|
||||
|
||||
if (!DbgTy.size)
|
||||
|
||||
@@ -79,11 +79,6 @@
|
||||
using namespace swift;
|
||||
using namespace irgen;
|
||||
|
||||
// FIXME: Remove this option entirely and turn this on by default.
|
||||
llvm::cl::opt<bool> DebugInfoInlinedGenerics(
|
||||
"debug-info-inlined-generics", llvm::cl::init(false),
|
||||
llvm::cl::desc("Emit variable debug info for inlined generic functions"));
|
||||
|
||||
namespace {
|
||||
|
||||
class LoweredValue;
|
||||
@@ -859,8 +854,6 @@ public:
|
||||
|
||||
/// Determine whether a generic variable has been inlined.
|
||||
static bool isInlinedGeneric(VarDecl *VarDecl, const SILDebugScope *DS) {
|
||||
if (DebugInfoInlinedGenerics)
|
||||
return false;
|
||||
if (!DS->InlinedCallSite)
|
||||
return false;
|
||||
if (VarDecl->hasType())
|
||||
|
||||
@@ -593,7 +593,7 @@ void SILModule::removeFromZombieList(StringRef Name) {
|
||||
|
||||
/// Erase a function from the module.
|
||||
void SILModule::eraseFunction(SILFunction *F) {
|
||||
assert(!F->isZombie() && "zombie function is in list of alive functions");
|
||||
assert(! F->isZombie() && "zombie function is in list of alive functions");
|
||||
// The owner of the function's Name is the FunctionTable key. As we remove
|
||||
// the function from the table we have to store the name string elsewhere:
|
||||
// in zombieFunctionNames.
|
||||
|
||||
@@ -165,28 +165,3 @@ void GenericCloner::populateCloned() {
|
||||
visit(BI->first->getTerminator());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const SILDebugScope *GenericCloner::remapScope(const SILDebugScope *DS) {
|
||||
if (!DS)
|
||||
return nullptr;
|
||||
auto it = RemappedScopeCache.find(DS);
|
||||
if (it != RemappedScopeCache.end())
|
||||
return it->second;
|
||||
|
||||
auto &M = getBuilder().getModule();
|
||||
auto *ParentFunction = DS->Parent.dyn_cast<SILFunction *>();
|
||||
if (ParentFunction == &Original)
|
||||
ParentFunction = getCloned();
|
||||
else if (ParentFunction)
|
||||
ParentFunction = remapParentFunction(
|
||||
M, ParentFunction, SubsMap,
|
||||
Original.getLoweredFunctionType()->getGenericSignature());
|
||||
|
||||
auto *ParentScope = DS->Parent.dyn_cast<const SILDebugScope *>();
|
||||
auto *RemappedScope =
|
||||
new (M) SILDebugScope(DS->Loc, ParentFunction, remapScope(ParentScope),
|
||||
remapScope(DS->InlinedCallSite));
|
||||
RemappedScopeCache.insert({DS, RemappedScope});
|
||||
return RemappedScope;
|
||||
}
|
||||
|
||||
@@ -248,6 +248,10 @@ void SILInliner::inlineFunction(FullApplySite AI, ArrayRef<SILValue> Args) {
|
||||
assert(CallSiteScope && "call site has no scope");
|
||||
assert(CallSiteScope->getParentFunction() == &F);
|
||||
|
||||
// Increment the ref count for the inlined function, so it doesn't
|
||||
// get deleted before we can emit abstract debug info for it.
|
||||
CalleeFunction->setInlined();
|
||||
|
||||
// If the caller's BB is not the last BB in the calling function, then keep
|
||||
// track of the next BB so we always insert new BBs before it; otherwise,
|
||||
// we just leave the new BBs at the end as they are by default.
|
||||
@@ -428,20 +432,12 @@ SILInliner::getOrCreateInlineScope(const SILDebugScope *CalleeScope) {
|
||||
if (it != InlinedScopeCache.end())
|
||||
return it->second;
|
||||
|
||||
auto &M = getBuilder().getModule();
|
||||
auto &M = getBuilder().getFunction().getModule();
|
||||
auto InlinedAt =
|
||||
getOrCreateInlineScope(CalleeScope->InlinedCallSite);
|
||||
|
||||
auto *ParentFunction = CalleeScope->Parent.dyn_cast<SILFunction *>();
|
||||
if (ParentFunction)
|
||||
ParentFunction = remapParentFunction(
|
||||
M, ParentFunction, SubsMap,
|
||||
CalleeFunction->getLoweredFunctionType()->getGenericSignature(),
|
||||
ForInlining);
|
||||
|
||||
auto *ParentScope = CalleeScope->Parent.dyn_cast<const SILDebugScope *>();
|
||||
auto ParentScope = CalleeScope->Parent.dyn_cast<const SILDebugScope *>();
|
||||
auto *InlinedScope = new (M) SILDebugScope(
|
||||
CalleeScope->Loc, ParentFunction,
|
||||
CalleeScope->Loc, CalleeScope->Parent.dyn_cast<SILFunction *>(),
|
||||
ParentScope ? getOrCreateInlineScope(ParentScope) : nullptr, InlinedAt);
|
||||
InlinedScopeCache.insert({CalleeScope, InlinedScope});
|
||||
return InlinedScope;
|
||||
|
||||
@@ -74,13 +74,11 @@ std::string SpecializationMangler::finalize() {
|
||||
// Generic Specialization
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
std::string GenericSpecializationMangler::mangle(GenericSignature *Sig) {
|
||||
std::string GenericSpecializationMangler::mangle() {
|
||||
beginMangling();
|
||||
|
||||
if (!Sig) {
|
||||
SILFunctionType *FTy = Function->getLoweredFunctionType();
|
||||
Sig = FTy->getGenericSignature();
|
||||
}
|
||||
CanGenericSignature Sig = FTy->getGenericSignature();
|
||||
|
||||
bool First = true;
|
||||
for (auto ParamType : Sig->getSubstitutableParams()) {
|
||||
@@ -89,9 +87,6 @@ std::string GenericSpecializationMangler::mangle(GenericSignature *Sig) {
|
||||
}
|
||||
assert(!First && "no generic substitutions");
|
||||
|
||||
if (isInlined)
|
||||
appendSpecializationOperator("Ti");
|
||||
else
|
||||
appendSpecializationOperator(isReAbstracted ? "Tg" : "TG");
|
||||
return finalize();
|
||||
}
|
||||
|
||||
@@ -1,19 +1,10 @@
|
||||
// SIL.
|
||||
// RUN: %target-swift-frontend -parse-as-library -module-name A \
|
||||
// RUN: -Xllvm -sil-print-debuginfo %s -g -O -o - -emit-sil \
|
||||
// RUN: | %FileCheck %s --check-prefix=SIL
|
||||
// IR.
|
||||
// RUN: %target-swift-frontend -parse-as-library -module-name A \
|
||||
// RUN: -Xllvm -debug-info-inlined-generics %s -g -O -o - -emit-ir \
|
||||
// RUN: | %FileCheck %s --check-prefix=IR
|
||||
|
||||
import StdlibUnittest
|
||||
// RUN: %target-swift-frontend -parse-as-library -module-name A -Xllvm -sil-print-debuginfo %s -g -O -o - -emit-sil | %FileCheck %s --check-prefix=SIL
|
||||
|
||||
@inline(never)
|
||||
func yes() -> Bool { return true }
|
||||
|
||||
#sourceLocation(file: "use.swift", line: 1)
|
||||
@inline(never) func use<V>(_ v: V) { _blackHole(v) }
|
||||
@inline(never) func use<V>(_ v: V) {}
|
||||
|
||||
#sourceLocation(file: "h.swift", line: 1)
|
||||
@inline(__always) func h<U>(_ u: U) {
|
||||
@@ -29,14 +20,18 @@ func yes() -> Bool { return true }
|
||||
}
|
||||
|
||||
// SIL: sil_scope [[F:.*]] { {{.*}}parent @$S1A1CC1fyyqd__lF
|
||||
// SIL: sil_scope [[F1:.*]] { loc "f.swift":1:28 parent [[F]] }
|
||||
// SIL: sil_scope [[F1G:.*]] { loc "f.swift":2:5 parent [[F1]] }
|
||||
// SIL: sil_scope [[F1:.*]] { loc "f.swift":1:29 parent [[F]] }
|
||||
// SIL: sil_scope [[F1G:.*]] { loc "f.swift":5:5 parent [[F1]] }
|
||||
// SIL: sil_scope [[F1G1:.*]] { loc "g.swift":2:3 {{.*}}inlined_at [[F1G]] }
|
||||
// SIL: sil_scope [[F1G3:.*]] { loc "g.swift":3:5 {{.*}}inlined_at [[F1G]] }
|
||||
// SIL: sil_scope [[F1G3H:.*]] { loc "h.swift":1:24
|
||||
// SIL-SAME: parent @{{.*}}1h{{.*}} inlined_at [[F1G3]] }
|
||||
// SIL: sil_scope [[F1G3H1:.*]] { loc "h.swift":1:37
|
||||
// SIL-SAME: parent [[F1G3H]] inlined_at [[F1G3]] }
|
||||
// SIL: sil_scope [[F1G3H2:.*]] { loc "h.swift":3:3
|
||||
// SIL-SAME: parent [[F1G3H1]] inlined_at [[F1G3]] }
|
||||
// SIL: sil_scope [[F1G3H2_THUNK:.*]] { loc "use.swift":1:21
|
||||
// SIL-SAME: inlined_at [[F1G3H2]] }
|
||||
|
||||
#sourceLocation(file: "C.swift", line: 1)
|
||||
public class C<R> {
|
||||
@@ -44,69 +39,13 @@ public class C<R> {
|
||||
init(_ _r: R) { r = _r }
|
||||
|
||||
// SIL: // C.f<A>(_:)
|
||||
// IR: define {{.*}} @"$S1A1CC1fyyqd__lF"
|
||||
#sourceLocation(file: "f.swift", line: 1)
|
||||
public func f<S>(_ s: S) {
|
||||
public func f<S> (_ s: S) {
|
||||
// SIL: debug_value_addr %0 : $*S, let, name "s", argno 1,{{.*}} scope [[F]]
|
||||
// SIL: function_ref {{.*}}yes{{.*}} scope [[F1G1]]
|
||||
// SIL: function_ref {{.*}}use{{.*}} scope [[F1G3H1]]
|
||||
// IR: dbg.value(metadata %swift.type* %S, metadata ![[MD_1_0:[0-9]+]]
|
||||
// IR: dbg.value(metadata %swift.opaque* %0, metadata ![[S:[0-9]+]]
|
||||
// IR: dbg.value(metadata %swift.opaque* %0, metadata ![[GS_T:[0-9]+]]
|
||||
// IR: dbg.value(metadata %swift.opaque* %0, metadata ![[GS_U:[0-9]+]]
|
||||
// IR: call {{.*}}3use
|
||||
#sourceLocation(file: "f.swift", line: 2)
|
||||
// SIL: function_ref {{.*}}use{{.*}}:0:0, scope [[F1G3H2_THUNK]]
|
||||
g(s)
|
||||
// IR: dbg.value({{.*}}, metadata ![[GR_T:[0-9]+]]
|
||||
// IR: dbg.value({{.*}}, metadata ![[GR_U:[0-9]+]]
|
||||
// IR: call {{.*}}3use
|
||||
#sourceLocation(file: "f.swift", line: 3)
|
||||
g(r)
|
||||
// IR: dbg.value({{.*}}, metadata ![[GRS_T:[0-9]+]]
|
||||
// IR: dbg.value({{.*}}, metadata ![[GRS_U:[0-9]+]]
|
||||
// IR: call {{.*}}3use
|
||||
#sourceLocation(file: "f.swift", line: 4)
|
||||
g((r, s))
|
||||
// IR: dbg.value
|
||||
// IR: dbg.value({{.*}}, metadata ![[GI_T:[0-9]+]]
|
||||
// IR: dbg.value({{.*}}, metadata ![[GI_U:[0-9]+]]
|
||||
// IR: call {{.*}}3use
|
||||
#sourceLocation(file: "f.swift", line: 5)
|
||||
g(Int(0))
|
||||
// IR: dbg.value
|
||||
// IR: dbg.value({{.*}}, metadata ![[GB_T:[0-9]+]]
|
||||
// IR: dbg.value({{.*}}, metadata ![[GB_U:[0-9]+]]
|
||||
// IR: call {{.*}}3use
|
||||
#sourceLocation(file: "f.swift", line: 6)
|
||||
g(false)
|
||||
g((s, s))
|
||||
}
|
||||
}
|
||||
|
||||
// IR: ![[BOOL:[0-9]+]] = !DICompositeType({{.*}}name: "Bool"
|
||||
// IR: ![[INT:[0-9]+]] = !DICompositeType({{.*}}name: "Int"
|
||||
// IR: ![[TAU_0_0:[0-9]+]] = {{.*}}DW_TAG_structure_type, name: "$SxD",
|
||||
// IR: ![[MD_1_0]] = !DILocalVariable(name: "$\CF\84_1_0"
|
||||
// IR: ![[S]] = !DILocalVariable(name: "s", {{.*}} type: ![[TAU_1_0:[0-9]+]]
|
||||
// IR: ![[TAU_1_0]] = {{.*}}DW_TAG_structure_type, name: "$Sqd__D",
|
||||
// IR: ![[GS_T]] = !DILocalVariable(name: "t", {{.*}} scope: ![[SP_GS_T:[0-9]+]], {{.*}} type: ![[TAU_1_0]])
|
||||
// IR: ![[SP_GS_T]] = {{.*}}linkageName: "$S1A1gyyxlFqd___Ti5"
|
||||
// IR: ![[GS_U]] = !DILocalVariable(name: "u", {{.*}} scope: ![[SP_GS_U:[0-9]+]], {{.*}} type: ![[TAU_1_0]])
|
||||
// IR: ![[SP_GS_U]] = {{.*}}linkageName: "$S1A1hyyxlFqd___Ti5"
|
||||
// IR: ![[GR_T]] = !DILocalVariable(name: "t", {{.*}} scope: ![[SP_GR_T:[0-9]+]], {{.*}}type: ![[TAU_0_0]])
|
||||
// S has the same generic parameter numbering s T and U.
|
||||
// IR: ![[SP_GR_T]] = {{.*}}linkageName: "$S1A1gyyxlF"
|
||||
// IR: ![[GR_U]] = !DILocalVariable(name: "u", {{.*}} scope: ![[SP_GR_U:[0-9]+]], {{.*}}type: ![[TAU_0_0]])
|
||||
// IR: ![[SP_GR_U]] = {{.*}}linkageName: "$S1A1hyyxlF"
|
||||
// IR: ![[GRS_T]] = !DILocalVariable(name: "t", {{.*}} scope: ![[SP_GRS_T:[0-9]+]], {{.*}}type: ![[TUPLE:[0-9]+]]
|
||||
// IR: ![[SP_GRS_T]] = {{.*}}linkageName: "$S1A1gyyxlFx_qd__t_Ti5"
|
||||
// IR: ![[TUPLE]] = {{.*}}DW_TAG_structure_type, name: "$Sx_qd__tD"
|
||||
// IR: ![[GRS_U]] = !DILocalVariable(name: "u", {{.*}} scope: ![[SP_GRS_U:[0-9]+]], {{.*}}type: ![[TUPLE]]
|
||||
// IR: ![[SP_GRS_U]] = {{.*}}linkageName: "$S1A1hyyxlFx_qd__t_Ti5"
|
||||
// IR-DAG: ![[GI_T]] = !DILocalVariable(name: "t", {{.*}} scope: ![[SP_GI_G:[0-9]+]], {{.*}}type: ![[INT]])
|
||||
// IR-DAG: ![[SP_GI_G]] = {{.*}}linkageName: "$S1A1gyyxlFSi_Tg5"
|
||||
// IR-DAG: ![[GI_U]] = !DILocalVariable(name: "u", {{.*}} scope: ![[SP_GI_U:[0-9]+]], {{.*}}type: ![[INT]])
|
||||
// IR-DAG: ![[SP_GI_U]] = {{.*}}linkageName: "$S1A1hyyxlFSi_TG5"
|
||||
// IR-DAG: ![[GB_T]] = !DILocalVariable(name: "t", {{.*}} scope: ![[SP_GB_G:[0-9]+]], {{.*}}type: ![[BOOL]])
|
||||
// IR-DAG: ![[SP_GB_G]] = {{.*}}linkageName: "$S1A1gyyxlFSb_Tg5"
|
||||
// IR-DAG: ![[GB_U]] = !DILocalVariable(name: "u", {{.*}} scope: ![[SP_GB_U:[0-9]+]], {{.*}}type: ![[BOOL]])
|
||||
// IR-DAG: ![[SP_GB_U]] = {{.*}}linkageName: "$S1A1hyyxlFSb_TG5"
|
||||
|
||||
@@ -318,4 +318,3 @@ $SSiSHsWP ---> protocol witness table for Swift.Int : Swift.Hashable in Swift
|
||||
$S7TestMod5OuterV3Fooayx_SiGD ---> TestMod.Outer<A>.Foo<Swift.Int>
|
||||
$Ss17_VariantSetBufferO05CocoaC0ayx_GD ---> Swift._VariantSetBuffer<A>.CocoaBuffer
|
||||
$S2t21QP22ProtocolTypeAliasThingayAA4BlahV5SomeQa_GSgD ---> t2.Blah.SomeQ as t2.Q.ProtocolTypeAliasThing?
|
||||
A.h<A>(A) -> ()inlined generic function <(A, A1)> of
|
||||
|
||||
Reference in New Issue
Block a user