[llvm] [llvm] prepare explicit template instantiations in llvm/DebugInfo for DLL export annotations (PR #140785)
Andrew Rogers via llvm-commits
llvm-commits at lists.llvm.org
Tue May 20 12:01:18 PDT 2025
https://github.com/andrurogerz created https://github.com/llvm/llvm-project/pull/140785
## 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:
* [`llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp`](https://github.com/llvm/llvm-project/blob/main/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp#L243-L251)
* [`llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp`](https://github.com/llvm/llvm-project/blob/main/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp#L60-L68)
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](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307).
## 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
>From f45edd8259e809bef1bd20e5b6dd8a2ed844ccc3 Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Tue, 20 May 2025 11:48:50 -0700
Subject: [PATCH 1/2] [llvm] add template specialization declarations for
ContinuationRecordBuilder::writeMemberType
---
.../DebugInfo/CodeView/ContinuationRecordBuilder.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
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
>From 07500bdac752a1760b4493631ccf5e237313cf22 Mon Sep 17 00:00:00 2001
From: Andrew Rogers <andrurogerz at gmail.com>
Date: Tue, 20 May 2025 11:50:25 -0700
Subject: [PATCH 2/2] [llvm] add template specialization declarations for
SimpleTypeSerializer::serialize
---
.../llvm/DebugInfo/CodeView/SimpleTypeSerializer.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
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
More information about the llvm-commits
mailing list