Skip to content

Commit 83b44be

Browse files
committed
Out-line the definition of ScopeCloner::getOrCreateClonedScope(). NFC
1 parent 3390a58 commit 83b44be

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

include/swift/SIL/SILDebugScope.h

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -91,28 +91,7 @@ class ScopeCloner {
9191
}
9292

9393
/// Return a (cached) deep copy of a scope.
94-
const SILDebugScope *getOrCreateClonedScope(const SILDebugScope *OrigScope) {
95-
if (!OrigScope)
96-
return nullptr;
97-
98-
auto it = ClonedScopeCache.find(OrigScope);
99-
if (it != ClonedScopeCache.end())
100-
return it->second;
101-
102-
auto ClonedScope = new (NewFn.getModule()) SILDebugScope(*OrigScope);
103-
if (OrigScope->InlinedCallSite) {
104-
// For inlined functions, we need to rewrite the inlined call site.
105-
ClonedScope->InlinedCallSite =
106-
getOrCreateClonedScope(OrigScope->InlinedCallSite);
107-
} else {
108-
ClonedScope->SILFn = &NewFn;
109-
ClonedScope->Parent = getOrCreateClonedScope(OrigScope->Parent);
110-
}
111-
// Create an inline scope for the cloned instruction.
112-
assert(ClonedScopeCache.find(OrigScope) == ClonedScopeCache.end());
113-
ClonedScopeCache.insert({OrigScope, ClonedScope});
114-
return ClonedScope;
115-
}
94+
const SILDebugScope *getOrCreateClonedScope(const SILDebugScope *OrigScope);
11695
};
11796

11897
/// A SILLocation together with a SILDebugScope.

lib/SIL/SILBasicBlock.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,30 @@ transferNodesFromList(llvm::ilist_traits<SILBasicBlock> &SrcTraits,
161161
}
162162
}
163163

164+
const SILDebugScope *
165+
ScopeCloner::getOrCreateClonedScope(const SILDebugScope *OrigScope) {
166+
if (!OrigScope)
167+
return nullptr;
168+
169+
auto it = ClonedScopeCache.find(OrigScope);
170+
if (it != ClonedScopeCache.end())
171+
return it->second;
172+
173+
auto ClonedScope = new (NewFn.getModule()) SILDebugScope(*OrigScope);
174+
if (OrigScope->InlinedCallSite) {
175+
// For inlined functions, we need to rewrite the inlined call site.
176+
ClonedScope->InlinedCallSite =
177+
getOrCreateClonedScope(OrigScope->InlinedCallSite);
178+
} else {
179+
ClonedScope->SILFn = &NewFn;
180+
ClonedScope->Parent = getOrCreateClonedScope(OrigScope->Parent);
181+
}
182+
// Create an inline scope for the cloned instruction.
183+
assert(ClonedScopeCache.find(OrigScope) == ClonedScopeCache.end());
184+
ClonedScopeCache.insert({OrigScope, ClonedScope});
185+
return ClonedScope;
186+
}
187+
164188
bool SILBasicBlock::isEntry() const {
165189
return this == &*getParent()->begin();
166190
}

0 commit comments

Comments
 (0)