Skip to content

Commit 210e135

Browse files
authored
Merge pull request #41515 from gottesmm/pr-2d2da2179be796c2147236db824f24b137037bdb
[move-function] Break blocks right after the non-undef debug info associated with move only values.
2 parents ea35055 + 0666cc9 commit 210e135

File tree

7 files changed

+506
-183
lines changed

7 files changed

+506
-183
lines changed

include/swift/SILOptimizer/Utils/CFGOptUtils.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,22 @@ SILBasicBlock *splitBasicBlockAndBranch(SILBuilder &builder,
144144
DominanceInfo *domInfo,
145145
SILLoopInfo *loopInfo);
146146

147+
/// A version of splitBasicBlockAndBranch that takes a SILBuilderContext instead
148+
/// of a SILBuilder. We generally are trying to eliminate APIs that take in
149+
/// SILBuilder directly since that can cause weird downstream mistakes around
150+
/// debug info scopes. So this provides a better choice for engineers.
151+
///
152+
/// TODO: Migrate all callers of splitBasicBlockAndBranch to use this entry
153+
/// point.
154+
inline SILBasicBlock *splitBasicBlockAndBranch(SILBuilderContext &builderCtx,
155+
SILInstruction *splitBeforeInst,
156+
DominanceInfo *domInfo,
157+
SILLoopInfo *loopInfo) {
158+
// Make sure we have the right debug scope from split before inst.
159+
SILBuilderWithScope builder(splitBeforeInst, builderCtx);
160+
return splitBasicBlockAndBranch(builder, splitBeforeInst, domInfo, loopInfo);
161+
}
162+
147163
/// Return true if the function has a critical edge, false otherwise.
148164
bool hasCriticalEdges(SILFunction &f, bool onlyNonCondBr);
149165

lib/SILOptimizer/Mandatory/MoveKillsCopyableAddressesChecker.cpp

Lines changed: 254 additions & 174 deletions
Large diffs are not rendered by default.

lib/SILOptimizer/Mandatory/MoveKillsCopyableValuesChecker.cpp

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@
2424
#include "swift/SIL/SILFunction.h"
2525
#include "swift/SIL/SILInstruction.h"
2626
#include "swift/SIL/SILUndef.h"
27+
#include "swift/SILOptimizer/Analysis/Analysis.h"
2728
#include "swift/SILOptimizer/Analysis/ClosureScope.h"
29+
#include "swift/SILOptimizer/Analysis/DominanceAnalysis.h"
30+
#include "swift/SILOptimizer/Analysis/LoopAnalysis.h"
2831
#include "swift/SILOptimizer/PassManager/Transforms.h"
32+
#include "swift/SILOptimizer/Utils/CFGOptUtils.h"
2933
#include "swift/SILOptimizer/Utils/CanonicalOSSALifetime.h"
3034

