Skip to content

Commit 0cff76e

Browse files
committed
[DebugInfo] [SILGen] Remove invalid debug info from intermediates in prolog
1 parent 2ebae40 commit 0cff76e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/SILGen/SILGenProlog.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ void SILGenFunction::emitProlog(
12971297

12981298
emitExpectedExecutor();
12991299

1300-
// IMPORTANT: This block should be the last one in `emitProlog`,
1300+
// IMPORTANT: This block should be the last one in `emitProlog`,
13011301
// since it terminates BB and no instructions should be insterted after it.
13021302
// Emit an unreachable instruction if a parameter type is
13031303
// uninhabited
@@ -1506,5 +1506,18 @@ uint16_t SILGenFunction::emitBasicProlog(
15061506
B.createDebugValue(loc, undef.getValue(), dbgVar);
15071507
}
15081508

1509+
for (auto &i : *B.getInsertionBB()) {
1510+
auto *alloc = dyn_cast<AllocStackInst>(&i);
1511+
if (!alloc)
1512+
continue;
1513+
auto varInfo = alloc->getVarInfo();
1514+
if (!varInfo || varInfo->ArgNo)
1515+
continue;
1516+
// The allocation has a varinfo but no argument number, which should not
1517+
// happen in the prolog. Unfortunately, some copies can generate wrong
1518+
// debug info, so we have to fix it here, by invalidating it.
1519+
alloc->invalidateVarInfo();
1520+
}
1521+
15091522
return ArgNo;
15101523
}

test/SILOptimizer/init_accessors.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ struct TestGenericTuple<T, U> {
330330
//
331331
// CHECK: bb0([[A_REF:%.*]] : $*T, [[B_REF:%.*]] : $*(T, U), [[A_VALUE:%.*]] : $*T, [[B_VALUE:%.*]] : $*T, [[C_VALUE:%.*]] : $*U, [[METATYPE:%.*]] : $@thin TestGenericTuple<T, U>.Type):
332332
//
333-
// CHECK: [[INIT_VALUE_1:%.*]] = alloc_stack $(T, U), let, name "initialValue"
333+
// CHECK: [[INIT_VALUE_1:%.*]] = alloc_stack $(T, U)
334334
// CHECK-NEXT: [[INIT_VALUE_1_0:%.*]] = tuple_element_addr [[INIT_VALUE_1]] : $*(T, U), 0
335335
// CHECK-NEXT: copy_addr [take] [[B_VALUE]] to [init] [[INIT_VALUE_1_0]]
336336
// CHECK-NEXT: [[INIT_VALUE_1_1:%.*]] = tuple_element_addr [[INIT_VALUE_1]] : $*(T, U), 1

0 commit comments

Comments
 (0)