Skip to content

Commit

Permalink
Merge pull request swiftlang#73995 from Snowy1803/rdar126556557
Browse files Browse the repository at this point in the history
[DebugInfo] [SILGen] Remove all invalid debug info from intermediates
  • Loading branch information
Snowy1803 authored May 30, 2024
2 parents 531469f + a530534 commit 11a5359
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
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.emitDebugDescription(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)
}

0 comments on commit 11a5359

Please sign in to comment.