@@ -1253,6 +1253,55 @@ llvm::DIType *IRGenDebugInfo::createDoublePointerSizedStruct(
1253
1253
llvm::dwarf::DW_LANG_Swift, nullptr , MangledName);
1254
1254
}
1255
1255
1256
+ llvm::DIType *
1257
+ IRGenDebugInfo::createFunctionPointer (DebugTypeInfo DbgTy, llvm::DIScope *Scope,
1258
+ unsigned SizeInBits, unsigned AlignInBits,
1259
+ unsigned Flags, StringRef MangledName) {
1260
+ auto FwdDecl = llvm::TempDINode (DBuilder.createReplaceableCompositeType (
1261
+ llvm::dwarf::DW_TAG_subroutine_type, MangledName, Scope, MainFile, 0 ,
1262
+ llvm::dwarf::DW_LANG_Swift, SizeInBits, AlignInBits, Flags, MangledName));
1263
+
1264
+ auto TH = llvm::TrackingMDNodeRef (FwdDecl.get ());
1265
+ DITypeCache[DbgTy.getType ()] = TH;
1266
+
1267
+ CanSILFunctionType FunTy;
1268
+ TypeBase *BaseTy = DbgTy.getType ();
1269
+ if (auto *SILFnTy = dyn_cast<SILFunctionType>(BaseTy))
1270
+ FunTy = CanSILFunctionType (SILFnTy);
1271
+ // FIXME: Handling of generic parameters in SIL type lowering is in flux.
1272
+ // DebugInfo doesn't appear to care about the generic context, so just
1273
+ // throw it away before lowering.
1274
+ else if (isa<GenericFunctionType>(BaseTy) ||
1275
+ isa<PolymorphicFunctionType>(BaseTy)) {
1276
+ auto *fTy = cast<AnyFunctionType>(BaseTy);
1277
+ auto *nongenericTy =
1278
+ FunctionType::get (fTy ->getInput (), fTy ->getResult (), fTy ->getExtInfo ());
1279
+
1280
+ FunTy = IGM.getLoweredType (nongenericTy).castTo <SILFunctionType>();
1281
+ } else
1282
+ FunTy = IGM.getLoweredType (BaseTy).castTo <SILFunctionType>();
1283
+ auto Params = createParameterTypes (FunTy, DbgTy.getDeclContext ());
1284
+
1285
+ auto FnTy = DBuilder.createSubroutineType (Params, Flags);
1286
+ llvm::DIType *DITy;
1287
+ if (FunTy->getRepresentation () == SILFunctionType::Representation::Thick) {
1288
+ if (SizeInBits == 2 * CI.getTargetInfo ().getPointerWidth (0 ))
1289
+ // This is a FunctionPairTy: { i8*, %swift.refcounted* }.
1290
+ DITy = createDoublePointerSizedStruct (Scope, MangledName, FnTy, MainFile,
1291
+ 0 , Flags, MangledName);
1292
+ else
1293
+ // This is a generic function as noted above.
1294
+ DITy = createOpaqueStruct (Scope, MangledName, MainFile, 0 , SizeInBits,
1295
+ AlignInBits, Flags, MangledName);
1296
+ } else {
1297
+ assert (SizeInBits == CI.getTargetInfo ().getPointerWidth (0 ));
1298
+ DITy = createPointerSizedStruct (Scope, MangledName, FnTy, MainFile, 0 ,
1299
+ Flags, MangledName);
1300
+ }
1301
+ DBuilder.replaceTemporary (std::move (FwdDecl), DITy);
1302
+ return DITy;
1303
+ }
1304
+
1256
1305
llvm::DIType *
1257
1306
IRGenDebugInfo::createOpaqueStruct (llvm::DIScope *Scope, StringRef Name,
1258
1307
llvm::DIFile *File, unsigned Line,
@@ -1545,51 +1594,13 @@ llvm::DIType *IRGenDebugInfo::createType(DebugTypeInfo DbgTy,
1545
1594
case TypeKind::SILFunction:
1546
1595
case TypeKind::Function:
1547
1596
case TypeKind::PolymorphicFunction:
1548
- case TypeKind::GenericFunction: {
1549
- auto FwdDecl = llvm::TempDINode (DBuilder.createReplaceableCompositeType (
1550
- llvm::dwarf::DW_TAG_subroutine_type, MangledName, Scope, File, 0 ,
1551
- llvm::dwarf::DW_LANG_Swift, SizeInBits, AlignInBits, Flags,
1552
- MangledName));
1553
-
1554
- auto TH = llvm::TrackingMDNodeRef (FwdDecl.get ());
1555
- DITypeCache[DbgTy.getType ()] = TH;
1556
-
1557
- CanSILFunctionType FunTy;
1558
- if (auto *SILFnTy = dyn_cast<SILFunctionType>(BaseTy))
1559
- FunTy = CanSILFunctionType (SILFnTy);
1560
- // FIXME: Handling of generic parameters in SIL type lowering is in flux.
1561
- // DebugInfo doesn't appear to care about the generic context, so just
1562
- // throw it away before lowering.
1563
- else if (isa<GenericFunctionType>(BaseTy) ||
1564
- isa<PolymorphicFunctionType>(BaseTy)) {
1565
- auto *fTy = cast<AnyFunctionType>(BaseTy);
1566
- auto *nongenericTy = FunctionType::get (fTy ->getInput (), fTy ->getResult (),
1567
- fTy ->getExtInfo ());
1568
-
1569
- FunTy = IGM.getLoweredType (nongenericTy).castTo <SILFunctionType>();
1570
- } else
1571
- FunTy =
1572
- IGM.getLoweredType (BaseTy).castTo <SILFunctionType>();
1573
- auto Params = createParameterTypes (FunTy, DbgTy.getDeclContext ());
1574
-
1575
- auto FnTy = DBuilder.createSubroutineType (Params, Flags);
1576
- llvm::DIType *DITy;
1577
- if (FunTy->getRepresentation () == SILFunctionType::Representation::Thick) {
1578
- if (SizeInBits == 2 * CI.getTargetInfo ().getPointerWidth (0 ))
1579
- // This is a FunctionPairTy: { i8*, %swift.refcounted* }.
1580
- DITy = createDoublePointerSizedStruct (Scope, MangledName, FnTy,
1581
- MainFile, 0 , Flags, MangledName);
1582
- else
1583
- // This is a generic function as noted above.
1584
- DITy = createOpaqueStruct (Scope, MangledName, MainFile, 0 , SizeInBits,
1585
- AlignInBits, Flags, MangledName);
1586
- } else {
1587
- assert (SizeInBits == CI.getTargetInfo ().getPointerWidth (0 ));
1588
- DITy = createPointerSizedStruct (Scope, MangledName, FnTy, MainFile, 0 ,
1589
- Flags, MangledName);
1590
- }
1591
- DBuilder.replaceTemporary (std::move (FwdDecl), DITy);
1592
- return DITy;
1597
+ case TypeKind::GenericFunction: {
1598
+ if (Opts.DebugInfoKind > IRGenDebugInfoKind::ASTTypes)
1599
+ return createFunctionPointer (DbgTy, Scope, SizeInBits, AlignInBits, Flags,
1600
+ MangledName);
1601
+ else
1602
+ return createOpaqueStruct (Scope, MangledName, MainFile, 0 , SizeInBits,
1603
+ AlignInBits, Flags, MangledName);
1593
1604
}
1594
1605
1595
1606
case TypeKind::Enum: {
0 commit comments