3135
using namespace swift;
@@ -192,8 +196,19 @@ namespace {
192196
struct MoveKillsCopyableValuesChecker {
193197
SILFunction *fn;
194198
CheckerLivenessInfo livenessInfo;
199+
DominanceInfo *dominanceToUpdate;
200+
SILLoopInfo *loopInfoToUpdate;
201+
202+
MoveKillsCopyableValuesChecker(SILFunction *fn)
203+
: fn(fn), livenessInfo(), dominanceToUpdate(nullptr),
204+
loopInfoToUpdate(nullptr) {}
205+
206+
void setDominanceToUpdate(DominanceInfo *newDFI) {
207+
dominanceToUpdate = newDFI;
208+
}
209+
210+
void setLoopInfoToUpdate(SILLoopInfo *newLFI) { loopInfoToUpdate = newLFI; }
195211

196-
MoveKillsCopyableValuesChecker(SILFunction *fn) : fn(fn) {}
197212
bool check();
198213

199214
void emitDiagnosticForMove(SILValue borrowedValue,
@@ -357,6 +372,16 @@ bool MoveKillsCopyableValuesChecker::check() {
357372
auto valuesToProcess =
358373
llvm::makeArrayRef(valuesToCheck.begin(), valuesToCheck.end());
359374
auto &mod = fn->getModule();
375+
376+
// If we do not emit any diagnostics, we need to put in a break after each dbg
377+
// info carrying inst for a lexical value that we find a move on. This ensures
378+
// that we avoid a behavior today in SelectionDAG that causes dbg info addr to
379+
// be always sunk to the end of a block.
380+
//
381+
// TODO: We should add llvm.dbg.addr support for fastisel and also teach
382+
// CodeGen how to handle llvm.dbg.addr better.
383+
SmallVector<SILInstruction *, 8> successMovesDbgInfoCarryingInsts;
384+
bool emittedDiagnostic = false;
360385
while (!valuesToProcess.empty()) {
361386
auto lexicalValue = valuesToProcess.front();
362387
valuesToProcess = valuesToProcess.drop_front(1);
@@ -392,9 +417,11 @@ bool MoveKillsCopyableValuesChecker::check() {
392417
if (livenessInfo.liveness.isWithinBoundary(mvi)) {
393418
LLVM_DEBUG(llvm::dbgs() << " WithinBoundary: Yes!\n");
394419
emitDiagnosticForMove(lexicalValue, varName, mvi);
420+
emittedDiagnostic = true;
395421
} else {
396422
LLVM_DEBUG(llvm::dbgs() << " WithinBoundary: No!\n");
397423
if (auto varInfo = dbgVarInfo.getVarInfo()) {
424+
successMovesDbgInfoCarryingInsts.push_back(*dbgVarInfo);
398425
auto *next = mvi->getNextInstruction();
399426
SILBuilderWithScope builder(next);
400427
// Use an autogenerated location to ensure that if we are next to a
@@ -416,6 +443,24 @@ bool MoveKillsCopyableValuesChecker::check() {
416443
}
417444
}
418445

446+
// If we emitted any diagnostics, we are going to fail and thus don't need to
447+
// use any compile time to break blocks since a user will never debug such
448+
// programs.
449+
if (emittedDiagnostic)
450+
return false;
451+
452+
// Ok! Now break before the instruction after our debug info generating inst
453+
// so that the SelectionDAG behavior mentioned above on the declaration of
454+
// successMovesDbgInfoCarryingInst.
455+
if (!successMovesDbgInfoCarryingInsts.empty()) {
456+
SILBuilderContext ctx(mod);
457+
do {
458+
auto *next = successMovesDbgInfoCarryingInsts.pop_back_val();
459+
splitBasicBlockAndBranch(ctx, next->getNextInstruction(),
460+
dominanceToUpdate, loopInfoToUpdate);
461+
} while (!successMovesDbgInfoCarryingInsts.empty());
462+
}
463+
419464
return false;
420465
}
421466

@@ -450,8 +495,20 @@ class MoveKillsCopyableValuesCheckerPass : public SILFunctionTransform {
450495

451496
MoveKillsCopyableValuesChecker checker(getFunction());
452497

453-
if (MoveKillsCopyableValuesChecker(getFunction()).check()) {
454-
invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions);
498+
// If we already had dominance or loop info generated, update them when
499+
// splitting blocks.
500+
auto *dominanceAnalysis = getAnalysis<DominanceAnalysis>();
501+
if (dominanceAnalysis->hasFunctionInfo(fn))
502+
checker.setDominanceToUpdate(dominanceAnalysis->get(fn));
503+
auto *loopAnalysis = getAnalysis<SILLoopAnalysis>();
504+
if (loopAnalysis->hasFunctionInfo(fn))
505+
checker.setLoopInfoToUpdate(loopAnalysis->get(fn));
506+
507+
if (checker.check()) {
508+
AnalysisPreserver preserveDominance(dominanceAnalysis);
509+
AnalysisPreserver preserveLoop(loopAnalysis);
510+
invalidateAnalysis(
511+
SILAnalysis::InvalidationKind::BranchesAndInstructions);
455512
}
456513

457514
// Now search through our function one last time and any move_value

test/DebugInfo/move_function_dbginfo.swift

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public protocol P {
2929
func doSomething()
3030
}
3131

32+
public var trueValue: Bool { true }
33+
public var falseValue: Bool { false }
34+
3235
///////////
3336
// Tests //
3437
///////////
@@ -40,12 +43,14 @@ public protocol P {
4043
//
4144
// We should have a llvm.dbg.addr for k since we moved it.
4245
// CHECK: call void @llvm.dbg.addr(metadata {{.*}}** %k.debug, metadata ![[K_COPYABLE_VALUE_METADATA:[0-9]*]], metadata !DIExpression()), !dbg ![[ADDR_LOC:[0-9]*]]
46+
// CHECK-NEXT: br
4347
//
4448
// Our undef should be an llvm.dbg.value. Counter-intuitively this works for
4549
// both llvm.dbg.addr /and/ llvm.dbg.value. Importantly though its metadata
4650
// should be for k since that is the variable that we are telling the debugger
4751
// is no longer defined.
4852
// CHECK: call void @llvm.dbg.value(metadata %T21move_function_dbginfo5KlassC* undef, metadata ![[K_COPYABLE_VALUE_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]]
53+
// CHECK-NOT: br label
4954
//
5055
// CHECK: ret void
5156
// CHECK-NEXT: }
@@ -83,9 +88,11 @@ public func copyableValueTest() {
8388
// CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo15copyableVarTestyyF"()
8489
// CHECK: call void @llvm.dbg.declare(metadata %T21move_function_dbginfo5KlassC** %m.debug,
8590
// CHECK: call void @llvm.dbg.addr(metadata %T21move_function_dbginfo5KlassC** %k, metadata ![[K_COPYABLE_VAR_METADATA:[0-9]+]], metadata !DIExpression()), !dbg ![[ADDR_LOC:[0-9]*]]
91+
// CHECK-NEXT: br
8692
// CHECK: call void @llvm.dbg.value(metadata %T21move_function_dbginfo5KlassC** undef, metadata ![[K_COPYABLE_VAR_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]]
8793
// TODO: Should this be a deref like the original?
8894
// CHECK: call void @llvm.dbg.addr(metadata %T21move_function_dbginfo5KlassC** %k, metadata ![[K_COPYABLE_VAR_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]]
95+
// CHECK-NEXT: br
8996
// CHECK: ret void
9097
// CHECK-NEXT: }
9198
//
@@ -127,6 +134,7 @@ public func copyableVarTest() {
127134
// CHECK: @llvm.dbg.declare(metadata %swift.opaque** %x.debug,
128135
// CHECK: @llvm.dbg.declare(metadata i8** %m.debug,
129136
// CHECK: @llvm.dbg.addr(metadata i8** %k.debug, metadata ![[K_ADDR_LET_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]]
137+
// CHECK-NEXT: br
130138
// CHECK: @llvm.dbg.value(metadata %swift.opaque* undef, metadata ![[K_ADDR_LET_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]]
131139
// CHECK: ret void
132140
// CHECK-NEXT: }
@@ -177,8 +185,10 @@ public func addressOnlyValueTest<T : P>(_ x: T) {
177185
// CHECK: @llvm.dbg.declare(metadata %swift.opaque** %x.debug,
178186
// CHECK: @llvm.dbg.declare(metadata i8** %m.debug,
179187
// CHECK: @llvm.dbg.addr(metadata i8** %k.debug, metadata ![[K_ADDRONLY_VAR_METADATA:[0-9]+]], metadata !DIExpression(DW_OP_deref)), !dbg ![[ADDR_LOC:[0-9]*]]
188+
// CHECK-NEXT: br
180189
// CHECK: @llvm.dbg.value(metadata %swift.opaque* undef, metadata ![[K_ADDRONLY_VAR_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]]
181190
// CHECK: @llvm.dbg.addr(metadata i8** %k.debug, metadata ![[K_ADDRONLY_VAR_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]]
191+
// CHECK-NEXT: br
182192
// CHECK: ret void
183193
// CHECK-NEXT: }
184194
//
@@ -226,6 +236,143 @@ public func addressOnlyVarTest<T : P>(_ x: T) {
226236
k.doSomething()
227237
}
228238

239+
///////////////////////
240+
// Conditional Tests //
241+
///////////////////////
242+
243+
// CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo037copyableVarTestCCFlowReinitOutOfBlockF0yyF"(
244+
// CHECK: call void @llvm.dbg.declare(metadata %T21move_function_dbginfo5KlassC** %m.debug,
245+
// CHECK: call void @llvm.dbg.addr(metadata %T21move_function_dbginfo5KlassC** %k, metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA:[0-9]+]], metadata !DIExpression()), !dbg ![[ADDR_LOC:[0-9]*]]
246+
// CHECK-NEXT: br label %[[BB_NEXT:[0-9]+]],
247+
//
248+
// CHECK: [[BB_NEXT]]:
249+
// CHECK: br i1 %{{[0-9]+}}, label %[[LHS:[0-9]+]], label %[[RHS:[0-9]+]],
250+
//
251+
// CHECK: [[LHS]]:
252+
// CHECK: call void @llvm.dbg.value(metadata %T21move_function_dbginfo5KlassC** undef, metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]]
253+
// CHECK: br label %[[CONT_BB:[0-9]+]],
254+
//
255+
// CHECK: [[RHS]]:
256+
// CHECK: br label %[[CONT_BB]],
257+
//
258+
// CHECK: [[CONT_BB]]:
259+
// TODO: Should this be a deref like the original?
260+
// CHECK: call void @llvm.dbg.addr(metadata %T21move_function_dbginfo5KlassC** %k, metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]]
261+
// CHECK-NEXT: br
262+
// CHECK: ret void
263+
// CHECK-NEXT: }
264+
public func copyableVarTestCCFlowReinitOutOfBlockTest() {
265+
var k = Klass()
266+
k.doSomething()
267+
if trueValue {
268+
let m = _move(k)
269+
m.doSomething()
270+
}
271+
k = Klass()
272+
k.doSomething()
273+
}
274+
275+
// CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo034copyableVarTestCCFlowReinitInBlockF0yyF"(
276+
// CHECK: entry:
277+
// CHECK: call void @llvm.dbg.declare(metadata %T21move_function_dbginfo5KlassC** %m.debug,
278+
// CHECK: call void @llvm.dbg.addr(metadata %T21move_function_dbginfo5KlassC** %k, metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA:[0-9]+]], metadata !DIExpression()), !dbg ![[ADDR_LOC:[0-9]*]]
279+
// CHECK-NEXT: br label %[[BB_NEXT:[0-9]+]],
280+
//
281+
// CHECK: [[BB_NEXT]]:
282+
// CHECK: br i1 %{{[0-9]+}}, label %[[LHS:[0-9]+]], label %[[RHS:[0-9]+]],
283+
//
284+
// CHECK: [[LHS]]:
285+
// CHECK: call void @llvm.dbg.value(metadata %T21move_function_dbginfo5KlassC** undef, metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]]
286+
// TODO: Should this be a deref like the original?
287+
// CHECK: call void @llvm.dbg.addr(metadata %T21move_function_dbginfo5KlassC** %k, metadata ![[K_COPYABLE_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]]
288+
// CHECK-NEXT: br label %[[BB_NEXT_2:[0-9]+]],
289+
//
290+
// CHECK: [[BB_NEXT_2]]:
291+
// CHECK: br label %[[CONT_BB:[0-9]+]],
292+
//
293+
// CHECK: [[RHS]]:
294+
// CHECK: br label %[[CONT_BB]],
295+
//
296+
// CHECK: [[CONT_BB]]:
297+
// CHECK: ret void
298+
// CHECK-NEXT: }
299+
public func copyableVarTestCCFlowReinitInBlockTest() {
300+
var k = Klass()
301+
k.doSomething()
302+
if trueValue {
303+
let m = _move(k)
304+
m.doSomething()
305+
k = Klass()
306+
}
307+
k.doSomething()
308+
}
309+
310+
// CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo040addressOnlyVarTestCCFlowReinitOutOfBlockG0yyxmAA1PRzlF"(
311+
// CHECK: entry:
312+
// CHECK: call void @llvm.dbg.addr(metadata %T21move_function_dbginfo1PP* %k, metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA:[0-9]+]], metadata !DIExpression()), !dbg ![[ADDR_LOC:[0-9]*]]
313+
// CHECK-NEXT: br label %[[BB_NEXT:[0-9]+]],
314+
//
315+
// CHECK: [[BB_NEXT]]:
316+
// CHECK: br i1 %{{[0-9]+}}, label %[[LHS:[0-9]+]], label %[[RHS:[0-9]+]],
317+
//
318+
// CHECK: [[LHS]]:
319+
// CHECK: call void @llvm.dbg.value(metadata %T21move_function_dbginfo1PP* undef, metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]]
320+
// CHECK: br label %[[CONT_BB:[0-9]+]],
321+
//
322+
// CHECK: [[RHS]]:
323+
// CHECK: br label %[[CONT_BB]],
324+
//
325+
// CHECK: [[CONT_BB]]:
326+
// TODO: Should this be a deref like the original?
327+
// CHECK: call void @llvm.dbg.addr(metadata %T21move_function_dbginfo1PP* %k, metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]]
328+
// CHECK-NEXT: br
329+
// CHECK: ret void
330+
// CHECK-NEXT: }
331+
public func addressOnlyVarTestCCFlowReinitOutOfBlockTest<T : P>(_ x: T.Type) {
332+
var k = T.value
333+
k.doSomething()
334+
if trueValue {
335+
let m = _move(k)
336+
m.doSomething()
337+
}
338+
k = T.value
339+
k.doSomething()
340+
}
341+
342+
// CHECK-LABEL: define swiftcc void @"$s21move_function_dbginfo037addressOnlyVarTestCCFlowReinitInBlockG0yyxmAA1PRzlF"(
343+
// CHECK: entry:
344+
// CHECK: call void @llvm.dbg.addr(metadata %T21move_function_dbginfo1PP* %k, metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA:[0-9]+]], metadata !DIExpression()), !dbg ![[ADDR_LOC:[0-9]*]]
345+
// CHECK-NEXT: br label %[[BB_NEXT:[0-9]+]],
346+
//
347+
// CHECK: [[BB_NEXT]]:
348+
// CHECK: br i1 %{{[0-9]+}}, label %[[LHS:[0-9]+]], label %[[RHS:[0-9]+]],
349+
//
350+
// CHECK: [[LHS]]:
351+
// CHECK: call void @llvm.dbg.value(metadata %T21move_function_dbginfo1PP* undef, metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]]
352+
// TODO: Should this be a deref like the original?
353+
// CHECK: call void @llvm.dbg.addr(metadata %T21move_function_dbginfo1PP* %k, metadata ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]], metadata !DIExpression()), !dbg ![[ADDR_LOC]]
354+
// CHECK-NEXT: br label %[[BB_NEXT_2:[0-9]+]],
355+
//
356+
// CHECK: [[BB_NEXT_2]]:
357+
// CHECK: br label %[[CONT_BB:[0-9]+]],
358+
//
359+
// CHECK: [[RHS]]:
360+
// CHECK: br label %[[CONT_BB]],
361+
//
362+
// CHECK: [[CONT_BB]]:
363+
// CHECK: ret void
364+
// CHECK-NEXT: }
365+
public func addressOnlyVarTestCCFlowReinitInBlockTest<T : P>(_ x: T.Type) {
366+
var k = T.value
367+
k.doSomething()
368+
if trueValue {
369+
let m = _move(k)
370+
m.doSomething()
371+
k = T.value
372+
}
373+
k.doSomething()
374+
}
375+
229376
//////////////////////////
230377
// Late Metadata Checks //
231378
//////////////////////////
@@ -234,3 +381,7 @@ public func addressOnlyVarTest<T : P>(_ x: T) {
234381
// CHECK-DAG: ![[K_COPYABLE_VAR_METADATA]] = !DILocalVariable(name: "k",
235382
// CHECK-DAG: ![[K_ADDR_LET_METADATA]] = !DILocalVariable(name: "k",
236383
// CHECK-DAG: ![[K_ADDRONLY_VAR_METADATA]] = !DILocalVariable(name: "k",
384+
// CHECK-DAG: ![[K_COPYABLE_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]] = !DILocalVariable(name: "k",
385+
// CHECK-DAG: ![[K_COPYABLE_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]] = !DILocalVariable(name: "k",
386+
// CHECK-DAG: ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_OUT_BLOCK_METADATA]] = !DILocalVariable(name: "k",
387+
// CHECK-DAG: ![[K_ADDRESSONLY_VAR_CCFLOW_REINIT_IN_BLOCK_METADATA]] = !DILocalVariable(name: "k",

test/SILGen/moveonly_builtin.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ class Klass {}
2828

2929
// CHECK-SIL-LABEL: sil hidden @$s8moveonly7useMoveyAA5KlassCADnF : $@convention(thin) (@owned Klass) -> @owned Klass {
3030
// CHECK-SIL: bb0([[ARG:%.*]] :
31-
// CHECK-SIL-NEXT: debug_value
31+
// CHECK-SIL-NEXT: debug_value [moved]
32+
// CHECK-SIL-NEXT: br bb1
33+
//
34+
// CHECK-SIL: bb1
3235
// CHECK-SIL-NEXT: strong_retain
3336
// CHECK-SIL-NEXT: move_value
3437
// CHECK-SIL-NEXT: debug_value [moved] undef
@@ -62,7 +65,9 @@ func useMove(_ k: __owned Klass) -> Klass {
6265

6366
// CHECK-SIL-LABEL: sil hidden @$s8moveonly7useMoveyxxnRlzClF : $@convention(thin) <T where T : AnyObject> (@owned T) -> @owned T {
6467
// CHECK-SIL: bb0([[ARG:%.*]] :
65-
// CHECK-SIL-NEXT: debug_value
68+
// CHECK-SIL-NEXT: debug_value [moved]
69+
// CHECK-SIL-NEXT: br bb1
70+
// CHECK-SIL: bb1:
6671
// CHECK-SIL-NEXT: strong_retain
6772
// CHECK-SIL-NEXT: move_value
6873
// CHECK-SIL-NEXT: debug_value [moved] undef

test/SILOptimizer/move_function_kills_addresses_dbginfo.sil

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Builtin
1111

1212
// CHECK-LABEL: sil [ossa] @singleBlock : $@convention(thin) (@owned Builtin.NativeObject) -> () {
1313
// CHECK: [[SRC_ADDR:%.*]] = alloc_stack [lexical] [moved] $Builtin.NativeObject, let, name "[[VAR_NAME:.*]]"
14+
// CHECK-NEXT: br
1415
// CHECK: [[DEST_ADDR:%.*]] = alloc_stack $Builtin.NativeObject
1516
// CHECK: copy_addr [take] [[SRC_ADDR]] to [initialization] [[DEST_ADDR]]
1617
// CHECK-NEXT: debug_value [moved] undef
@@ -38,13 +39,14 @@ bb0(%0 : @owned $Builtin.NativeObject):
3839
// CHECK-LABEL: sil [ossa] @multipleBlock : $@convention(thin) (@owned Builtin.NativeObject) -> () {
3940
// CHECK: bb0(
4041
// CHECK: [[SRC_ADDR:%.*]] = alloc_stack [lexical] [moved] $Builtin.NativeObject, let, name "[[VAR_NAME:.*]]"
42+
// CHECK-NEXT: br
4143
// CHECK: [[DEST_ADDR:%.*]] = alloc_stack $Builtin.NativeObject
42-
// CHECK: cond_br undef, bb1, bb2
44+
// CHECK: cond_br undef, [[LHS:bb[0-9]+]], [[RHS:bb[0-9]+]]
4345
//
44-
// CHECK: bb1:
46+
// CHECK: [[LHS]]:
4547
// CHECK: copy_addr [take] [[SRC_ADDR]] to [initialization] [[DEST_ADDR]]
4648
// CHECK: debug_value [moved] undef : $*Builtin.NativeObject, let, name "[[VAR_NAME]]"
47-
// CHECK: br bb3
49+
// CHECK: br bb
4850
//
4951
// CHECK: } // end sil function 'multipleBlock'
5052
sil [ossa] @multipleBlock : $@convention(thin) (@owned Builtin.NativeObject) -> () {

0 commit comments

Comments
 (0)