@@ -279,8 +279,16 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
279
279
DebugTypeInfo DebugType,
280
280
bool IsLocalToUnit,
281
281
std::optional<SILLocation> Loc);
282
+
283
+ void emitArtificialVariable (IRGenFunction &IGF, llvm::Value *Metadata,
284
+ StringRef Name, StringRef Identifier);
285
+
282
286
void emitTypeMetadata (IRGenFunction &IGF, llvm::Value *Metadata,
283
287
unsigned Depth, unsigned Index, StringRef Name);
288
+
289
+ void emitWitnessTable (IRGenFunction &IGF, llvm::Value *Metadata,
290
+ unsigned Depth, unsigned Index, ProtocolDecl *protocol);
291
+
284
292
void emitPackCountParameter (IRGenFunction &IGF, llvm::Value *Metadata,
285
293
SILDebugVariable VarInfo);
286
294
@@ -3700,9 +3708,10 @@ void IRGenDebugInfoImpl::emitGlobalVariableDeclaration(
3700
3708
Var->addDebugInfo (GV);
3701
3709
}
3702
3710
3703
- void IRGenDebugInfoImpl::emitTypeMetadata (IRGenFunction &IGF,
3704
- llvm::Value *Metadata, unsigned Depth,
3705
- unsigned Index, StringRef Name) {
3711
+ void IRGenDebugInfoImpl::emitArtificialVariable (IRGenFunction &IGF,
3712
+ llvm::Value *Metadata,
3713
+ StringRef Name,
3714
+ StringRef Identifier) {
3706
3715
if (Opts.DebugInfoLevel <= IRGenDebugInfoLevel::LineTables)
3707
3716
return ;
3708
3717
@@ -3711,23 +3720,45 @@ void IRGenDebugInfoImpl::emitTypeMetadata(IRGenFunction &IGF,
3711
3720
if (!DS || DS->getInlinedFunction ()->isTransparent ())
3712
3721
return ;
3713
3722
3714
- llvm::SmallString<8 > Buf;
3715
- static const char *Tau = SWIFT_UTF8 (" \u03C4 " );
3716
- llvm::raw_svector_ostream OS (Buf);
3717
- OS << ' $' << Tau << ' _' << Depth << ' _' << Index;
3718
- uint64_t PtrWidthInBits = CI.getTargetInfo ().getPointerWidth (clang::LangAS::Default);
3723
+ auto id = IGF.getSwiftModule ()->getASTContext ().getIdentifier (Name);
3724
+ uint64_t PtrWidthInBits =
3725
+ CI.getTargetInfo ().getPointerWidth (clang::LangAS::Default);
3719
3726
assert (PtrWidthInBits % 8 == 0 );
3720
3727
auto DbgTy = DebugTypeInfo::getTypeMetadata (
3721
- getMetadataType (Name )->getDeclaredInterfaceType ().getPointer (),
3728
+ getMetadataType (Identifier )->getDeclaredInterfaceType ().getPointer (),
3722
3729
Size (PtrWidthInBits / 8 ),
3723
3730
Alignment (CI.getTargetInfo ().getPointerAlign (clang::LangAS::Default)));
3724
- emitVariableDeclaration (IGF.Builder , Metadata, DbgTy, IGF.getDebugScope (),
3725
- {}, {OS.str ().str (), 0 , false },
3726
- // swift.type is already a pointer type,
3727
- // having a shadow copy doesn't add another
3728
- // layer of indirection.
3729
- IGF.isAsync () ? CoroDirectValue : DirectValue,
3730
- ArtificialValue);
3731
+ emitVariableDeclaration (
3732
+ IGF.Builder , Metadata, DbgTy, IGF.getDebugScope (), {},
3733
+ {id.str (), 0 , false }, // swift.type is already a pointer type,
3734
+ // having a shadow copy doesn't add another
3735
+ // layer of indirection.
3736
+ IGF.isAsync () ? CoroDirectValue : DirectValue, ArtificialValue);
3737
+ }
3738
+
3739
+ void IRGenDebugInfoImpl::emitTypeMetadata (IRGenFunction &IGF,
3740
+ llvm::Value *Metadata, unsigned Depth,
3741
+ unsigned Index, StringRef Name) {
3742
+ llvm::SmallString<8 > Buf;
3743
+ static const char *Tau = SWIFT_UTF8 (" \u03C4 " );
3744
+ llvm::raw_svector_ostream OS (Buf);
3745
+ OS << ' $' << Tau << ' _' << Depth << ' _' << Index;
3746
+
3747
+ emitArtificialVariable (IGF, Metadata, OS.str (), Name);
3748
+ }
3749
+
3750
+ void IRGenDebugInfoImpl::emitWitnessTable (IRGenFunction &IGF,
3751
+ llvm::Value *Metadata, unsigned Depth,
3752
+ unsigned Index,
3753
+ ProtocolDecl *protocol) {
3754
+ llvm::SmallString<64 > Buf;
3755
+ static const char *Tau = SWIFT_UTF8 (" \u03C4 " );
3756
+ llvm::raw_svector_ostream OS (Buf);
3757
+ DebugTypeInfo DbgTy (protocol->getInterfaceType ());
3758
+ auto MangledName = getMangledName (DbgTy);
3759
+ OS << " $WT_" << Tau << ' _' << Depth << ' _' << Index << " _" << MangledName;
3760
+
3761
+ emitArtificialVariable (IGF, Metadata, OS.str (), Buf.str ());
3731
3762
}
3732
3763
3733
3764
void IRGenDebugInfoImpl::emitPackCountParameter (IRGenFunction &IGF,
@@ -3872,6 +3903,13 @@ void IRGenDebugInfo::emitTypeMetadata(IRGenFunction &IGF, llvm::Value *Metadata,
3872
3903
Depth, Index, Name);
3873
3904
}
3874
3905
3906
+ void IRGenDebugInfo::emitWitnessTable (IRGenFunction &IGF, llvm::Value *Metadata,
3907
+ unsigned Depth, unsigned Index,
3908
+ ProtocolDecl *protocol) {
3909
+ static_cast <IRGenDebugInfoImpl *>(this )->emitWitnessTable (
3910
+ IGF, Metadata, Depth, Index, protocol);
3911
+ }
3912
+
3875
3913
void IRGenDebugInfo::emitPackCountParameter (IRGenFunction &IGF,
3876
3914
llvm::Value *Metadata,
3877
3915
SILDebugVariable VarInfo) {
0 commit comments