Skip to content

Fix the missing inlined-at field of function-level SILDebugScopes. #17569

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 3 commits into from
Jun 27, 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
2 changes: 1 addition & 1 deletion lib/SIL/SILDebugScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
using namespace swift;

SILDebugScope::SILDebugScope(SILLocation Loc, SILFunction *SILFn,
const SILDebugScope *ParentScope ,
const SILDebugScope *ParentScope,
const SILDebugScope *InlinedCallSite)
: Loc(Loc), InlinedCallSite(InlinedCallSite) {
if (ParentScope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ void FunctionSignatureTransform::createFunctionSignatureOptimizedFunction() {
ThunkBody->createFunctionArgument(ArgDesc.Arg->getType(), ArgDesc.Decl);
}

SILLocation Loc = ThunkBody->getParent()->getLocation();
SILLocation Loc = RegularLocation::getAutoGeneratedLocation();
SILBuilder Builder(ThunkBody);
Builder.setCurrentDebugScope(ThunkBody->getParent()->getDebugScope());

Expand Down
3 changes: 2 additions & 1 deletion lib/SILOptimizer/Utils/SILInliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,10 @@ SILInliner::getOrCreateInlineScope(const SILDebugScope *CalleeScope) {
auto &M = getBuilder().getFunction().getModule();
auto InlinedAt =
getOrCreateInlineScope(CalleeScope->InlinedCallSite);
auto ParentScope = CalleeScope->Parent.dyn_cast<const SILDebugScope *>();
auto *InlinedScope = new (M) SILDebugScope(
CalleeScope->Loc, CalleeScope->Parent.dyn_cast<SILFunction *>(),
CalleeScope->Parent.dyn_cast<const SILDebugScope *>(), InlinedAt);
ParentScope ? getOrCreateInlineScope(ParentScope) : nullptr, InlinedAt);
InlinedScopeCache.insert({CalleeScope, InlinedScope});
return InlinedScope;
}
Expand Down
31 changes: 20 additions & 11 deletions test/DebugInfo/inlined-generics-basic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,35 @@
@inline(never)
func yes() -> Bool { return true }

@inline(never)
func use<V>(_ v: V) {}
#sourceLocation(file: "use.swift", line: 1)
@inline(never) func use<V>(_ v: V) {}

@inline(__always)
func h<U>(_ u: U) {
#sourceLocation(file: "h.swift", line: 1)
@inline(__always) func h<U>(_ u: U) {
yes()
use(u)
}

#sourceLocation(file: "g.swift", line: 1)
@inline(__always) func g<T>(_ t: T) {
if (yes()) {
use(t)
h(t)
}
}

// SIL: sil_scope [[F:.*]] { {{.*}}parent @$S1A1CC1fyyqd__lF
// SIL: sil_scope [[F0:.*]] { loc "f.swift":1:29 parent [[F]] }
// SIL: sil_scope [[F_G_S:.*]] { loc "f.swift":5:5 parent [[F0]] }
// SIL: sil_scope [[G_S:.*]] { loc "g.swift":2:3 {{.*}} inlined_at [[F_G_S]] }
// 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> {
Expand All @@ -32,9 +41,9 @@ public class C<R> {
// SIL: // C.f<A>(_:)
#sourceLocation(file: "f.swift", line: 1)
public func f<S> (_ s: S) {
// SIL: debug_value_addr %0 : $*S, let, name "s", argno 1,
// SIL-SAME: scope [[F]]
// SIL: function_ref {{.*}}yes{{.*}} scope [[G_S]]
// SIL: debug_value_addr %0 : $*S, let, name "s", argno 1,{{.*}} scope [[F]]
// SIL: function_ref {{.*}}yes{{.*}} scope [[F1G1]]
// SIL: function_ref {{.*}}use{{.*}}:0:0, scope [[F1G3H2_THUNK]]
g(s)
g(r)
g((s, s))
Expand Down