mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #8533 from adrian-prantl/28311051
This commit is contained in:
@@ -46,82 +46,28 @@ public:
|
||||
/// An optional chain of inlined call sites.
|
||||
///
|
||||
/// If this scope is inlined, this points to a special "scope" that
|
||||
/// holds only the location of the call site. The parent scope will be
|
||||
/// the scope of the inlined call site.
|
||||
///
|
||||
/// Note that compared to the inlinedAt chain in llvm::DILocation
|
||||
/// SILDebugScope represents an inline tree.
|
||||
/// holds the location of the call site.
|
||||
const SILDebugScope *InlinedCallSite;
|
||||
|
||||
SILDebugScope(SILLocation Loc, SILFunction *SILFn,
|
||||
const SILDebugScope *ParentScope = nullptr,
|
||||
const SILDebugScope *InlinedCallSite = nullptr)
|
||||
: Loc(Loc), InlinedCallSite(InlinedCallSite) {
|
||||
if (ParentScope)
|
||||
Parent = ParentScope;
|
||||
else {
|
||||
assert(SILFn && "no parent provided");
|
||||
Parent = SILFn;
|
||||
}
|
||||
}
|
||||
const SILDebugScope *InlinedCallSite = nullptr);
|
||||
|
||||
/// Create a scope for an artificial function.
|
||||
SILDebugScope(SILLocation Loc)
|
||||
: Loc(Loc), InlinedCallSite(nullptr) {}
|
||||
|
||||
/// Create an inlined version of CalleeScope.
|
||||
SILDebugScope(const SILDebugScope *CallSiteScope,
|
||||
const SILDebugScope *CalleeScope)
|
||||
: Loc(CalleeScope->Loc), Parent(CalleeScope),
|
||||
InlinedCallSite(CallSiteScope) {
|
||||
assert(CallSiteScope && CalleeScope);
|
||||
if (InlinedCallSite)
|
||||
assert(!InlinedCallSite->InlinedCallSite &&
|
||||
"a call site scope cannot have an inlined call site");
|
||||
}
|
||||
SILDebugScope(SILLocation Loc);
|
||||
|
||||
/// Return the function this scope originated from before being inlined.
|
||||
SILFunction *getInlinedFunction() const {
|
||||
if (Parent.isNull())
|
||||
return nullptr;
|
||||
SILFunction *getInlinedFunction() const;
|
||||
|
||||
const SILDebugScope *Scope = this;
|
||||
while (Scope->Parent.is<const SILDebugScope *>())
|
||||
Scope = Scope->Parent.get<const SILDebugScope *>();
|
||||
assert(Scope->Parent.is<SILFunction *>() && "orphaned scope");
|
||||
return Scope->Parent.get<SILFunction *>();
|
||||
}
|
||||
|
||||
/// Return this scope without inline information.
|
||||
const SILDebugScope *getInlinedScope() const {
|
||||
return InlinedCallSite ? Parent.get<const SILDebugScope*>() : this;
|
||||
}
|
||||
|
||||
/// Return the parent function of this scope. If the scope was
|
||||
/// inlined this recursively returns the function it was inlined
|
||||
/// into.
|
||||
SILFunction *getParentFunction() const {
|
||||
if (InlinedCallSite)
|
||||
return InlinedCallSite->Parent.get<const SILDebugScope *>()
|
||||
->getParentFunction();
|
||||
if (auto *ParentScope = Parent.dyn_cast<const SILDebugScope *>())
|
||||
return ParentScope->getParentFunction();
|
||||
return Parent.get<SILFunction *>();
|
||||
}
|
||||
|
||||
typedef SmallVector<const SILDebugScope *, 8> InlineScopeList;
|
||||
static void flatten(const SILDebugScope *DS, InlineScopeList &List);
|
||||
|
||||
// Return a flattened representation of the inline scope tree that
|
||||
// is equivalent to the reversed inlined-at chain.
|
||||
InlineScopeList flattenedInlineTree() const {
|
||||
InlineScopeList List;
|
||||
flatten(this, List);
|
||||
return List;
|
||||
}
|
||||
SILFunction *getParentFunction() const;
|
||||
|
||||
#ifndef NDEBUG
|
||||
void dump(SourceManager &SM, llvm::raw_ostream &OS = llvm::errs(),
|
||||
unsigned Indent = 0) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
@@ -410,9 +410,12 @@ public:
|
||||
SourceLoc getSourceLoc() const;
|
||||
SourceLoc getStartSourceLoc() const;
|
||||
SourceLoc getEndSourceLoc() const;
|
||||
|
||||
SourceRange getSourceRange() const {
|
||||
return { getStartSourceLoc(), getEndSourceLoc() };
|
||||
return {getStartSourceLoc(), getEndSourceLoc()};
|
||||
}
|
||||
DebugLoc getDebugInfoLoc() const {
|
||||
assert(isDebugInfoLoc());
|
||||
return Loc.DebugInfoLoc;
|
||||
}
|
||||
|
||||
/// Fingerprint a DebugLoc for use in a DenseMap.
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
CloneCollector::CallbackType Callback = nullptr)
|
||||
: TypeSubstCloner<SILInliner>(To, From, ApplySubs,
|
||||
OpenedArchetypesTracker, true),
|
||||
IKind(IKind), CalleeEntryBB(nullptr), CallSiteScope(nullptr),
|
||||
IKind(IKind), CalleeEntryBB(nullptr),
|
||||
Callback(Callback) {
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ private:
|
||||
/// Alternatively, it can be the SIL file location of the call site (in case
|
||||
/// of SIL-to-SIL transformations).
|
||||
Optional<SILLocation> Loc;
|
||||
const SILDebugScope *CallSiteScope;
|
||||
const SILDebugScope *CallSiteScope = nullptr;
|
||||
SILFunction *CalleeFunction;
|
||||
llvm::SmallDenseMap<const SILDebugScope *,
|
||||
const SILDebugScope *> InlinedScopeCache;
|
||||
|
||||
Reference in New Issue
Block a user