Skip to content

Commit 748fe46

Browse files
Merge pull request #36190 from adrian-prantl/toplevelscope
Remove the redundant lexical scope for function-body brace statements.
2 parents 8184952 + 4174e21 commit 748fe46

18 files changed

+66
-81
lines changed

lib/SILGen/SILGenFunction.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,11 +600,12 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
600600
auto *Parent =
601601
DebugScopeStack.size() ? DebugScopeStack.back().getPointer() : F.getDebugScope();
602602
auto *DS = Parent;
603-
// Don't nest a scope for Loc under Parent unless it's actually different.
604-
if (RegularLocation(DS->getLoc()) != RegularLocation(Loc)) {
605-
DS = new (SGM.M)
603+
// Don't create a pointless scope for the function body's BraceStmt.
604+
if (!DebugScopeStack.empty())
605+
// Don't nest a scope for Loc under Parent unless it's actually different.
606+
if (RegularLocation(DS->getLoc()) != RegularLocation(Loc))
607+
DS = new (SGM.M)
606608
SILDebugScope(RegularLocation(Loc), &getFunction(), DS);
607-
}
608609
DebugScopeStack.emplace_back(DS, isGuardScope);
609610
B.setCurrentDebugScope(DS);
610611
}

test/DebugInfo/any.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ func markUsed<T>(_ t: T) {}
44

