Skip to content

Commit c6d42db

Browse files
committed
Adapt to MD* => DI* renaming of debug info types
Applied the upgrade script from r236120 (LLVM) and r236121 (CFE). This is the final step of rdar://problem/20434113. Swift SVN r27925
1 parent be05690 commit c6d42db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+452
-461
lines changed

lib/IRGen/IRGenDebugInfo.cpp

+103-108
Large diffs are not rendered by default.

lib/IRGen/IRGenDebugInfo.h

+47-51
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ class IRGenDebugInfo {
9090
llvm::SmallString<256> MainFilename;
9191
llvm::BumpPtrAllocator DebugInfoNames;
9292
StringRef CWDName; /// The current working directory.
93-
llvm::MDCompileUnit *TheCU = nullptr; /// The current compilation unit.
94-
llvm::MDFile *MainFile = nullptr; /// The main file.
93+
llvm::DICompileUnit *TheCU = nullptr; /// The current compilation unit.
94+
llvm::DIFile *MainFile = nullptr; /// The main file.
9595
llvm::MDModule *MainModule = nullptr; /// The current module.
9696
llvm::MDNode *EntryPointFn; /// Scope of SWIFT_ENTRY_POINT_FUNCTION.
9797
TypeAliasDecl *MetadataTypeDecl; /// The type decl for swift.type.
98-
llvm::MDType *InternalType; /// Catch-all type for opaque internal types.
98+
llvm::DIType *InternalType; /// Catch-all type for opaque internal types.
9999

100100
Location LastDebugLoc; /// The last location that was emitted.
101101
SILDebugScope *LastScope; /// The scope of that last location.
@@ -172,14 +172,13 @@ class IRGenDebugInfo {
172172
/// \param Fn The IR representation of the function.
173173
/// \param Rep The calling convention of the function.
174174
/// \param Ty The signature of the function.
175-
llvm::MDSubprogram *emitFunction(SILModule &SILMod, SILDebugScope *DS,
175+
llvm::DISubprogram *emitFunction(SILModule &SILMod, SILDebugScope *DS,
176176
llvm::Function *Fn,
177177
SILFunctionTypeRepresentation Rep,
178-
SILType Ty,
179-
DeclContext *DeclCtx = nullptr);
178+
SILType Ty, DeclContext *DeclCtx = nullptr);
180179

181180
/// Emit debug info for a given SIL function.
182-
llvm::MDSubprogram *emitFunction(SILFunction &SILFn, llvm::Function *Fn);
181+
llvm::DISubprogram *emitFunction(SILFunction &SILFn, llvm::Function *Fn);
183182

184183
/// Convenience function useful for functions without any source
185184
/// location. Internally calls emitFunction, emits a debug
@@ -220,8 +219,8 @@ class IRGenDebugInfo {
220219

221220
/// Emit a dbg.declare or dbg.value intrinsic, depending on Storage.
222221
void emitDbgIntrinsic(llvm::BasicBlock *BB, llvm::Value *Storage,
223-
llvm::MDLocalVariable *Var, llvm::MDExpression *Expr,
224-
unsigned Line, unsigned Col, llvm::MDLocalScope *Scope,
222+
llvm::DILocalVariable *Var, llvm::DIExpression *Expr,
223+
unsigned Line, unsigned Col, llvm::DILocalScope *Scope,
225224
SILDebugScope *DS);
226225

227226
/// Create debug metadata for a global variable.
@@ -251,65 +250,62 @@ class IRGenDebugInfo {
251250
void createImportedModule(StringRef Name, StringRef MangledPrefix,
252251
llvm::MDModule *Module, unsigned Line);
253252

254-
llvm::MDType *createType(DebugTypeInfo DbgTy, StringRef MangledName,
255-
llvm::MDScope *Scope, llvm::MDFile *File);
256-
llvm::MDType *getOrCreateType(DebugTypeInfo DbgTy);
257-
llvm::MDScope *getOrCreateScope(SILDebugScope *DS);
258-
llvm::MDScope *getOrCreateContext(DeclContext *DC);
253+
llvm::DIType *createType(DebugTypeInfo DbgTy, StringRef MangledName,
254+
llvm::DIScope *Scope, llvm::DIFile *File);
255+
llvm::DIType *getOrCreateType(DebugTypeInfo DbgTy);
256+
llvm::DIScope *getOrCreateScope(SILDebugScope *DS);
257+
llvm::DIScope *getOrCreateContext(DeclContext *DC);
259258
llvm::MDNode *createInlinedAt(SILDebugScope *Scope);
260259

261260
StringRef getCurrentDirname();
262-
llvm::MDFile *getOrCreateFile(const char *Filename);
263-
llvm::MDType *getOrCreateDesugaredType(Type Ty, DebugTypeInfo DTI);
261+
llvm::DIFile *getOrCreateFile(const char *Filename);
262+
llvm::DIType *getOrCreateDesugaredType(Type Ty, DebugTypeInfo DTI);
264263
StringRef getName(const FuncDecl &FD);
265264
StringRef getName(SILLocation L);
266265
StringRef getMangledName(TypeAliasDecl *Decl);
267266
StringRef getMangledName(DebugTypeInfo DTI);
268-
llvm::MDTypeRefArray createParameterTypes(CanSILFunctionType FnTy,
267+
llvm::DITypeRefArray createParameterTypes(CanSILFunctionType FnTy,
269268
DeclContext *DeclCtx);
270-
llvm::MDTypeRefArray createParameterTypes(SILType SILTy,
269+
llvm::DITypeRefArray createParameterTypes(SILType SILTy,
271270
DeclContext *DeclCtx);
272271
void createParameterType(llvm::SmallVectorImpl<llvm::Metadata *> &Parameters,
273272
SILType CanTy, DeclContext *DeclCtx);
274-
llvm::DebugNodeArray getTupleElements(TupleType *TupleTy,
275-
llvm::MDScope *Scope,
276-
llvm::MDFile *File, unsigned Flags,
277-
DeclContext *DeclContext,
278-
unsigned &SizeInBits);
279-
llvm::MDFile *getFile(llvm::MDScope *Scope);
280-
llvm::MDModule *getOrCreateModule(llvm::MDScope *Parent, std::string Name,
281-
llvm::MDFile *File);
282-
llvm::MDScope *getModule(StringRef MangledName);
283-
llvm::DebugNodeArray getStructMembers(NominalTypeDecl *D, Type BaseTy,
284-
llvm::MDScope *Scope,
285-
llvm::MDFile *File,
286-
unsigned Flags, unsigned &SizeInBits);
287-
llvm::MDCompositeType *
273+
llvm::DINodeArray getTupleElements(TupleType *TupleTy, llvm::DIScope *Scope,
274+
llvm::DIFile *File, unsigned Flags,
275+
DeclContext *DeclContext,
276+
unsigned &SizeInBits);
277+
llvm::DIFile *getFile(llvm::DIScope *Scope);
278+
llvm::MDModule *getOrCreateModule(llvm::DIScope *Parent, std::string Name,
279+
llvm::DIFile *File);
280+
llvm::DIScope *getModule(StringRef MangledName);
281+
llvm::DINodeArray getStructMembers(NominalTypeDecl *D, Type BaseTy,
282+
llvm::DIScope *Scope, llvm::DIFile *File,
283+
unsigned Flags, unsigned &SizeInBits);
284+
llvm::DICompositeType *
288285
createStructType(DebugTypeInfo DbgTy, NominalTypeDecl *Decl, Type BaseTy,
289-
llvm::MDScope *Scope, llvm::MDFile *File, unsigned Line,
286+
llvm::DIScope *Scope, llvm::DIFile *File, unsigned Line,
290287
unsigned SizeInBits, unsigned AlignInBits, unsigned Flags,
291-
llvm::MDType *DerivedFrom, unsigned RuntimeLang,
288+
llvm::DIType *DerivedFrom, unsigned RuntimeLang,
292289
StringRef UniqueID);
293-
llvm::MDDerivedType *createMemberType(DebugTypeInfo DTI, StringRef Name,
290+
llvm::DIDerivedType *createMemberType(DebugTypeInfo DTI, StringRef Name,
294291
unsigned &OffsetInBits,
295-
llvm::MDScope *Scope,
296-
llvm::MDFile *File, unsigned Flags);
297-
llvm::DebugNodeArray getEnumElements(DebugTypeInfo DbgTy, EnumDecl *D,
298-
llvm::MDScope *Scope, llvm::MDFile *File,
299-
unsigned Flags);
300-
llvm::MDCompositeType *createEnumType(DebugTypeInfo DbgTy, EnumDecl *Decl,
292+
llvm::DIScope *Scope,
293+
llvm::DIFile *File, unsigned Flags);
294+
llvm::DINodeArray getEnumElements(DebugTypeInfo DbgTy, EnumDecl *D,
295+
llvm::DIScope *Scope, llvm::DIFile *File,
296+
unsigned Flags);
297+
llvm::DICompositeType *createEnumType(DebugTypeInfo DbgTy, EnumDecl *Decl,
301298
StringRef MangledName,
302-
llvm::MDScope *Scope,
303-
llvm::MDFile *File, unsigned Line,
299+
llvm::DIScope *Scope,
300+
llvm::DIFile *File, unsigned Line,
304301
unsigned Flags);
305-
llvm::MDType *createPointerSizedStruct(llvm::MDScope *Scope,
306-
StringRef Name, llvm::MDFile *File,
307-
unsigned Line, unsigned Flags,
308-
StringRef MangledName);
309-
llvm::MDType *createPointerSizedStruct(llvm::MDScope *Scope,
310-
StringRef Name, llvm::MDType *PointeeTy,
311-
llvm::MDFile *File, unsigned Line,
312-
unsigned Flags, StringRef MangledName);
302+
llvm::DIType *createPointerSizedStruct(llvm::DIScope *Scope, StringRef Name,
303+
llvm::DIFile *File, unsigned Line,
304+
unsigned Flags, StringRef MangledName);
305+
llvm::DIType *createPointerSizedStruct(llvm::DIScope *Scope, StringRef Name,
306+
llvm::DIType *PointeeTy,
307+
llvm::DIFile *File, unsigned Line,
308+
unsigned Flags, StringRef MangledName);
313309
uint64_t getSizeOfBasicType(DebugTypeInfo DbgTy);
314310
TypeAliasDecl *getMetadataType();
315311
};

test/DebugInfo/Constructors.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend %s -emit-ir -g -o - | FileCheck %s
22
struct Foo {
33
// Allocating constructor - should have no line table info.
4-
// CHECK: !MDSubprogram(name: "init", linkageName: "_TFV12Constructors3FooCfMS0_FT1xSi_S0_",
4+
// CHECK: !DISubprogram(name: "init", linkageName: "_TFV12Constructors3FooCfMS0_FT1xSi_S0_",
55
// CHECK-SAME: line: [[@LINE+3]]
66
// CHECK-NOT: scopeLine: 0
77
// CHECK-SAME: isDefinition: true

test/DebugInfo/Destructors.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend %s -emit-ir -g -o - | FileCheck %s
22

33
class Foo {
4-
// CHECK: !MDSubprogram(name: "deinit", linkageName: "_TFC11Destructors3FooD"
4+
// CHECK: !DISubprogram(name: "deinit", linkageName: "_TFC11Destructors3FooD"
55
// CHECK-SAME: line: [[@LINE-2]]
66
// CHECK-SAME: isDefinition: true
77
var x : Int

test/DebugInfo/DynamicSelf.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class C {
1010
extension C {
1111
class func Factory() -> Self {
1212
// Currently we emit the static type C for r.
13-
// CHECK: !MDLocalVariable(tag: DW_TAG_auto_variable, name: "r", {{.*}}line: [[@LINE+1]]
13+
// CHECK: !DILocalVariable(tag: DW_TAG_auto_variable, name: "r", {{.*}}line: [[@LINE+1]]
1414
let r = self(number: 0)
1515
return r
1616
}

test/DebugInfo/Imports.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
// RUN: %target-swift-frontend -c -module-name Foo %s -I %t -g -o - | llvm-dwarfdump - | FileCheck --check-prefix=DWARF %s
66

77
// CHECK-DAG: ![[FOOMODULE:[0-9]+]] = !MDModule(name: "Foo"
8-
// CHECK-DAG: !MDImportedEntity(tag: DW_TAG_imported_module, scope: ![[THISFILE:[0-9]+]], entity: ![[FOOMODULE]]
9-
// CHECK-DAG: ![[THISFILE]] = !MDFile(filename: "Imports.swift", directory: "{{.*}}test/DebugInfo")
10-
// CHECK-DAG: ![[SWIFTFILE:[0-9]+]] = !MDFile(filename: "Swift.swiftmodule"
8+
// CHECK-DAG: !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[THISFILE:[0-9]+]], entity: ![[FOOMODULE]]
9+
// CHECK-DAG: ![[THISFILE]] = !DIFile(filename: "Imports.swift", directory: "{{.*}}test/DebugInfo")
10+
// CHECK-DAG: ![[SWIFTFILE:[0-9]+]] = !DIFile(filename: "Swift.swiftmodule"
1111
// CHECK-DAG: ![[SWIFTMODULE:[0-9]+]] = !MDModule(name: "Swift"
12-
// CHECK-DAG: !MDImportedEntity(tag: DW_TAG_imported_module, scope: ![[SWIFTFILE]], entity: ![[SWIFTMODULE]]
13-
// CHECK-DAG: ![[BASICFILE:[0-9]+]] = !MDFile(filename: "basic.swiftmodule"
12+
// CHECK-DAG: !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[SWIFTFILE]], entity: ![[SWIFTMODULE]]
13+
// CHECK-DAG: ![[BASICFILE:[0-9]+]] = !DIFile(filename: "basic.swiftmodule"
1414
// CHECK-DAG: ![[BASICMODULE:[0-9]+]] = !MDModule(name: "basic"
15-
// CHECK-DAG: !MDImportedEntity(tag: DW_TAG_imported_module, scope: ![[BASICFILE]], entity: ![[BASICMODULE]]
15+
// CHECK-DAG: !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[BASICFILE]], entity: ![[BASICMODULE]]
1616
import basic
1717
import typealias Swift.Optional
1818

test/DebugInfo/PrivateDiscriminator.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// Private discriminators should only be emitted for multi-file projects.
22

33
// RUN: %target-swift-frontend -emit-ir %s -g -o - | FileCheck --check-prefix=SINGLE %s
4-
// SINGLE-NOT: !MDCompileUnit({{.*}}-private-discriminator
4+
// SINGLE-NOT: !DICompileUnit({{.*}}-private-discriminator
55

66
// RUN: %target-swift-frontend %S/../Inputs/empty.swift -primary-file %s -emit-ir -g | FileCheck %s
7-
// CHECK: !MDCompileUnit({{.*}}flags: {{[^,]*}}-private-discriminator [[DISCRIMINATOR:_[A-Z0-9]+]]
7+
// CHECK: !DICompileUnit({{.*}}flags: {{[^,]*}}-private-discriminator [[DISCRIMINATOR:_[A-Z0-9]+]]
88

99
private class A {
1010
init(val : Int) { member = val }
1111
private let member : Int
12-
// CHECK: !MDSubprogram(name: "getMember"
12+
// CHECK: !DISubprogram(name: "getMember"
1313
// CHECK-SAME: linkageName: "{{[^"]*}}[[DISCRIMINATOR]]
1414
// CHECK-SAME: line: [[@LINE+2]]
1515
// CHECK-SAME: isLocal: true, isDefinition: true

test/DebugInfo/ProtocolContainer.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ class AClass : AProtocol {
1313
// CHECK-NEXT: entry:
1414
// CHECK-NEXT: %[[X:.*]] = alloca %P17ProtocolContainer9AProtocol_, align {{(4|8)}}
1515
// CHECK: call void @llvm.dbg.declare(metadata %P17ProtocolContainer9AProtocol_* %[[X]], metadata ![[XMD:.*]], metadata !{{[0-9]+}})
16-
// CHECK-NOT: !MDLocalVariable({{.*}} name: "x"
17-
// CHECK: ![[XMD]] = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "x", {{.*}}line: [[@LINE+2]]
18-
// CHECK-NOT: !MDLocalVariable({{.*}} name: "x"
16+
// CHECK-NOT: !DILocalVariable({{.*}} name: "x"
17+
// CHECK: ![[XMD]] = !DILocalVariable(tag: DW_TAG_arg_variable, name: "x", {{.*}}line: [[@LINE+2]]
18+
// CHECK-NOT: !DILocalVariable({{.*}} name: "x"
1919
func foo (var x : AProtocol) {
2020
x.print() // Set breakpoint here
2121
}

test/DebugInfo/accessors.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// RUN: %target-swift-frontend -primary-file %s -emit-ir -g -o - | FileCheck %s
22

33
// Verify that we generate appropriate names for accessors.
4-
// CHECK: !MDSubprogram(name: "x.get"
5-
// CHECK: !MDSubprogram(name: "x.set"
4+
// CHECK: !DISubprogram(name: "x.get"
5+
// CHECK: !DISubprogram(name: "x.set"
66

77
// Variable getter/setter
88
var _x : Int = 0

test/DebugInfo/anonymous.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend -primary-file %s -emit-ir -g -o - | FileCheck %s
22

33
// Don't crash when emitting debug info for anonymous variables.
4-
// CHECK: !MDLocalVariable({{.*}} name: "_"
4+
// CHECK: !DILocalVariable({{.*}} name: "_"
55
protocol F_ {
66
func successor() -> Self
77
}

test/DebugInfo/any.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
func main() {
44
// CHECK: call void @llvm.dbg.declare(metadata %"protocol<>"* {{.*}}, metadata ![[S:.*]], metadata !{{[0-9]+}}), !dbg ![[DBG:.*]]
5-
// CHECK: ![[S]] = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "s", {{.*}}line: [[@LINE+3]]
6-
// CHECK: ![[SCOPE:.*]] = distinct !MDLexicalBlock({{.*}}line: 3, column: 13)
7-
// CHECK: ![[DBG]] = !MDLocation(line: [[@LINE+1]], column: 6, scope: ![[SCOPE]])
5+
// CHECK: ![[S]] = !DILocalVariable(tag: DW_TAG_auto_variable, name: "s", {{.*}}line: [[@LINE+3]]
6+
// CHECK: ![[SCOPE:.*]] = distinct !DILexicalBlock({{.*}}line: 3, column: 13)
7+
// CHECK: ![[DBG]] = !DILocation(line: [[@LINE+1]], column: 6, scope: ![[SCOPE]])
88
var s : Any = "hello world"
99
var n : Any = 12
1010
var t : Any = (1,2)

test/DebugInfo/apple-types-accel.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// CHECK-DWARF-NEXT: AT_linkage_name( "_TtC4main3foo" )
1818

1919
// Verify the IR interface:
20-
// CHECK: !MDCompositeType(tag: DW_TAG_structure_type, name: "foo"
20+
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "foo"
2121
// CHECK-SAME: line: [[@LINE+2]]
2222
// CHECK-SAME: identifier: "_TtC4main3foo"
2323
class foo {

test/DebugInfo/archetype.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ protocol RandomAccessIndexType : IntegerArithmeticType {
99
static func uncheckedSubtract(lhs: Self, rhs: Self) -> (Distance, Bool)
1010
}
1111

12-
// CHECK: !MDCompositeType(tag: DW_TAG_structure_type, name: "_TtTQQq_F9archetype16ExistentialTuple
12+
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "_TtTQQq_F9archetype16ExistentialTuple
1313
// CHECK-SAME: identifier: [[TT:".+"]])
1414
// archetype.ExistentialTuple <A : RandomAccessIndexType, B>(x : A, y : A) -> B
15-
// CHECK: !MDSubprogram(name: "ExistentialTuple", linkageName: "_TF9archetype16ExistentialTuple
15+
// CHECK: !DISubprogram(name: "ExistentialTuple", linkageName: "_TF9archetype16ExistentialTuple
1616
// CHECK-SAME: line: [[@LINE+2]]
1717
// CHECK-SAME: isDefinition: true
1818
func ExistentialTuple<T: RandomAccessIndexType>(x: T, y: T) -> T.Distance {
1919
// (B, Swift.Bool)
20-
// CHECK: !MDLocalVariable(tag: DW_TAG_auto_variable, name: "tmp"
20+
// CHECK: !DILocalVariable(tag: DW_TAG_auto_variable, name: "tmp"
2121
// CHECK-SAME: line: [[@LINE+2]]
2222
// CHECK-SAME: type: ![[TT]]
2323
var tmp : (T.Distance, Bool) = T.uncheckedSubtract(x, rhs: y)

test/DebugInfo/archetypes2.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// RUN: %target-swift-frontend %s -emit-ir -verify -g -o - | FileCheck %s
22

33
class C<A> {
4-
// CHECK-DAG: ![[A:[0-9]+]] = !MDCompositeType(tag: DW_TAG_structure_type, name: "_TtQq_C11archetypes21C"
5-
// CHECK-DAG: ![[B:[0-9]+]] = !MDCompositeType(tag: DW_TAG_structure_type, name: "_TtQq_FC11archetypes21C3foo
6-
// CHECK-DAG: !MDLocalVariable(tag: DW_TAG_arg_variable, name: "x", {{.*}}line: [[@LINE+2]],{{.*}}type: ![[A]]
7-
// CHECK-DAG: !MDLocalVariable(tag: DW_TAG_arg_variable, name: "y", {{.*}}line: [[@LINE+1]],{{.*}}type: ![[B]]
4+
// CHECK-DAG: ![[A:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "_TtQq_C11archetypes21C"
5+
// CHECK-DAG: ![[B:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "_TtQq_FC11archetypes21C3foo
6+
// CHECK-DAG: !DILocalVariable(tag: DW_TAG_arg_variable, name: "x", {{.*}}line: [[@LINE+2]],{{.*}}type: ![[A]]
7+
// CHECK-DAG: !DILocalVariable(tag: DW_TAG_arg_variable, name: "y", {{.*}}line: [[@LINE+1]],{{.*}}type: ![[B]]
88
func foo <B> (var x : A, var y : B)
99
{
1010
println("hello world")

0 commit comments

Comments
 (0)