Skip to content

Commit 8964108

Browse files
authored
Merge pull request swiftlang#13919 from dcci/hotfix
[DefiniteInit] Correctly set the debug scope when creating a `store`.
2 parents a67ba32 + 1a153d4 commit 8964108

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2191,7 +2191,9 @@ SILValue LifetimeChecker::handleConditionalInitAssign() {
21912191
}
21922192

21932193
// Before the memory allocation, store zero in the control variable.
2194-
B.setInsertionPoint(&*std::next(TheMemory.MemoryInst->getIterator()));
2194+
auto *InsertPoint = &*std::next(TheMemory.MemoryInst->getIterator());
2195+
B.setInsertionPoint(InsertPoint);
2196+
B.setCurrentDebugScope(InsertPoint->getDebugScope());
21952197
SILValue ControlVariableAddr = ControlVariableBox;
21962198
auto Zero = B.createIntegerLiteral(Loc, IVType, 0);
21972199
B.createStore(Loc, Zero, ControlVariableAddr,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %target-swift-frontend -emit-sil %s -Onone -Xllvm -sil-print-debuginfo \
2+
// RUN: -o /dev/null -Xllvm -sil-print-after=definite-init \
3+
// RUN: -Xllvm -sil-print-only-functions=$S8patatino4BearC6before7before26during5afterACSb_S3btKcfc \
4+
// RUN: 2>&1 | %FileCheck %s
5+
// REQUIRES: executable_test
6+
7+
import StdlibUnittest
8+
9+
func unwrap(_ b: Bool) throws -> Int {
10+
return 0
11+
}
12+
class Bear {
13+
let x: LifetimeTracked
14+
init(n: Int, before: Bool) throws {
15+
self.x = LifetimeTracked(0)
16+
}
17+
init(n: Int, after: Bool) throws {
18+
self.x = LifetimeTracked(0)
19+
}
20+
convenience init(before: Bool, before2: Bool, during: Bool, after: Bool) throws {
21+
try self.init(n: unwrap(before2), after: during)
22+
}
23+
}
24+
25+
// CHECK: %7 = integer_literal $Builtin.Int1, 0, loc {{.*}}:20:15, scope 1
26+
// CHECK-NEXT: store %7 to [trivial] %5 : $*Builtin.Int1, loc {{.*}}:20:15, scope 1

0 commit comments

Comments
 (0)