Skip to content

Commit 5d8dfde

Browse files
committed
[NFC] IRGen: Added debugging info.
In debug builds, provide some context when an archetype fails to be found.
1 parent 195046a commit 5d8dfde

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lib/IRGen/GenArchetype.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "IRGenDebugInfo.h"
4949
#include "IRGenFunction.h"
5050
#include "IRGenModule.h"
51+
#include "LocalTypeData.h"
5152
#include "MetadataRequest.h"
5253
#include "Outlining.h"
5354
#include "ProtocolInfo.h"
@@ -75,6 +76,25 @@ irgen::emitArchetypeTypeMetadataRef(IRGenFunction &IGF,
7576
return emitOpaqueTypeMetadataRef(IGF, opaque, request);
7677
}
7778

79+
#ifndef NDEBUG
80+
if (!archetype->getParent()) {
81+
llvm::errs() << "Metadata for archetype not bound in function.\n"
82+
<< " The metadata could be missing entirely because it needs "
83+
"to be passed to the function.\n"
84+
<< " Or the metadata is present and not bound in which case "
85+
"setScopedLocalTypeMetadata or similar must be called.\n";
86+
llvm::errs() << "Archetype without metadata: " << archetype << "\n";
87+
archetype->dump(llvm::errs());
88+
llvm::errs() << "Function:\n";
89+
IGF.CurFn->print(llvm::errs());
90+
if (auto localTypeData = IGF.getLocalTypeData()) {
91+
llvm::errs() << "LocalTypeData:\n";
92+
localTypeData->dump();
93+
} else {
94+
llvm::errs() << "No LocalTypeDataCache for this function!\n";
95+
}
96+
}
97+
#endif
7898
// If there's no local or opaque metadata, it must be a nested type.
7999
assert(archetype->getParent() && "Not a nested archetype");
80100

lib/IRGen/IRGenFunction.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,9 @@ class IRGenFunction {
792792
llvm::Value *getDynamicSelfMetadata();
793793
void setDynamicSelfMetadata(CanType selfBaseTy, bool selfIsExact,
794794
llvm::Value *value, DynamicSelfKind kind);
795+
#ifndef NDEBUG
796+
LocalTypeDataCache const *getLocalTypeData() { return LocalTypeData; }
797+
#endif
795798

796799
private:
797800
LocalTypeDataCache &getOrCreateLocalTypeData();

0 commit comments

Comments
 (0)