[llvm] Add debuginfo C support for a SetType, Subrangetype, dynamic array type and replace arrays (PR #135607)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 14 02:51:42 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: peter mckinna (demoitem)
<details>
<summary>Changes</summary>
This change adds some support to the C DebugInfo capability to create set types,
subrange types, dynamic array types and the ability to replace arrays.
---
Full diff: https://github.com/llvm/llvm-project/pull/135607.diff
2 Files Affected:
- (modified) llvm/include/llvm-c/DebugInfo.h (+72-1)
- (modified) llvm/lib/IR/DebugInfo.cpp (+51)
``````````diff
diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
index 11e0b9b4c81e8..0f267d9941b08 100644
--- a/llvm/include/llvm-c/DebugInfo.h
+++ b/llvm/include/llvm-c/DebugInfo.h
@@ -673,7 +673,6 @@ LLVMMetadataRef LLVMDIBuilderCreateUnionType(
LLVMMetadataRef *Elements, unsigned NumElements, unsigned RunTimeLang,
const char *UniqueId, size_t UniqueIdLen);
-
/**
* Create debugging information entry for an array.
* \param Builder The DIBuilder.
@@ -689,6 +688,78 @@ LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef Builder, uint64_t Size,
LLVMMetadataRef *Subscripts,
unsigned NumSubscripts);
+/**
+ * Create debugging information entry for a set.
+ * @param Builder The DIBuilder.
+ * \param Scope The scope this module is imported into.
+ * \param Name A name that uniquely identifies this set.
+ * \param NameLen The length of the C string passed to \c Name.
+ * \param File File where the set is located.
+ * \param Line Line number of the declaration.
+ * \param SizeInBits Set size.
+ * \param AlignInBits Set alignment.
+ * @param BaseTy The base type of the set.
+ */
+LLVMMetadataRef LLVMDIBuilderCreateSetType(
+ LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+ size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
+ uint64_t SizeInBits, uint32_t AlignInBits, LLVMMetadataRef BaseTy);
+
+/**
+ * Create a descriptor for a subrange with dynamic bounds.
+ * \param Builder The DIBuilder.
+ * \param Scope The scope this module is imported into.
+ * \param Name A name that uniquely identifies this set.
+ * \param NameLen The length of the C string passed to \c Name.
+ * \param LineNo Line number.
+ * \param File File where the subrange is located.
+ * \param SizeInBits Member size.
+ * \param AlignInBits Member alignment.
+ * \param Flags Flags.
+ * \param BaseTy The base type of the subrange. eg integer or enumeration
+ * \param LowerBound Lower bound of the subrange.
+ * \param UpperBound Upper bound of the subrange.
+ * \param Stride Stride of the subrange.
+ * \param Bias Bias of the subrange.
+ */
+LLVMMetadataRef LLVMDIBuilderCreateSubrangeType(
+ LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+ size_t NameLen, unsigned LineNo, LLVMMetadataRef File,
+ uint64_t SizeInBits, uint32_t AlignInBits,
+ LLVMDIFlags Flags, LLVMMetadataRef BaseTy,
+ LLVMMetadataRef LowerBound, LLVMMetadataRef UpperBound,
+ LLVMMetadataRef Stride, LLVMMetadataRef Bias);
+
+/**
+ * Create debugging information entry for a dynamic array.
+ * \param Builder The DIBuilder.
+ * \param Size Array size.
+ * \param AlignInBits Alignment.
+ * \param Ty Element type.
+ * \param Subscripts Subscripts.
+ * \param NumSubscripts Number of subscripts.
+ * \param DataLocation DataLocation.
+ * \param Associated Associated.
+ * \param Allocated Allocated.
+ * \param Rank Rank.
+ * \param BitStride BitStride.
+ */
+LLVMMetadataRef LLVMDIBuilderCreateDynamicArrayType(
+ LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+ size_t NameLen, unsigned LineNo, LLVMMetadataRef File,
+ uint64_t Size, uint32_t AlignInBits,
+ LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts,
+ LLVMMetadataRef DataLocation, LLVMMetadataRef Associated,
+ LLVMMetadataRef Allocated, LLVMMetadataRef Rank, LLVMMetadataRef BitStride);
+
+/**
+ * Replace arrays.
+ *
+ * @see DIBuilder::replaceArrays()
+ */
+void LLVMReplaceArrays(LLVMDIBuilderRef Builder, LLVMMetadataRef *T,
+ LLVMMetadataRef *Elements, unsigned NumElements);
+
/**
* Create debugging information entry for a vector type.
* \param Builder The DIBuilder.
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index cefd6fe14a3ac..c2f12f0efa030 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -1309,6 +1309,57 @@ return wrap(unwrap(Builder)->createEnumerationType(
LineNumber, SizeInBits, AlignInBits, Elts, unwrapDI<DIType>(ClassTy)));
}
+LLVMMetadataRef LLVMDIBuilderCreateSetType(
+ LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+ size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
+ uint64_t SizeInBits, uint32_t AlignInBits, LLVMMetadataRef BaseTy) {
+ return wrap(unwrap(Builder)->createSetType(
+ unwrapDI<DIScope>(Scope), {Name, NameLen}, unwrapDI<DIFile>(File),
+ LineNumber, SizeInBits, AlignInBits, unwrapDI<DIType>(BaseTy)));
+}
+
+LLVMMetadataRef LLVMDIBuilderCreateSubrangeType(
+ LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+ size_t NameLen, unsigned LineNo, LLVMMetadataRef File,
+ uint64_t SizeInBits, uint32_t AlignInBits,
+ LLVMDIFlags Flags, LLVMMetadataRef BaseTy,
+ LLVMMetadataRef LowerBound, LLVMMetadataRef UpperBound,
+ LLVMMetadataRef Stride, LLVMMetadataRef Bias
+ ) {
+ return wrap(unwrap(Builder)->createSubrangeType(
+ {Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
+ unwrapDI<DIScope>(Scope), SizeInBits, AlignInBits,
+ map_from_llvmDIFlags(Flags), unwrapDI<DIType>(BaseTy),
+ unwrap<DIExpression>(LowerBound), unwrap<DIExpression>(UpperBound),
+ unwrap<DIExpression>(Stride), unwrap<DIExpression>(Bias)));
+}
+
+LLVMMetadataRef LLVMDIBuilderCreateDynamicArrayType(
+ LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
+ size_t NameLen, unsigned LineNo, LLVMMetadataRef File,
+ uint64_t Size, uint32_t AlignInBits,
+ LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts,
+ LLVMMetadataRef DataLocation, LLVMMetadataRef Associated,
+ LLVMMetadataRef Allocated, LLVMMetadataRef Rank, LLVMMetadataRef BitStride) {
+ auto Subs =
+ unwrap(Builder)->getOrCreateArray({unwrap(Subscripts), NumSubscripts});
+ return wrap(unwrap(Builder)->createArrayType(
+ unwrapDI<DIScope>(Scope),
+ {Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
+ Size, AlignInBits, unwrapDI<DIType>(Ty), Subs,
+ unwrap<DIExpression>(DataLocation), unwrap<DIExpression>(Associated),
+ unwrap<DIExpression>(Allocated), unwrap<DIExpression>(Rank),
+ unwrap(BitStride)));
+}
+
+void LLVMReplaceArrays(LLVMDIBuilderRef Builder, LLVMMetadataRef *T,
+ LLVMMetadataRef *Elements, unsigned NumElements) {
+ auto Arr = unwrap<DICompositeType>(*T);
+ auto Elts = unwrap(Builder)->getOrCreateArray({unwrap(Elements),
+ NumElements});
+ unwrap(Builder)->replaceArrays(Arr, Elts);
+}
+
LLVMMetadataRef LLVMDIBuilderCreateUnionType(
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
size_t NameLen, LLVMMetadataRef File, unsigned LineNumber,
``````````
</details>
https://github.com/llvm/llvm-project/pull/135607
More information about the llvm-commits
mailing list