@@ -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
- unsigned Depth, unsigned Index, StringRef Name);
287
+ GenericTypeParamType *Type);
288
+
289
+ void emitWitnessTable (IRGenFunction &IGF, llvm::Value *Metadata,
290
+ StringRef Name, ProtocolDecl *protocol);
291
+
284
292
void emitPackCountParameter (IRGenFunction &IGF, llvm::Value *Metadata,
285
293
SILDebugVariable VarInfo);
286
294
@@ -3904,9 +3912,10 @@ void IRGenDebugInfoImpl::emitGlobalVariableDeclaration(
3904
3912
Var->addDebugInfo (GV);
3905
3913
}
3906
3914
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) {
3910
3919
if (Opts.DebugInfoLevel <= IRGenDebugInfoLevel::LineTables)
3911
3920
return ;
3912
3921
@@ -3915,23 +3924,44 @@ void IRGenDebugInfoImpl::emitTypeMetadata(IRGenFunction &IGF,
3915
3924
if (!DS || DS->getInlinedFunction ()->isTransparent ())
3916
3925
return ;
3917
3926
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);
3923
3929
assert (PtrWidthInBits % 8 == 0 );
3924
3930
auto DbgTy = DebugTypeInfo::getTypeMetadata (
3925
3931
getMetadataType (Name)->getDeclaredInterfaceType ().getPointer (),
3926
3932
Size (PtrWidthInBits / 8 ),
3927
3933
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 ());
3935
3965
}
3936
3966
3937
3967
void IRGenDebugInfoImpl::emitPackCountParameter (IRGenFunction &IGF,
@@ -4070,10 +4100,15 @@ void IRGenDebugInfo::emitGlobalVariableDeclaration(
4070
4100
}
4071
4101
4072
4102
void IRGenDebugInfo::emitTypeMetadata (IRGenFunction &IGF, llvm::Value *Metadata,
4073
- unsigned Depth, unsigned Index,
4074
- StringRef Name) {
4103
+ GenericTypeParamType *Type) {
4075
4104
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);
4077
4112
}
4078
4113
4079
4114
void IRGenDebugInfo::emitPackCountParameter (IRGenFunction &IGF,
0 commit comments