Skip to content

Commit 0fac43e

Browse files
adrian-prantlgottesmm
authored andcommitted
Adapt to upstream LLVM changes.
<rdar://problem/25949511+25962000> (cherry picked from commit df9dfac)
1 parent 2067402 commit 0fac43e

29 files changed

+142
-112
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,22 @@ StringRef IRGenDebugInfo::BumpAllocatedString(StringRef S) {
7373
}
7474

7575
/// Return the size reported by a type.
76-
static unsigned getSizeInBits(llvm::DIType *Ty, const TrackingDIRefMap &Map) {
76+
static unsigned getSizeInBits(llvm::DIType *Ty) {
7777
// Follow derived types until we reach a type that
7878
// reports back a size.
7979
while (isa<llvm::DIDerivedType>(Ty) && !Ty->getSizeInBits()) {
8080
auto *DT = cast<llvm::DIDerivedType>(Ty);
81-
Ty = DT->getBaseType().resolve(Map);
81+
Ty = DT->getBaseType().resolve();
8282
if (!Ty)
8383
return 0;
8484
}
8585
return Ty->getSizeInBits();
8686
}
8787

8888
/// Return the size reported by the variable's type.
89-
static unsigned getSizeInBits(const llvm::DILocalVariable *Var,
90-
const TrackingDIRefMap &Map) {
91-
llvm::DIType *Ty = Var->getType().resolve(Map);
92-
return getSizeInBits(Ty, Map);
89+
static unsigned getSizeInBits(const llvm::DILocalVariable *Var) {
90+
llvm::DIType *Ty = Var->getType().resolve();
91+
return getSizeInBits(Ty);
9392
}
9493

9594
IRGenDebugInfo::IRGenDebugInfo(const IRGenOptions &Opts,
@@ -908,7 +907,7 @@ void IRGenDebugInfo::emitVariableDeclaration(
908907
auto *BB = Builder.GetInsertBlock();
909908
bool IsPiece = Storage.size() > 1;
910909
uint64_t SizeOfByte = CI.getTargetInfo().getCharWidth();
911-
unsigned VarSizeInBits = getSizeInBits(Var, DIRefMap);
910+
unsigned VarSizeInBits = getSizeInBits(Var);
912911

913912
// Running variables for the current/previous piece.
914913
unsigned SizeInBits = 0;
@@ -1025,7 +1024,7 @@ IRGenDebugInfo::createMemberType(DebugTypeInfo DbgTy, StringRef Name,
10251024
auto *DITy = DBuilder.createMemberType(
10261025
Scope, Name, File, 0, SizeOfByte * DbgTy.size.getValue(),
10271026
SizeOfByte * DbgTy.align.getValue(), OffsetInBits, Flags, Ty);
1028-
OffsetInBits += getSizeInBits(Ty, DIRefMap);
1027+
OffsetInBits += getSizeInBits(Ty);
10291028
OffsetInBits = llvm::alignTo(OffsetInBits,
10301029
SizeOfByte * DbgTy.align.getValue());
10311030
return DITy;

test/DebugInfo/DynamicSelf.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ class C {
1010
extension C {
1111
class func Factory() -> Self {
1212
// Currently we emit the static type C for r.
13-
// CHECK: !DILocalVariable(name: "r", {{.*}}line: [[@LINE+2]], type: ![[SELFTY:[0-9]+]])
14-
// CHECK: ![[SELFTY]] = !DIDerivedType(tag: DW_TAG_typedef, name: "_TtDC11DynamicSelf1C", {{.*}}, baseType: !"_TtC11DynamicSelf1C")
13+
// CHECK: ![[BASE:.*]] = !DICompositeType({{.*}}identifier: "_TtC11DynamicSelf1C"
14+
// CHECK: !DILocalVariable(name: "r",
15+
// CHECK-SAME: line: [[@LINE+4]], type: ![[SELFTY:[0-9]+]])
16+
// CHECK: ![[SELFTY]] = !DIDerivedType(tag: DW_TAG_typedef,
17+
// CHECK-SAME: name: "_TtDC11DynamicSelf1C",
18+
// CHECK-SAME: baseType: ![[BASE]])
1519
let r = self.init(number: 0)
1620
return r
1721
}

test/DebugInfo/Errors.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ func simple(_ placeholder: Int64) throws -> () {
1010
// CHECK: define {{.*}}void @_TF6Errors6simpleFzVs5Int64T_(i64, %swift.refcounted*, %swift.error**)
1111
// CHECK: call void @llvm.dbg.declare
1212
// CHECK: call void @llvm.dbg.declare({{.*}}, metadata ![[ERROR:[0-9]+]], metadata ![[DEREF:[0-9]+]])
13-
// CHECK: ![[ERROR]] = !DILocalVariable(name: "$error", arg: 3, {{.*}} type: !"_TtPs13ErrorProtocol_", flags: DIFlagArtificial)
13+
// CHECK: ![[ERROR]] = !DILocalVariable(name: "$error", arg: 3,
14+
// CHECK-SAME: type: ![[ERRTY:.*]], flags: DIFlagArtificial)
15+
// CHECK: ![[ERRTY]] = !DICompositeType({{.*}}identifier: "_TtPs13ErrorProtocol_"
1416
// CHECK: ![[DEREF]] = !DIExpression(DW_OP_deref)
1517
throw MyError.Simple
1618
}

test/DebugInfo/Imports.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ markUsed(basic.foo(1, 2))
2121

2222
// DWARF: .debug_info
2323
// DWARF: DW_TAG_module
24-
// DWARF: DW_AT_name {{.*}}"Swift"
24+
// DWARF: DW_AT_name {{.*}}"Foo"
2525
// DWARF: DW_AT_LLVM_include_path
2626
// DWARF: DW_TAG_module
27-
// DWARF: DW_AT_name {{.*}}"Foo"
27+
// DWARF: DW_AT_name {{.*}}"Swift"
2828
// DWARF: DW_AT_LLVM_include_path
2929
// DWARF: DW_TAG_module
3030
// DWARF: DW_AT_name {{.*}}"basic"

test/DebugInfo/archetype.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ protocol RandomAccessIndex : IntegerArithmetic {
99
static func uncheckedSubtract(_ lhs: Self, rhs: Self) -> (Distance, Bool)
1010
}
1111

12-
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "_TtTQQq_F9archetype16ExistentialTuple
13-
// CHECK-SAME: identifier: [[TT:".+"]])
1412
// archetype.ExistentialTuple <A : RandomAccessIndex, B>(x : A, y : A) -> B
1513
// CHECK: !DISubprogram(name: "ExistentialTuple", linkageName: "_TF9archetype16ExistentialTuple
1614
// CHECK-SAME: line: [[@LINE+2]]
@@ -19,8 +17,10 @@ func ExistentialTuple<T: RandomAccessIndex>(_ x: T, y: T) -> T.Distance {
1917
// (B, Swift.Bool)
2018
// CHECK: !DILocalVariable(name: "tmp"
2119
// CHECK-SAME: line: [[@LINE+2]]
22-
// CHECK-SAME: type: ![[TT]]
23-
let tmp : (T.Distance, Bool) = T.uncheckedSubtract(x, rhs: y)
20+
// CHECK-SAME: type: ![[TT:[0-9]+]]
21+
var tmp : (T.Distance, Bool) = T.uncheckedSubtract(x, rhs: y)
2422
return _overflowChecked((tmp.0, tmp.1))
2523
}
24+
// CHECK: ![[TT]] = !DICompositeType(tag: DW_TAG_structure_type,
25+
// CHECK-SAME: name: "_TtTQQq_F9archetype16ExistentialTuple
2626

test/DebugInfo/archetypes2.swift

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

55
class C<A> {
6-
// CHECK-DAG: !DILocalVariable(name: "x", arg: 1,{{.*}}line: [[@LINE+2]],{{.*}}type: !"_TtQq_C11archetypes21C"
7-
// CHECK-DAG: !DILocalVariable(name: "y", arg: 2,{{.*}}line: [[@LINE+1]],{{.*}}type: !"_TtQq_FC11archetypes21C3foo
6+
// CHECK: !DILocalVariable(name: "x", arg: 1,
7+
// CHECK-SAME: line: [[@LINE+9]],
8+
// CHECK-SAME: type: ![[A:[0-9]+]]
9+
// CHECK: ![[A]] = !DICompositeType(tag: DW_TAG_structure_type,
10+
// CHECK-SAME: identifier: "_TtQq_C11archetypes21C"
11+
// CHECK: !DILocalVariable(name: "y", arg: 2,
12+
// CHECK-SAME: line: [[@LINE+4]],
13+
// CHECK-SAME: type: ![[B:[0-9]+]]
14+
// CHECK: ![[B]] = !DICompositeType(tag: DW_TAG_structure_type,
15+
// CHECK-SAME: identifier: "_TtQq_FC11archetypes21C3foo
816
func foo<B>(_ x: A, y :B) {
917
markUsed("hello world")
1018
}

test/DebugInfo/attributes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// REQUIRES: objc_interop
44

5-
// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",{{.*}} line: [[@LINE+1]],{{.*}} runtimeLang: DW_LANG_Swift,{{.*}} identifier: [[TY0:"[^"]*"]])
5+
// CHECK-DAG: ![[TY0:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",{{.*}} line: [[@LINE+1]],{{.*}} runtimeLang: DW_LANG_Swift,
66
@objc class ObjCClass {
77
@IBAction func click(_: AnyObject?) -> () {}
88
}

test/DebugInfo/bound-namealiastype.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ func dispatch_queue_create() -> dispatch_queue_t! {
88
return nil
99
}
1010

11-
// CHECK: !DICompositeType(tag: DW_TAG_union_type,
12-
// CHECK-SAME: identifier: "_TtGSqa4main16dispatch_queue_t_"
1311
// CHECK: !DIGlobalVariable(name: "queue",
14-
// CHECK-SAME: line: [[@LINE+1]], type: !"_TtGSqa4main16dispatch_queue_t_"
12+
// CHECK-SAME: line: [[@LINE+3]], type: ![[T:[0-9]+]]
13+
// CHECK: ![[T]] = !DICompositeType(tag: DW_TAG_union_type,
14+
// CHECK-SAME: identifier: "_TtGSQa4main16dispatch_queue_t_"
1515
public var queue = dispatch_queue_create()

test/DebugInfo/byref-capture.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ func makeIncrementor(_ inc : Int64) -> () -> Int64
1010
// CHECK-SAME: metadata ![[EMPTY:.*]])
1111
// CHECK: ![[EMPTY]] = !DIExpression()
1212
// CHECK: ![[SUM_CAPTURE]] = !DILocalVariable(name: "sum", arg: 1,
13-
// CHECK-SAME: line: [[@LINE-8]], type: !"_TtRVs5Int64"
14-
// ^ inout type.
13+
// CHECK-SAME: line: [[@LINE-8]], type: ![[INOUTTY:[0-9]+]]
14+
// CHECK: ![[INOUTTY]] = !DICompositeType({{.*}}identifier: "_TtRVs5Int64"
15+
// ^ inout type.
1516
sum += inc
1617
return sum
1718
}

test/DebugInfo/enum.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ enum Either {
1010
// CHECK-SAME: line: [[@LINE-3]],
1111
// CHECK-SAME: size: {{328|168}},
1212
}
13+
// CHECK: ![[INT:.*]] = !DICompositeType({{.*}}identifier: "_TtSi"
1314
let E : Either = .Neither;
1415

1516
// CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "Color",
@@ -19,8 +20,9 @@ let E : Either = .Neither;
1920
enum Color : UInt64 {
2021
// This is effectively a 2-bit bitfield:
2122
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "Red"
22-
// CHECK-SAME: baseType: !"_TtVs6UInt64"
23+
// CHECK-SAME: baseType: ![[UINT64:[0-9]+]]
2324
// CHECK-SAME: size: 8, align: 8{{[,)]}}
25+
// CHECK: ![[UINT64]] = !DICompositeType({{.*}}identifier: "_TtVs6UInt64"
2426
case Red, Green, Blue
2527
}
2628

@@ -30,11 +32,12 @@ enum Color : UInt64 {
3032
// CHECK-SAME: identifier: "_TtO4enum12MaybeIntPair"
3133
enum MaybeIntPair {
3234
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "none"
33-
// CHECK-SAME: baseType: !"_TtSi", align: 8{{[,)]}}
35+
// CHECK-SAME: baseType: ![[INT]], align: 8{{[,)]}}
3436
case none
3537
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "just"
36-
// CHECK-SAME: baseType: !"_TtTVs5Int64S__"
38+
// CHECK-SAME: baseType: ![[INTTUP:[0-9]+]]
3739
// CHECK-SAME: size: 128, align: 64{{[,)]}}
40+
// CHECK: ![[INTTUP]] = !DICompositeType({{.*}}identifier: "_TtTVs5Int64S__"
3841
case just(Int64, Int64)
3942
}
4043

@@ -76,10 +79,11 @@ public enum Tuple<P> {
7679

7780
func bar<T>(_ x : Tuple<T>) -> Tuple<T> { return x }
7881

82+
// CHECK: ![[LIST:.*]] = !DICompositeType({{.*}}identifier: "_TtGO4enum4ListQq_S0__"
7983
public enum List<T> {
8084
indirect case Tail(List, T)
8185
case End
8286

83-
// CHECK: !DILocalVariable(name: "self", arg: 1, {{.*}} line: [[@LINE+1]], type: !"_TtGO4enum4ListQq_S0__", flags: DIFlagArtificial)
87+
// CHECK: !DILocalVariable(name: "self", arg: 1, {{.*}} line: [[@LINE+1]], type: ![[LIST]], flags: DIFlagArtificial)
8488
func fooMyList() {}
8589
}

0 commit comments

Comments
 (0)