@@ -279,8 +279,16 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
279279 DebugTypeInfo DebugType,
280280 bool IsLocalToUnit,
281281 std::optional<SILLocation> Loc);
282+
283+ void emitArtificialVariable (IRGenFunction &IGF, llvm::Value *Metadata,
284+ StringRef Name, StringRef Identifier);
285+
282286 void emitTypeMetadata (IRGenFunction &IGF, llvm::Value *Metadata,
283- unsigned Depth, unsigned Index, StringRef Name);
287+ GenericTypeParamType *Type);
288+
289+ void emitWitnessTable (IRGenFunction &IGF, llvm::Value *Metadata,
290+ StringRef Name, ProtocolDecl *protocol);
291+
284292 void emitPackCountParameter (IRGenFunction &IGF, llvm::Value *Metadata,
285293 SILDebugVariable VarInfo);
286294
@@ -3904,9 +3912,10 @@ void IRGenDebugInfoImpl::emitGlobalVariableDeclaration(
39043912 Var->addDebugInfo (GV);
39053913}
39063914
3907- void IRGenDebugInfoImpl::emitTypeMetadata (IRGenFunction &IGF,
3908- llvm::Value *Metadata, unsigned Depth,
3909- unsigned Index, StringRef Name) {
3915+ void IRGenDebugInfoImpl::emitArtificialVariable (IRGenFunction &IGF,
3916+ llvm::Value *Metadata,
3917+ StringRef Name,
3918+ StringRef Identifier) {
39103919 if (Opts.DebugInfoLevel <= IRGenDebugInfoLevel::LineTables)
39113920 return ;
39123921
@@ -3915,23 +3924,44 @@ void IRGenDebugInfoImpl::emitTypeMetadata(IRGenFunction &IGF,
39153924 if (!DS || DS->getInlinedFunction ()->isTransparent ())
39163925 return ;
39173926
3918- llvm::SmallString<8 > Buf;
3919- static const char *Tau = SWIFT_UTF8 (" \u03C4 " );
3920- llvm::raw_svector_ostream OS (Buf);
3921- OS << ' $' << Tau << ' _' << Depth << ' _' << Index;
3922- uint64_t PtrWidthInBits = CI.getTargetInfo ().getPointerWidth (clang::LangAS::Default);
3927+ uint64_t PtrWidthInBits =
3928+ CI.getTargetInfo ().getPointerWidth (clang::LangAS::Default);
39233929 assert (PtrWidthInBits % 8 == 0 );
39243930 auto DbgTy = DebugTypeInfo::getTypeMetadata (
39253931 getMetadataType (Name)->getDeclaredInterfaceType ().getPointer (),
39263932 Size (PtrWidthInBits / 8 ),
39273933 Alignment (CI.getTargetInfo ().getPointerAlign (clang::LangAS::Default)));
3928- emitVariableDeclaration (IGF.Builder , Metadata, DbgTy, IGF.getDebugScope (),
3929- {}, {OS.str ().str (), 0 , false },
3930- // swift.type is already a pointer type,
3931- // having a shadow copy doesn't add another
3932- // layer of indirection.
3933- IGF.isAsync () ? CoroDirectValue : DirectValue,
3934- ArtificialValue);
3934+ emitVariableDeclaration (
3935+ IGF.Builder , Metadata, DbgTy, IGF.getDebugScope (), {},
3936+ {Identifier, 0 , false }, // swift.type is already a pointer type,
3937+ // having a shadow copy doesn't add another
3938+ // layer of indirection.
3939+ IGF.isAsync () ? CoroDirectValue : DirectValue, ArtificialValue);
3940+ }
3941+
3942+ void IRGenDebugInfoImpl::emitTypeMetadata (IRGenFunction &IGF,
3943+ llvm::Value *Metadata,
3944+ GenericTypeParamType *Type) {
3945+ llvm::SmallString<8 > Buf;
3946+ llvm::raw_svector_ostream OS (Buf);
3947+ OS << " $" << Type->getCanonicalName ().str ();
3948+ auto Name = Type->getName ().str ();
3949+
3950+ emitArtificialVariable (IGF, Metadata, Name, OS.str ());
3951+ }
3952+
3953+ void IRGenDebugInfoImpl::emitWitnessTable (IRGenFunction &IGF,
3954+ llvm::Value *Metadata, StringRef Name,
3955+ ProtocolDecl *protocol) {
3956+ llvm::SmallString<32 > Buf;
3957+ llvm::raw_svector_ostream OS (Buf);
3958+ DebugTypeInfo DbgTy (protocol->getDeclaredType ());
3959+ auto MangledName = getMangledName (DbgTy).Canonical ;
3960+ OS << " $WT" << Name << " $$" << MangledName;;
3961+ // Make sure this ID lives long enough.
3962+ auto Id = IGF.getSwiftModule ()->getASTContext ().getIdentifier (OS.str ());
3963+
3964+ emitArtificialVariable (IGF, Metadata, Name, Id.str ());
39353965}
39363966
39373967void IRGenDebugInfoImpl::emitPackCountParameter (IRGenFunction &IGF,
@@ -4070,10 +4100,15 @@ void IRGenDebugInfo::emitGlobalVariableDeclaration(
40704100}
40714101
40724102void IRGenDebugInfo::emitTypeMetadata (IRGenFunction &IGF, llvm::Value *Metadata,
4073- unsigned Depth, unsigned Index,
4074- StringRef Name) {
4103+ GenericTypeParamType *Type) {
40754104 static_cast <IRGenDebugInfoImpl *>(this )->emitTypeMetadata (IGF, Metadata,
4076- Depth, Index, Name);
4105+ Type);
4106+ }
4107+
4108+ void IRGenDebugInfo::emitWitnessTable (IRGenFunction &IGF, llvm::Value *Metadata,
4109+ StringRef Name, ProtocolDecl *protocol) {
4110+ static_cast <IRGenDebugInfoImpl *>(this )->emitWitnessTable (IGF, Metadata, Name,
4111+ protocol);
40774112}
40784113
40794114void IRGenDebugInfo::emitPackCountParameter (IRGenFunction &IGF,
0 commit comments