diff --git a/compiler/codegen.cpp b/compiler/codegen.cpp index 52d451f57..49c7eef09 100644 --- a/compiler/codegen.cpp +++ b/compiler/codegen.cpp @@ -4426,8 +4426,10 @@ void codegenEntryPoints(ModulePtr module, bool importedExternals) { finalizeCtorsDtors(); - if (llvmDIBuilder != nullptr) + if (llvmDIBuilder != nullptr) { + materializeDebugInfoForTypes(); llvmDIBuilder->finalize(); + } constructorsCtx = nullptr; destructorsCtx = nullptr; diff --git a/compiler/types.cpp b/compiler/types.cpp index 420db96b7..fa7e2ab68 100644 --- a/compiler/types.cpp +++ b/compiler/types.cpp @@ -1677,4 +1677,21 @@ string typeName(TypePtr type) { typePrint(os, type); return string(os.str()); } + +void materializeDebugInfoForTypes() { + if (llvmDIBuilder == nullptr) + return; + + auto sweep = [](auto ®istry) { + for (auto &bucket : registry) + for (auto &t : bucket) + if (t->llType != nullptr && !t->defined) + llvmType(t.ptr()); + }; + + sweep(recordTypes); + sweep(tupleTypes); + sweep(unionTypes); + sweep(variantTypes); +} } // namespace ceramic diff --git a/compiler/types.hpp b/compiler/types.hpp index 81369d2f9..d1743d190 100644 --- a/compiler/types.hpp +++ b/compiler/types.hpp @@ -118,6 +118,8 @@ llvm::DIType *llvmTypeDebugInfo(const TypePtr &t); llvm::DIType *llvmVoidTypeDebugInfo(); +void materializeDebugInfoForTypes(); + size_t typeSize(TypePtr t); size_t typeAlignment(TypePtr t);