Skip to content

Commit

Permalink
Debug Info: Don't skip updating IRGenDebugInfo's current location for…
Browse files Browse the repository at this point in the history
… SILLocations that are marked as prologue. IRGenDebugInfo will handle them correctly anyway and if the instruction with the prologue location originates from an inlined function, this would result in dropping debug location information.

rdar://problem/23288366
  • Loading branch information
adrian-prantl committed Nov 10, 2015
1 parent 6879dad commit 098c079
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 40 deletions.
2 changes: 1 addition & 1 deletion lib/IRGen/IRGenSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ void IRGenSILFunction::visitSILBasicBlock(SILBasicBlock *BB) {

// Ignore scope-less instructions and have IRBuilder reuse the
// previous location and scope.
if (DS && !KeepCurrentLocation && !ILoc.isInPrologue())
if (DS && !KeepCurrentLocation)
IGM.DebugInfo->setCurrentLoc(Builder, DS, ILoc);

// Function argument handling.
Expand Down
86 changes: 47 additions & 39 deletions test/DebugInfo/patternmatching.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,54 @@
func markUsed<T>(t: T) {}

func classifyPoint2(p: (Double, Double)) {
func return_same (input : Double) -> Double
{
func return_same (input : Double) -> Double {
var input = input
return input; // return_same gets called in both where statements
return input;
}


switch p {
case (0, 0):
markUsed("origin")
case (0, _):
markUsed("on the Y axis")
markUsed("(0, \(p.1)) is on the y-axis")
case (_, 0):
markUsed("on the X axis")
case (let x, let y) where
// CHECK: call double {{.*}}return_same{{.*}}, !dbg ![[LOC1:.*]]
// CHECK: br {{.*}}, label {{.*}}, label {{.*}}, !dbg ![[LOC2:.*]]
// CHECK: builtinStringLiteral{{.*}}, !dbg ![[LOC3:.*]]
// CHECK: ![[LOC1]] = !DILocation(line: [[@LINE+2]],
// CHECK: ![[LOC2]] = !DILocation(line: [[@LINE+1]],
return_same(x) == return_same(y):
// CHECK: ![[LOC3]] = !DILocation(line: [[@LINE+1]],
markUsed("(\(x), \(y)) is on the + diagonal")
// SIL-CHECK: dealloc_stack{{.*}}line:[[@LINE-1]]:55:cleanup
// Verify that the branch has a location >= the cleanup.
// SIL-CHECK-NEXT: br{{.*}}line:[[@LINE-3]]:55:cleanup
case (let x, let y) where x == -y:
// Verify that all variables end up in the appropriate scopes.
// CHECK-SCOPES: !DILocalVariable(name: "x", scope: ![[SCOPE1:[0-9]+]],{{.*}} line: [[@LINE-2]]
// CHECK-SCOPES: ![[SCOPE1]] = distinct !DILexicalBlock(
markUsed("on the - diagonal")
case (let x, let y) where x >= -10 && x < 10 && y >= -10 && y < 10:
// CHECK-SCOPES: !DILocalVariable(name: "x", scope: ![[SCOPE2:[0-9]+]],{{.*}} line: [[@LINE-1]]
// CHECK-SCOPES: ![[SCOPE2]] = distinct !DILexicalBlock(
markUsed("near the origin")
case (let x, let y):
// CHECK-SCOPES: !DILocalVariable(name: "x", scope: ![[SCOPE3:[0-9]+]],{{.*}} line: [[@LINE-1]]
// CHECK-SCOPES: ![[SCOPE3]] = distinct !DILexicalBlock(
markUsed("sqrt(\(x*x + y*y)) units from the origin")
}
// CHECK: !DILocation(line: [[@LINE+1]],
switch p {
case (let x, let y) where
// CHECK: call double {{.*}}return_same{{.*}}, !dbg ![[LOC1:.*]]
// CHECK: br {{.*}}, label {{.*}}, label {{.*}}, !dbg ![[LOC2:.*]]
// CHECK: call{{.*}}markUsed{{.*}}, !dbg ![[LOC3:.*]]
// CHECK: ![[LOC1]] = !DILocation(line: [[@LINE+2]],
// CHECK: ![[LOC2]] = !DILocation(line: [[@LINE+1]],
return_same(x) == return_same(y):
// CHECK: ![[LOC3]] = !DILocation(line: [[@LINE+1]],
markUsed(x)
// SIL-CHECK: dealloc_stack{{.*}}line:[[@LINE-1]]:17:cleanup
// Verify that the branch has a location >= the cleanup.
// SIL-CHECK-NEXT: br{{.*}}line:[[@LINE-3]]:17:cleanup
// CHECK-SCOPES: call {{.*}}markUsed
// CHECK-SCOPES: call void @llvm.dbg.declare({{.*}}metadata ![[X1:[0-9]+]]
// CHECK-SCOPES-SAME: !dbg ![[X1LOC:[0-9]+]]
// CHECK-SCOPES: call void @llvm.dbg.declare
// CHECK-SCOPES: call void @llvm.dbg.declare({{.*}}metadata ![[X2:[0-9]+]]
// CHECK-SCOPES-SAME: !dbg ![[X2LOC:[0-9]+]]
// CHECK-SCOPES: call void @llvm.dbg.declare
// CHECK-SCOPES: call void @llvm.dbg.declare({{.*}}metadata ![[X3:[0-9]+]]
// CHECK-SCOPES-SAME: !dbg ![[X3LOC:[0-9]+]]
// CHECK-SCOPES: !DILocalVariable(name: "x",
case (let x, let y) where x == -y:
// Verify that all variables end up in separate appropriate scopes.
// CHECK-SCOPES: !DILocalVariable(name: "x", scope: ![[SCOPE1:[0-9]+]],
// CHECK-SCOPES-SAME: line: [[@LINE-3]]
// CHECK-SCOPES: ![[X1LOC]] = !DILocation(line: [[@LINE-4]], column: 15,
// CHECK-SCOPES-SAME: scope: ![[SCOPE1]])
// FIXME: ![[SCOPE1]] = distinct !DILexicalBlock({{.*}}line: [[@LINE-6]]
markUsed(x)
case (let x, let y) where x >= -10 && x < 10 && y >= -10 && y < 10:
// CHECK-SCOPES: !DILocalVariable(name: "x", scope: ![[SCOPE2:[0-9]+]],
// CHECK-SCOPES-SAME: line: [[@LINE-2]]
// CHECK-SCOPES: ![[X2LOC]] = !DILocation(line: [[@LINE-3]], column: 15,
// CHECK-SCOPES-SAME: scope: ![[SCOPE2]])
markUsed(x)
case (let x, let y):
// CHECK-SCOPES: !DILocalVariable(name: "x", scope: ![[SCOPE3:[0-9]+]],
// CHECK-SCOPES-SAME: line: [[@LINE-2]]
// CHECK-SCOPES: ![[X3LOC]] = !DILocation(line: [[@LINE-3]], column: 15,
// CHECK-SCOPES-SAME: scope: ![[SCOPE3]])
markUsed(x)
}
// CHECK: !DILocation(line: [[@LINE+1]],
}

0 comments on commit 098c079

Please sign in to comment.