Skip to content

[IRGen] Add some PrettyStackTraces for metadata emission #18727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/IRGen/GenClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2101,6 +2101,7 @@ namespace {
llvm::Constant *irgen::emitClassPrivateData(IRGenModule &IGM,
ClassDecl *cls) {
assert(IGM.ObjCInterop && "emitting RO-data outside of interop mode");
PrettyStackTraceDecl stackTraceRAII("emitting ObjC metadata for", cls);
SILType selfType = getSelfType(cls);
auto &classTI = IGM.getTypeInfo(selfType).as<ClassTypeInfo>();

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

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

PrettyStackTraceDecl stackTraceRAII("emitting ObjC metadata for", ext);
ClassDataBuilder builder(IGM, cls, ext);

return builder.emitCategory();
}

/// Emit the metadata for an ObjC protocol.
llvm::Constant *irgen::emitObjCProtocolData(IRGenModule &IGM,
ProtocolDecl *proto) {
assert(proto->isObjC() && "not an objc protocol");
PrettyStackTraceDecl stackTraceRAII("emitting ObjC metadata for", proto);
ClassDataBuilder builder(IGM, proto);
return builder.emitProtocol();
}
Expand Down
6 changes: 6 additions & 0 deletions lib/IRGen/GenMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "swift/AST/Decl.h"
#include "swift/AST/Attr.h"
#include "swift/AST/IRGenOptions.h"
#include "swift/AST/PrettyStackTrace.h"
#include "swift/AST/SubstitutionMap.h"
#include "swift/AST/Types.h"
#include "swift/ClangImporter/ClangModule.h"
Expand Down Expand Up @@ -2730,6 +2731,7 @@ static void emitObjCClassSymbol(IRGenModule &IGM,
void irgen::emitClassMetadata(IRGenModule &IGM, ClassDecl *classDecl,
const ClassLayout &fieldLayout) {
assert(!classDecl->isForeign());
PrettyStackTraceDecl stackTraceRAII("emitting metadata for", classDecl);

emitFieldOffsetGlobals(IGM, classDecl, fieldLayout);

Expand Down Expand Up @@ -3185,6 +3187,7 @@ namespace {

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

void irgen::emitEnumMetadata(IRGenModule &IGM, EnumDecl *theEnum) {
PrettyStackTraceDecl stackTraceRAII("emitting metadata for", theEnum);
ConstantInitBuilder initBuilder(IGM);
auto init = initBuilder.beginStruct();
init.setPacked(true);
Expand Down Expand Up @@ -3837,6 +3841,8 @@ SpecialProtocol irgen::getSpecialProtocolID(ProtocolDecl *P) {
/// the protocol descriptor, and for ObjC interop, references to the descriptor
/// that the ObjC runtime uses for uniquing.
void IRGenModule::emitProtocolDecl(ProtocolDecl *protocol) {
PrettyStackTraceDecl stackTraceRAII("emitting metadata for", protocol);

// Emit remote reflection metadata for the protocol.
emitFieldMetadataRecord(protocol);

Expand Down
4 changes: 4 additions & 0 deletions lib/IRGen/GenProto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "swift/AST/Decl.h"
#include "swift/AST/GenericEnvironment.h"
#include "swift/AST/IRGenOptions.h"
#include "swift/AST/PrettyStackTrace.h"
#include "swift/AST/SubstitutionMap.h"
#include "swift/ClangImporter/ClangModule.h"
#include "swift/IRGen/Linking.h"
Expand Down Expand Up @@ -2213,6 +2214,9 @@ void IRGenModule::emitSILWitnessTable(SILWitnessTable *wt) {
return;

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

// Build the witnesses.
ConstantInitBuilder builder(*this);
Expand Down