[llvm] llvm-c: Introduce 'LLVMDISubprogramReplaceType' (PR #143461)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 9 17:11:46 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
Author: David (davidgmbb)
<details>
<summary>Changes</summary>
The C API does not provide a way to replace the subroutine type after creating a subprogram. This functionality is useful for creating a subroutine type composed of types which have the subprogram as scope
---
Full diff: https://github.com/llvm/llvm-project/pull/143461.diff
2 Files Affected:
- (modified) llvm/include/llvm-c/DebugInfo.h (+9)
- (modified) llvm/lib/IR/DebugInfo.cpp (+4)
``````````diff
diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
index 991def64028da..bffed4bebbda6 100644
--- a/llvm/include/llvm-c/DebugInfo.h
+++ b/llvm/include/llvm-c/DebugInfo.h
@@ -1420,6 +1420,15 @@ void LLVMSetSubprogram(LLVMValueRef Func, LLVMMetadataRef SP);
*/
unsigned LLVMDISubprogramGetLine(LLVMMetadataRef Subprogram);
+/**
+ * Replace the subprogram subroutine type
+ * \param Subprogram The subprogram object.
+ * \param SubroutineType The new subroutine type
+ *
+ * @see DISubprogram::replaceType()
+ */
+void LLVMDISubprogramReplaceType(LLVMMetadataRef Subprogram, LLVMMetadataRef SubroutineType);
+
/**
* Get the debug location for the given instruction.
*
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 7db9891fdbd75..c26dfcde87edf 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -1818,6 +1818,10 @@ unsigned LLVMDISubprogramGetLine(LLVMMetadataRef Subprogram) {
return unwrapDI<DISubprogram>(Subprogram)->getLine();
}
+void LLVMDISubprogramReplaceType(LLVMMetadataRef Subprogram, LLVMMetadataRef SubroutineType) {
+ unwrapDI<DISubprogram>(Subprogram)->replaceType(unwrapDI<DISubroutineType>(SubroutineType));
+}
+
LLVMMetadataRef LLVMInstructionGetDebugLoc(LLVMValueRef Inst) {
return wrap(unwrap<Instruction>(Inst)->getDebugLoc().getAsMDNode());
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/143461
More information about the llvm-commits
mailing list