Skip to content

[llvm] prepare explicit template instantiations in llvm/DebugInfo for DLL export annotations #140785

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

andrurogerz
Copy link
Contributor

Purpose

This patch prepares the llvm/DebugInfo library for public interface annotations in support of an LLVM Windows DLL (shared library) build, tracked in #109483. The purpose of this patch is to make the upcoming codemod of this library more straight-forward. It is not expected to impact any functionality.

Overview

Adds declarations to the header files for two explicit specialized methods:

  • ContinuationRecordBuilder::writeMemberType
  • SimpleTypeSerializer::serialize

These specializations are already defined the corresponding implementation files:

This patch will not impact functionality, it just ensures they're exposed as part of the public ABI so they can be annotated for export in a subsequent patch.

Background

The LLVM Windows DLL effort is tracked in #109483. Additional context is provided in this discourse.

Validation

Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations:

  • Windows with MSVC
  • Windows with Clang
  • Linux with GCC
  • Linux with Clang
  • Darwin with Clang

@andrurogerz andrurogerz marked this pull request as ready for review May 20, 2025 19:20
@llvmbot
Copy link
Member

llvmbot commented May 20, 2025

@llvm/pr-subscribers-debuginfo

Author: Andrew Rogers (andrurogerz)

Changes

Purpose

This patch prepares the llvm/DebugInfo library for public interface annotations in support of an LLVM Windows DLL (shared library) build, tracked in #109483. The purpose of this patch is to make the upcoming codemod of this library more straight-forward. It is not expected to impact any functionality.

Overview

Adds declarations to the header files for two explicit specialized methods:

  • ContinuationRecordBuilder::writeMemberType
  • SimpleTypeSerializer::serialize

These specializations are already defined the corresponding implementation files:

This patch will not impact functionality, it just ensures they're exposed as part of the public ABI so they can be annotated for export in a subsequent patch.

Background

The LLVM Windows DLL effort is tracked in #109483. Additional context is provided in this discourse.

Validation

Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations:

  • Windows with MSVC
  • Windows with Clang
  • Linux with GCC
  • Linux with Clang
  • Darwin with Clang

Full diff: https://github.com/llvm/llvm-project/pull/140785.diff

2 Files Affected:

  • (modified) llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h (+14)
  • (modified) llvm/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h (+13)
diff --git a/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h b/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h
index 84cef520a2f46..fc86a6249aa94 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/ContinuationRecordBuilder.h
@@ -12,6 +12,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/DebugInfo/CodeView/CVRecord.h"
+#include "llvm/DebugInfo/CodeView/TypeRecord.h"
 #include "llvm/DebugInfo/CodeView/TypeRecordMapping.h"
 #include "llvm/Support/BinaryByteStream.h"
 #include "llvm/Support/BinaryStreamWriter.h"
@@ -50,6 +51,19 @@ class ContinuationRecordBuilder {
 
   std::vector<CVType> end(TypeIndex Index);
 };
+
+#define TYPE_RECORD(EnumName, EnumVal, Name)
+#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#define MEMBER_RECORD(EnumName, EnumVal, Name)                                 \
+  extern template void ContinuationRecordBuilder::writeMemberType(             \
+      Name##Record &Record);
+#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
+#undef TYPE_RECORD
+#undef TYPE_RECORD_ALIAS
+#undef MEMBER_RECORD
+#undef MEMBER_RECORD_ALIAS
+
 } // namespace codeview
 } // namespace llvm
 
diff --git a/llvm/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h b/llvm/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h
index fcc0452a6ae9a..2ee815b0e9617 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/SimpleTypeSerializer.h
@@ -10,6 +10,7 @@
 #define LLVM_DEBUGINFO_CODEVIEW_SIMPLETYPESERIALIZER_H
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/DebugInfo/CodeView/TypeRecord.h"
 #include <vector>
 
 namespace llvm {
@@ -32,6 +33,18 @@ class SimpleTypeSerializer {
   ArrayRef<uint8_t> serialize(const FieldListRecord &Record) = delete;
 };
 
+#define TYPE_RECORD(EnumName, EnumVal, Name)                                   \
+  extern template ArrayRef<uint8_t> SimpleTypeSerializer::serialize(           \
+      Name##Record &Record);
+#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#define MEMBER_RECORD(EnumName, EnumVal, Name)
+#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
+#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
+#undef TYPE_RECORD
+#undef TYPE_RECORD_ALIAS
+#undef MEMBER_RECORD
+#undef MEMBER_RECORD_ALIAS
+
 } // end namespace codeview
 } // end namespace llvm
 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants