Skip to content

[DebugInfo] [SILGen] Remove all invalid debug info from intermediates #73995

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 1 commit into from
May 30, 2024
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
25 changes: 13 additions & 12 deletions lib/SILGen/SILGenProlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1540,18 +1540,19 @@ uint16_t SILGenFunction::emitBasicProlog(
B.createDebugValue(loc, undef.getValue(), dbgVar);
}

for (auto &i : *B.getInsertionBB()) {
auto *alloc = dyn_cast<AllocStackInst>(&i);
if (!alloc)
continue;
auto varInfo = alloc->getVarInfo();
if (!varInfo || varInfo->ArgNo)
continue;
// The allocation has a varinfo but no argument number, which should not
// happen in the prolog. Unfortunately, some copies can generate wrong
// debug info, so we have to fix it here, by invalidating it.
alloc->invalidateVarInfo();
}
for (auto &bb : B.getFunction())
for (auto &i : bb) {
auto *alloc = dyn_cast<AllocStackInst>(&i);
if (!alloc)
continue;
auto varInfo = alloc->getVarInfo();
if (!varInfo || varInfo->ArgNo)
continue;
// The allocation has a varinfo but no argument number, which should not
// happen in the prolog. Unfortunately, some copies can generate wrong
// debug info, so we have to fix it here, by invalidating it.
alloc->invalidateVarInfo();
}

return ArgNo;
}
11 changes: 11 additions & 0 deletions test/DebugInfo/parameter-pack.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %target-swift-frontend -emit-silgen %s | %FileCheck %s

// https://github.com/apple/swift/issues/73030

// CHECK-LABEL: sil {{.+}} @$s4main1f1t1cxxQp_q_t_q0_txxQp_t_q_t_q0_tRvzr1_lF
func f<each A, B, C>(t: ((repeat each A), B), c: C) -> ((repeat each A, B), C) {
// CHECK-NOT: let, name "t"
// CHECK: alloc_stack [lexical] [var_decl] $((repeat each A), B), let, name "t", argno 1
// CHECK: debug_value %{{[0-9]+}} : $*C, let, name "c", argno 2, expr op_deref
((repeat each t.0, t.1), c)
}