-
Notifications
You must be signed in to change notification settings - Fork 14.4k
llvm-c: Introduce 'LLVMDISubprogramReplaceType' #143461
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
Conversation
@llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-debuginfo Author: David (davidgmbb) ChangesThe 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:
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());
}
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
9150b7e
to
f423d89
Compare
ping |
Do we have unit test coverage for other parts of the debug info C API? If so, could you add some for this function too? |
f423d89
to
0c47a11
Compare
Hi. Thanks for taking some time to review the PR. I found some tests and added a call to the new function there, but I don't know if they are automatically triggered in CI runs. |
0c47a11
to
e993a25
Compare
If you build |
Thanks for the explanation. I checked the logs and that test passed. I am running all the tests locally but I have an old cheap CPU and it's taking forever. If I run just that test it passes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test update LGTM. If @dwblaikie has no further comments, I can merge this for you if you don't have commit access?
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
e993a25
to
2d2e50c
Compare
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
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
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
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