55
func main() {
66
// CHECK: call void @llvm.dbg.declare(metadata %Any* {{.*}}, metadata ![[S:.*]], metadata !DIExpression()), !dbg ![[DBG:.*]]
7-
// CHECK: ![[S]] = !DILocalVariable(name: "s", {{.*}}line: [[@LINE+3]]
8-
// CHECK: ![[SCOPE:.*]] = distinct !DILexicalBlock({{.*}}line: 5, column: 13)
9-
// CHECK: ![[DBG]] = !DILocation(line: [[@LINE+1]], column: 7, scope: ![[SCOPE:.*]])
7+
// CHECK: ![[S]] = !DILocalVariable(name: "s", {{.*}}line: [[@LINE+2]]
8+
// CHECK: ![[DBG]] = !DILocation(line: [[@LINE+1]], column: 7,
109
var s: Any = "hello world"
1110
var n: Any = 12
1211
var t: Any = (1,2)

test/DebugInfo/basic.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,13 @@ public
4242
func foo(_ a: Int64, _ b: Int64) -> Int64 {
4343
var a = a
4444
var b = b
45-
// CHECK-DAG: !DILexicalBlock(scope: ![[FOO]],{{.*}} line: [[@LINE-3]]
46-
// CHECK-DAG: ![[ASCOPE:.*]] = !DILocation(line: [[@LINE-4]],{{.*}} scope: ![[FOO]])
45+
// CHECK-DAG: ![[ALOC:.*]] = !DILocation(line: [[@LINE-3]],{{.*}} scope: ![[FOO]])
4746
// Check that a is the first and b is the second argument.
4847
// CHECK-DAG: store i64 %0, i64* [[AADDR:.*]], align
4948
// CHECK-DAG: store i64 %1, i64* [[BADDR:.*]], align
5049
// CHECK-DAG: [[AVAL:%.*]] = getelementptr inbounds {{.*}}, [[AMEM:.*]], i32 0, i32 0
5150
// CHECK-DAG: [[BVAL:%.*]] = getelementptr inbounds {{.*}}, [[BMEM:.*]], i32 0, i32 0
52-
// CHECK-DAG: call void @llvm.dbg.declare(metadata i64* [[AADDR]], metadata ![[AARG:.*]], metadata !DIExpression()), !dbg ![[ASCOPE]]
51+
// CHECK-DAG: call void @llvm.dbg.declare(metadata i64* [[AADDR]], metadata ![[AARG:.*]], metadata !DIExpression()), !dbg ![[ALOC]]
5352
// CHECK-DAG: call void @llvm.dbg.declare(metadata i64* [[BADDR]], metadata ![[BARG:.*]], metadata !DIExpression())
5453
// CHECK-DAG: ![[AARG]] = !DILocalVariable(name: "a", arg: 1
5554
// CHECK-DAG: ![[BARG]] = !DILocalVariable(name: "b", arg: 2

test/DebugInfo/columns.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ public func foo(_ a: Int64, _ b: Int64) -> Int64 { // line 5
1515
}
1616

1717
// CHECK-DAG: !DISubprogram(name: "foo",{{.*}} line: 5,
18-
// DWARF-CHECK-DAG: !DILexicalBlock({{.*}}, line: 5, column: 50)
1918
// DWARF-CHECK-DAG: ![[DIV]] = !DILocation(line: 8, column: 17,
2019
// DWARF-CHECK-DAG: ![[ADD]] = !DILocation(line: 8, column: 13,
2120
// DWARF-CHECK-DAG: ![[SLT]] = !DILocation(line: 10, column: 9,
2221
// DWARF-CHECK-DAG: !DILexicalBlock({{.*}}, line: 10, column: 14)
2322
// DWARF-CHECK-DAG: ![[SUB]] = !DILocation(line: 12, column: 14,
2423

25-
// CV-CHECK-DAG: !DILexicalBlock({{.*}}, line: 5)
2624
// CV-CHECK-DAG: ![[DIV]] = !DILocation(line: 8, scope:
2725
// CV-CHECK-DAG: ![[SLT]] = !DILocation(line: 10, scope:
2826
// CV-CHECK-DAG: !DILexicalBlock({{.*}}, line: 10)

test/DebugInfo/doubleinlines.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ func callCondFail(arg: Builtin.Int1, msg: Builtin.RawPointer) {
1313
// CHECK: define hidden swiftcc void @"$s13DoubleInlines12callCondFail3arg3msgyBi1__BptF"{{.*}} !dbg ![[FUNCSCOPE:.*]] {
1414
// CHECK: tail call void asm sideeffect "", "n"(i32 0) #3, !dbg ![[SCOPEONE:.*]]
1515
// CHECK: ![[FUNCSCOPEOTHER:.*]] = distinct !DISubprogram(name: "condFail",{{.*}}
16-
// CHECK: ![[SCOPEFIVE:.*]] = distinct !DILexicalBlock(scope: ![[FUNCSCOPE]], file: ![[FILE:.*]], line: 9)
17-
// CHECK: ![[SCOPESIX:.*]] = distinct !DILexicalBlock(scope: ![[FUNCSCOPEOTHER]], file: ![[FILE]], line: 5)
1816
// CHECK: ![[SCOPEONE]] = !DILocation(line: 0, scope: ![[SCOPETWO:.*]], inlinedAt: ![[SCOPETHREE:.*]])
1917
// CHECK: ![[SCOPETHREE]] = !DILocation(line: 6, scope: ![[SCOPEFOUR:.*]])
20-
// CHECK: ![[SCOPEFOUR]] = distinct !DILexicalBlock(scope: ![[SCOPEFIVE]], file: ![[FILE]], line: 10)
18+
// CHECK: ![[SCOPEFOUR]] = distinct !DILexicalBlock(scope: ![[FUNCSCOPE]], file: !{{.*}}, line: 10)

test/DebugInfo/guard-let-scope.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// RUN: | %FileCheck %s
33
func f(c: AnyObject?) {
44
let x = c
5-
// CHECK: sil_scope [[S1:[0-9]+]] { loc "{{.*}}":[[@LINE-2]]:23 parent
5+
// CHECK: sil_scope [[S1:[0-9]+]] { {{.*}} parent @{{.*}}1f
66
// CHECK: sil_scope [[S2:[0-9]+]] { loc "{{.*}}":[[@LINE+3]]:3 parent [[S1]] }
7-
// CHECK: debug_value %0 : $Optional<AnyObject>, let, name "x"{{.*}} scope [[S1]]
8-
// CHECK: debug_value %6 : $AnyObject, let, name "x", {{.*}} scope [[S2]]
7+
// CHECK: debug_value %{{.*}} : $Optional<AnyObject>, let, name "x"{{.*}} scope [[S1]]
8+
// CHECK: debug_value %{{.*}} : $AnyObject, let, name "x", {{.*}} scope [[S2]]
99
guard let x = x else {
1010
fatalError(".")
1111
}

test/DebugInfo/inlined-generics-basic.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,11 @@ func yes() -> Bool { return true }
2929
}
3030

3131
// SIL: sil_scope [[F:.*]] { {{.*}}parent @$s1A1CC1fyyqd__lF
32-
// SIL: sil_scope [[F1:.*]] { loc "f.swift":1:28 parent [[F]] }
33-
// SIL: sil_scope [[F1G:.*]] { loc "f.swift":2:5 parent [[F1]] }
32+
// SIL: sil_scope [[F1G:.*]] { loc "f.swift":2:5 parent [[F]] }
3433
// SIL: sil_scope [[F1G1:.*]] { loc "g.swift":2:3 {{.*}}inlined_at [[F1G]] }
3534
// SIL: sil_scope [[F1G3:.*]] { loc "g.swift":3:5 {{.*}}inlined_at [[F1G]] }
3635
// SIL: sil_scope [[F1G3H:.*]] { loc "h.swift":1:24
3736
// SIL-SAME: parent @{{.*}}1h{{.*}} inlined_at [[F1G3]] }
38-
// SIL: sil_scope [[F1G3H1:.*]] { loc "h.swift":1:37
39-
// SIL-SAME: parent [[F1G3H]] inlined_at [[F1G3]] }
4037

4138
#sourceLocation(file: "C.swift", line: 1)
4239
public class C<R> {
@@ -49,7 +46,7 @@ public class C<R> {
4946
public func f<S>(_ s: S) {
5047
// SIL: debug_value_addr %0 : $*S, let, name "s", argno 1,{{.*}} scope [[F]]
5148
// SIL: function_ref {{.*}}yes{{.*}} scope [[F1G1]]
52-
// SIL: function_ref {{.*}}use{{.*}} scope [[F1G3H1]]
49+
// SIL: function_ref {{.*}}use{{.*}} scope [[F1G3H]]
5350
// IR: dbg.value(metadata %swift.type* %S, metadata ![[MD_1_0:[0-9]+]]
5451
// IR: dbg.value(metadata %swift.opaque* %0, metadata ![[S:[0-9]+]]
5552
// IR: dbg.value(metadata %swift.opaque* %0, metadata ![[GS_T:[0-9]+]]

test/DebugInfo/inlinedAt.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,10 @@ public func f(_ i : Int) -> Int { // 301
4141
// CHECK: ![[G:.*]] = distinct !DISubprogram(name: "g",
4242

4343
// CHECK: ![[L3:.*]] = !DILocation(line: 302, column: 10,
44-
// CHECK-SAME: scope: ![[F_SCOPE:.*]])
45-
// CHECK: ![[F_SCOPE]] = distinct !DILexicalBlock(scope: ![[F]],
46-
// CHECK-SAME: line: 301, column: 33)
47-
// CHECK: ![[G_SCOPE:.*]] = distinct !DILexicalBlock(scope: ![[G]],
48-
// CHECK-SAME: line: 201, column: 26)
44+
// CHECK-SAME: scope: ![[F:.*]])
4945
// CHECK: ![[H:.*]] = distinct !DISubprogram(name: "h",
5046
// CHECK: ![[L1]] = !DILocation(line: 101, column: 8, scope: ![[H]],
5147
// CHECK-SAME: inlinedAt: ![[L2:.*]])
52-
// CHECK: ![[L2]] = !DILocation(line: 203, column: 10, scope: ![[G_SCOPE]],
48+
// CHECK: ![[L2]] = !DILocation(line: 203, column: 10, scope: ![[G]],
5349
// CHECK-SAME: inlinedAt: ![[L3]])
5450

test/DebugInfo/inlinescopes.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ func transparent(_ x: Int64) -> Int64 { return noinline(x) }
2424

2525
@inline(__always)
2626
func inlined(_ x: Int64) -> Int64 {
27-
// CHECK-DAG: ![[CALL]] = !DILocation(line: [[@LINE+2]], column: {{.*}}, scope: ![[SCOPE:.*]], inlinedAt: ![[INLINED:.*]])
28-
// CHECK-DAG: ![[SCOPE:.*]] = distinct !DILexicalBlock(
27+
// CHECK-DAG: ![[CALL]] = !DILocation(line: [[@LINE+3]], column: {{.*}}, scope: ![[SCOPE:.*]], inlinedAt: ![[INLINED:.*]])
28+
// Check if the inlined and removed function still has the correct linkage name.
29+
// CHECK-DAG: ![[SCOPE]] = distinct !DISubprogram(name: "inlined", linkageName: "$s4main7inlinedys5Int64VADF"
2930
let result = transparent(x)
3031
// TRANSPARENT-CHECK-NOT: !DISubprogram(name: "transparent"
3132
return result
3233
}
3334
// CHECK-DAG: !DIGlobalVariable(name: "y",{{.*}} file: ![[TOPLEVEL]],{{.*}} line: [[@LINE+1]]
3435
public let y = inlined(x)
35-
36-
// Check if the inlined and removed function still has the correct linkage name.
37-
// CHECK-DAG: !DISubprogram(name: "inlined", linkageName: "$s4main7inlinedys5Int64VADF"

test/DebugInfo/mandatory-inlining-ownership.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// RUN: -sil-print-after=mandatory-inlining \
55
// RUN: -Xllvm -sil-print-debuginfo -o /dev/null 2>&1 | %FileCheck %s
66

7-
// CHECK: begin_borrow {{.*}} : $OSLog, loc {{.*}}, scope 5
8-
// CHECK: tuple (), loc {{.*}}, scope 5
9-
// CHECK: end_borrow %9 : $OSLog, loc {{.*}}, scope 5
7+
// CHECK: begin_borrow {{.*}} : $OSLog, loc {{.*}}, scope 4
8+
// CHECK: tuple (), loc {{.*}}, scope 4
9+
// CHECK: end_borrow %9 : $OSLog, loc {{.*}}, scope 4
1010

1111
import os
1212

test/DebugInfo/returnlocation.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,9 @@ public class Class1 {
184184
public required init?() {
185185
print("hello")
186186
// CHECK_INIT: call {{.*}}@"$ss5print_9separator10terminatoryypd_S2StF"{{.*}}, !dbg [[printLoc:![0-9]+]]
187-
// CHECK_INIT: ret i{{32|64}} 0, !dbg [[retnLoc:![0-9]+]]
188-
189-
// CHECK_INIT: [[retnLoc]] = !DILocation(line: 0
190-
// CHECK_INIT: [[printLoc]] = !DILocation(line: [[@LINE-5]]
187+
// FIXME: Why doesn't ret have the correct line number?
188+
// CHECK_INIT: ret i{{32|64}} 0, !dbg [[printLoc]]
189+
// CHECK_INIT: [[printLoc]] = !DILocation(line: [[@LINE-4]]
191190
return nil
192191
}
193192
}

test/DebugInfo/transparent.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use(z)
2121
// CHECK-NEXT: !dbg ![[ZERO:[0-9]+]]
2222
// CHECK-NEXT: }
2323

24-
// CHECK: ![[FILE:[0-9]+]] = {{.*}}"<compiler-generated>"
25-
// CHECK: ![[SP]] = {{.*}}name: "transparent"
26-
// CHECK-SAME: file: ![[FILE:[0-9]+]]
24+
// CHECK: ![[SP]] = distinct !DISubprogram({{.*}}name: "transparent"
25+
// CHECK-SAME: file: ![[FILE:[0-9]+]]
26+
// CHECK: ![[FILE]] = {{.*}}"<compiler-generated>"
2727
// CHECK-NOT: line:
2828
// CHECK: ![[ZERO]] = !DILocation(line: 0,

test/SILOptimizer/capturepromotion-wrong-lexicalscope.swift

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44

55
// CHECK: sil hidden [ossa] @$s4null19captureStackPromoteSiycyF : $@convention(thin) () -> @owned @callee_guaranteed () -> Int {
66
// CHECK: bb0:
7-
// CHECK: %0 = alloc_box ${ var Int }, var, name "x", loc {{.*}}:32:7, scope 3
8-
// CHECK: %1 = project_box %0 : ${ var Int }, 0, loc {{.*}}:32:7, scope 3
9-
// CHECK: %2 = integer_literal $Builtin.IntLiteral, 1, loc {{.*}}:32:11, scope 3
10-
// CHECK: %3 = metatype $@thin Int.Type, loc {{.*}}:32:11, scope 3
11-
// CHECK: %4 = function_ref @$sSi22_builtinIntegerLiteralSiBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int, loc {{.*}}:32:11, scope 3
12-
// CHECK: %5 = apply %4(%2, %3) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int, loc {{.*}}:32:11, scope 3
13-
// CHECK: store %5 to [trivial] %1 : $*Int, loc {{.*}}:32:11, scope 3
14-
// CHECK: %7 = copy_value %0 : ${ var Int }, loc {{.*}}:33:11, scope 3
15-
// CHECK: %8 = project_box %7 : ${ var Int }, 0, loc {{.*}}:33:11, scope 3
16-
// CHECK: mark_function_escape %1 : $*Int, loc {{.*}}:33:11, scope 3
17-
// CHECK: %10 = function_ref @$s4null19captureStackPromoteSiycyFSiycfU_Tf2i_n : $@convention(thin) (Int) -> Int, loc {{.*}}:33:11, scope 3
18-
// CHECK: %11 = load [trivial] %8 : $*Int, loc {{.*}}:33:11, scope 3
19-
// CHECK: destroy_value %7 : ${ var Int }, loc {{.*}}:33:11, scope 3
20-
// CHECK: %13 = partial_apply [callee_guaranteed] %10(%11) : $@convention(thin) (Int) -> Int, loc {{.*}}:33:11, scope 3
21-
// CHECK: debug_value %13 : $@callee_guaranteed () -> Int, let, name "f", loc {{.*}}:33:7, scope 3
7+
// CHECK: %0 = alloc_box ${ var Int }, var, name "x", loc {{.*}}:32:7, scope 2
8+
// CHECK: %1 = project_box %0 : ${ var Int }, 0, loc {{.*}}:32:7, scope 2
9+
// CHECK: %2 = integer_literal $Builtin.IntLiteral, 1, loc {{.*}}:32:11, scope 2
10+
// CHECK: %3 = metatype $@thin Int.Type, loc {{.*}}:32:11, scope 2
11+
// CHECK: %4 = function_ref @$sSi22_builtinIntegerLiteralSiBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int, loc {{.*}}:32:11, scope 2
12+
// CHECK: %5 = apply %4(%2, %3) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int, loc {{.*}}:32:11, scope 2
13+
// CHECK: store %5 to [trivial] %1 : $*Int, loc {{.*}}:32:11, scope 2
14+
// CHECK: %7 = copy_value %0 : ${ var Int }, loc {{.*}}:33:11, scope 2
15+
// CHECK: %8 = project_box %7 : ${ var Int }, 0, loc {{.*}}:33:11, scope 2
16+
// CHECK: mark_function_escape %1 : $*Int, loc {{.*}}:33:11, scope 2
17+
// CHECK: %10 = function_ref @$s4null19captureStackPromoteSiycyFSiycfU_Tf2i_n : $@convention(thin) (Int) -> Int, loc {{.*}}:33:11, scope 2
18+
// CHECK: %11 = load [trivial] %8 : $*Int, loc {{.*}}:33:11, scope 2
19+
// CHECK: destroy_value %7 : ${ var Int }, loc {{.*}}:33:11, scope 2
20+
// CHECK: %13 = partial_apply [callee_guaranteed] %10(%11) : $@convention(thin) (Int) -> Int, loc {{.*}}:33:11, scope 2
21+
// CHECK: debug_value %13 : $@callee_guaranteed () -> Int, let, name "f", loc {{.*}}:33:7, scope 2
2222
// There used to be a begin_borrow here. We leave an emptyline here to preserve line numbers.
23-
// CHECK: %15 = copy_value %13 : $@callee_guaranteed () -> Int, loc {{.*}}:34:10, scope 3
23+
// CHECK: %15 = copy_value %13 : $@callee_guaranteed () -> Int, loc {{.*}}:34:10, scope 2
2424
// There used to be an end_borrow here. We leave an emptyline here to preserve line numbers.
25-
// CHECK: destroy_value %13 : $@callee_guaranteed () -> Int, loc {{.*}}:35:1, scope 3
26-
// CHECK: destroy_value %0 : ${ var Int }, loc {{.*}}:35:1, scope 3
27-
// CHECK: return %15 : $@callee_guaranteed () -> Int, loc {{.*}}:34:3, scope 3
25+
// CHECK: destroy_value %13 : $@callee_guaranteed () -> Int, loc {{.*}}:35:1, scope 2
26+
// CHECK: destroy_value %0 : ${ var Int }, loc {{.*}}:35:1, scope 2
27+
// CHECK: return %15 : $@callee_guaranteed () -> Int, loc {{.*}}:34:3, scope 2
2828
// CHECK: }
2929

3030

test/SILOptimizer/castoptimizer-wrongscope.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
// RUN: -Xllvm -sil-print-after=diagnostic-constant-propagation \
66
// RUN: 2>&1 | %FileCheck %s
77

8-
// CHECK: alloc_stack $R, loc {{.*}}, scope 2
9-
// CHECK-NEXT: init_existential_addr {{.*}} : $*R, $Float, loc {{.*}}, scope 2
10-
// CHECK-NEXT: copy_addr [take] %8 to [initialization] {{.*}} : $*Float, loc {{.*}}, scope 2
8+
// CHECK: alloc_stack $R, loc {{.*}}, scope 1
9+
// CHECK-NEXT: init_existential_addr {{.*}} : $*R, $Float, loc {{.*}}, scope 1
10+
// CHECK-NEXT: copy_addr [take] %8 to [initialization] {{.*}} : $*Float, loc {{.*}}, scope 1
1111

1212
protocol R {}
1313
extension Float: R {}

test/SILOptimizer/constantprop-wrongscope.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// Make sure that the destroy_addr instruction has the same scope of the
1313
// instructions surrounding it.
1414

15-
// CHECK: destroy_addr %7 : $*Any, loc {{.*}}:22:19, scope 2
16-
// CHECK: dealloc_stack %12 : $*Optional<Any>, loc {{.*}}:22:23, scope 2
17-
// CHECK: dealloc_stack %7 : $*Any, loc {{.*}}:22:23, scope 2
18-
// CHECK: dealloc_stack %6 : $*A, loc {{.*}}:22:7, scope 2
15+
// CHECK: destroy_addr %7 : $*Any, loc {{.*}}:22:19, scope 1
16+
// CHECK: dealloc_stack %12 : $*Optional<Any>, loc {{.*}}:22:23, scope 1
17+
// CHECK: dealloc_stack %7 : $*Any, loc {{.*}}:22:23, scope 1
18+
// CHECK: dealloc_stack %6 : $*A, loc {{.*}}:22:7, scope 1
1919

2020
import Foundation
2121
func indexedSubscripting(b b: B, idx: Int, a: A) {

test/SILOptimizer/definite-init-wrongscope.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ public class M {
3333

3434
// CHECK-LABEL: sil [ossa] @$s3del1MC4fromAcA12WithDelegate_p_tKcfc : $@convention(method) (@in WithDelegate, @owned M) -> (@owned M, @error Error)
3535

36-
// CHECK: [[I:%.*]] = integer_literal $Builtin.Int2, 1, loc {{.*}}:23:12, scope 3
37-
// CHECK: [[V:%.*]] = load [trivial] %2 : $*Builtin.Int2, loc {{.*}}:23:12, scope 3
38-
// CHECK: [[OR:%.*]] = builtin "or_Int2"([[V]] : $Builtin.Int2, [[I]] : $Builtin.Int2) : $Builtin.Int2, loc {{.*}}:23:12, scope 3
39-
// CHECK: store [[OR]] to [trivial] %2 : $*Builtin.Int2, loc {{.*}}:23:12, scope 3
40-
// CHECK: store %{{.*}} to [init] %{{.*}} : $*C, loc {{.*}}:26:20, scope 3
36+
// CHECK: [[I:%.*]] = integer_literal $Builtin.Int2, 1, loc {{.*}}:23:12, scope 2
37+
// CHECK: [[V:%.*]] = load [trivial] %2 : $*Builtin.Int2, loc {{.*}}:23:12, scope 2
38+
// CHECK: [[OR:%.*]] = builtin "or_Int2"([[V]] : $Builtin.Int2, [[I]] : $Builtin.Int2) : $Builtin.Int2, loc {{.*}}:23:12, scope 2
39+
// CHECK: store [[OR]] to [trivial] %2 : $*Builtin.Int2, loc {{.*}}:23:12, scope 2
40+
// CHECK: store %{{.*}} to [init] %{{.*}} : $*C, loc {{.*}}:26:20, scope 2
4141

4242
// Make sure the dealloc_stack gets the same scope of the instructions surrounding it.
4343

44-
// CHECK: destroy_addr %0 : $*WithDelegate, loc {{.*}}:29:5, scope 3
45-
// CHECK: dealloc_stack %2 : $*Builtin.Int2, loc {{.*}}:23:12, scope 3
44+
// CHECK: destroy_addr %0 : $*WithDelegate, loc {{.*}}:29:5, scope 2
45+
// CHECK: dealloc_stack %2 : $*Builtin.Int2, loc {{.*}}:23:12, scope 2
4646
// CHECK: throw %{{.*}} : $Error, loc {{.*}}:23:12, scope 1

test/SILOptimizer/di-conditional-destroy-scope.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
// REQUIRES: objc_interop
77

88

9-
// CHECK: [[ADR:%.*]] = ref_element_addr %{{.*}} : $RecursibleDirectoryContentsGenerator, #RecursibleDirectoryContentsGenerator.fileSystem, loc {{.*}}:39:5, scope 2
9+
// CHECK: [[ADR:%.*]] = ref_element_addr %{{.*}} : $RecursibleDirectoryContentsGenerator, #RecursibleDirectoryContentsGenerator.fileSystem, loc {{.*}}:39:5, scope 1
1010
// CHECK: [[ADR_ACCESS:%.*]] = begin_access [deinit] [static] [[ADR]]
11-
// CHECK: destroy_addr [[ADR_ACCESS]] : $*FileSystem, loc {{.*}}:39:5, scope 2
11+
// CHECK: destroy_addr [[ADR_ACCESS]] : $*FileSystem, loc {{.*}}:39:5, scope 1
1212

1313

1414
import Foundation

test/SILOptimizer/stack-nesting-wrong-scope.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// RUN: -Xllvm -sil-print-debuginfo -o %t -module-name red 2>&1 | %FileCheck %s
55

66
// CHECK: bb{{[0-9]+}}(%{{[0-9]+}} : @owned $Error):
7-
// CHECK: dealloc_stack %{{[0-9]+}} : $*ThrowAddrOnlyStruct<T>, loc {{.*}}:26:68, scope 2
8-
// CHECK: br bb{{[0-9]+}}(%{{[0-9]+}} : $Error), loc {{.*}}:26:15, scope 2
7+
// CHECK: dealloc_stack %{{[0-9]+}} : $*ThrowAddrOnlyStruct<T>, loc {{.*}}:26:68, scope 1
8+
// CHECK: br bb{{[0-9]+}}(%{{[0-9]+}} : $Error), loc {{.*}}:26:15, scope 1
99

1010
protocol Patatino {
1111
init()

0 commit comments

Comments
 (0)