Skip to content

Commit 5d61e72

Browse files
committed
[IRGen] Add some PrettyStackTraces for metadata emission
1 parent 6dfff66 commit 5d61e72

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

lib/IRGen/GenClass.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2101,6 +2101,7 @@ namespace {
21012101
llvm::Constant *irgen::emitClassPrivateData(IRGenModule &IGM,
21022102
ClassDecl *cls) {
21032103
assert(IGM.ObjCInterop && "emitting RO-data outside of interop mode");
2104+
PrettyStackTraceDecl stackTraceRAII("emitting ObjC metadata for", cls);
21042105
SILType selfType = getSelfType(cls);
21052106
auto &classTI = IGM.getTypeInfo(selfType).as<ClassTypeInfo>();
21062107

@@ -2121,6 +2122,7 @@ irgen::emitClassPrivateDataFields(IRGenModule &IGM,
21212122
ConstantStructBuilder &init,
21222123
ClassDecl *cls) {
21232124
assert(IGM.ObjCInterop && "emitting RO-data outside of interop mode");
2125+
PrettyStackTraceDecl stackTraceRAII("emitting ObjC metadata for", cls);
21242126

21252127
SILType selfType = getSelfType(cls);
21262128
auto &classTI = IGM.getTypeInfo(selfType).as<ClassTypeInfo>();
@@ -2157,15 +2159,16 @@ llvm::Constant *irgen::emitCategoryData(IRGenModule &IGM,
21572159
ClassDecl *cls = ext->getAsClassOrClassExtensionContext();
21582160
assert(cls && "generating category metadata for a non-class extension");
21592161

2162+
PrettyStackTraceDecl stackTraceRAII("emitting ObjC metadata for", ext);
21602163
ClassDataBuilder builder(IGM, cls, ext);
2161-
21622164
return builder.emitCategory();
21632165
}
21642166

21652167
/// Emit the metadata for an ObjC protocol.
21662168
llvm::Constant *irgen::emitObjCProtocolData(IRGenModule &IGM,
21672169
ProtocolDecl *proto) {
21682170
assert(proto->isObjC() && "not an objc protocol");
2171+
PrettyStackTraceDecl stackTraceRAII("emitting ObjC metadata for", proto);
21692172
ClassDataBuilder builder(IGM, proto);
21702173
return builder.emitProtocol();
21712174
}

lib/IRGen/GenMeta.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "swift/AST/Decl.h"
2323
#include "swift/AST/Attr.h"
2424
#include "swift/AST/IRGenOptions.h"
25+
#include "swift/AST/PrettyStackTrace.h"
2526
#include "swift/AST/SubstitutionMap.h"
2627
#include "swift/AST/Types.h"
2728
#include "swift/ClangImporter/ClangModule.h"
@@ -2730,6 +2731,7 @@ static void emitObjCClassSymbol(IRGenModule &IGM,
27302731
void irgen::emitClassMetadata(IRGenModule &IGM, ClassDecl *classDecl,
27312732
const ClassLayout &fieldLayout) {
27322733
assert(!classDecl->isForeign());
2734+
PrettyStackTraceDecl stackTraceRAII("emitting metadata for", classDecl);
27332735

27342736
emitFieldOffsetGlobals(IGM, classDecl, fieldLayout);
27352737

@@ -3185,6 +3187,7 @@ namespace {
31853187

31863188
/// Emit the type metadata or metadata template for a struct.
31873189
void irgen::emitStructMetadata(IRGenModule &IGM, StructDecl *structDecl) {
3190+
PrettyStackTraceDecl stackTraceRAII("emitting metadata for", structDecl);
31883191
ConstantInitBuilder initBuilder(IGM);
31893192
auto init = initBuilder.beginStruct();
31903193
init.setPacked(true);
@@ -3401,6 +3404,7 @@ namespace {
34013404
} // end anonymous namespace
34023405

34033406
void irgen::emitEnumMetadata(IRGenModule &IGM, EnumDecl *theEnum) {
3407+
PrettyStackTraceDecl stackTraceRAII("emitting metadata for", theEnum);
34043408
ConstantInitBuilder initBuilder(IGM);
34053409
auto init = initBuilder.beginStruct();
34063410
init.setPacked(true);
@@ -3837,6 +3841,8 @@ SpecialProtocol irgen::getSpecialProtocolID(ProtocolDecl *P) {
38373841
/// the protocol descriptor, and for ObjC interop, references to the descriptor
38383842
/// that the ObjC runtime uses for uniquing.
38393843
void IRGenModule::emitProtocolDecl(ProtocolDecl *protocol) {
3844+
PrettyStackTraceDecl stackTraceRAII("emitting metadata for", protocol);
3845+
38403846
// Emit remote reflection metadata for the protocol.
38413847
emitFieldMetadataRecord(protocol);
38423848

lib/IRGen/GenProto.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "swift/AST/Decl.h"
3434
#include "swift/AST/GenericEnvironment.h"
3535
#include "swift/AST/IRGenOptions.h"
36+
#include "swift/AST/PrettyStackTrace.h"
3637
#include "swift/AST/SubstitutionMap.h"
3738
#include "swift/ClangImporter/ClangModule.h"
3839
#include "swift/IRGen/Linking.h"
@@ -2213,6 +2214,9 @@ void IRGenModule::emitSILWitnessTable(SILWitnessTable *wt) {
22132214
return;
22142215

22152216
auto *conf = wt->getConformance();
2217+
PrettyStackTraceType stackTraceRAII(Context, "emitting witness table for",
2218+
conf->getType());
2219+
PrettyStackTraceDecl stackTraceRAII2("...conforming to", conf->getProtocol());
22162220

22172221
// Build the witnesses.
22182222
ConstantInitBuilder builder(*this);

0 commit comments

Comments
 (0)