-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm-c] Expose debug support for LLJIT in Orc C-API bindings #73257
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
Merged
weliveindetail
merged 8 commits into
llvm:main
from
weliveindetail:capi-orc-debug-plugin
Dec 11, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a91f9b8
[llvm-c] Expose debug support for LLJIT in Orc bindings
weliveindetail c6edfcf
Temporarily disable the test for MachO
weliveindetail 09de016
Add example with minimal debug-info and re-enable MachO test
weliveindetail 8c94494
Declare in new C-API header and implement in libLLVMOrcDebugging
weliveindetail e0fbd64
Drop LLVMOrcLLJITEnableDebugSupport() from OrcV2CBindings.cpp
weliveindetail efc145d
Drop unnecessary include from OrcV2CBindings.cpp
weliveindetail e842e06
Fix file headers (NFC)
weliveindetail 3e443cc
Drop unnecessary typedef in LLJITUtils.h
weliveindetail File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/*===------- llvm-c/LLJITUtils.h - Advanced LLJIT features --------*- C -*-===*\ | ||
|* *| | ||
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| | ||
|* Exceptions. *| | ||
|* See https://llvm.org/LICENSE.txt for license information. *| | ||
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| | ||
|* *| | ||
|*===----------------------------------------------------------------------===*| | ||
|* *| | ||
|* This header declares the C interface for extra utilities to be used with *| | ||
|* the LLJIT class from the llvm-c/LLJIT.h header. It requires to following *| | ||
|* link libraries in addition to libLLVMOrcJIT.a: *| | ||
|* - libLLVMOrcDebugging.a *| | ||
|* *| | ||
|* Many exotic languages can interoperate with C code but have a harder time *| | ||
|* with C++ due to name mangling. So in addition to C, this interface enables *| | ||
|* tools written in such languages. *| | ||
|* *| | ||
|* Note: This interface is experimental. It is *NOT* stable, and may be *| | ||
|* changed without warning. Only C API usage documentation is *| | ||
|* provided. See the C++ documentation for all higher level ORC API *| | ||
|* details. *| | ||
|* *| | ||
\*===----------------------------------------------------------------------===*/ | ||
|
||
#ifndef LLVM_C_LLJITUTILS_H | ||
#define LLVM_C_LLJITUTILS_H | ||
|
||
#include "llvm-c/LLJIT.h" | ||
|
||
LLVM_C_EXTERN_C_BEGIN | ||
|
||
/** | ||
* @defgroup LLVMCExecutionEngineLLJITUtils LLJIT Utilities | ||
* @ingroup LLVMCExecutionEngineLLJIT | ||
* | ||
* @{ | ||
*/ | ||
|
||
/** | ||
* Install the plugin that submits debug objects to the executor. Executors must | ||
* expose the llvm_orc_registerJITLoaderGDBWrapper symbol. | ||
*/ | ||
LLVMErrorRef LLVMOrcLLJITEnableDebugSupport(LLVMOrcLLJITRef J); | ||
|
||
/** | ||
* @} | ||
*/ | ||
|
||
LLVM_C_EXTERN_C_END | ||
|
||
#endif /* LLVM_C_LLJITUTILS_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
llvm/lib/ExecutionEngine/Orc/Debugging/LLJITUtilsCBindings.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//===--------- LLJITUtilsCBindings.cpp - Advanced LLJIT features ----------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "llvm-c/LLJIT.h" | ||
#include "llvm-c/LLJITUtils.h" | ||
|
||
#include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupport.h" | ||
#include "llvm/ExecutionEngine/Orc/LLJIT.h" | ||
|
||
using namespace llvm; | ||
using namespace llvm::orc; | ||
|
||
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLJIT, LLVMOrcLLJITRef) | ||
|
||
LLVMErrorRef LLVMOrcLLJITEnableDebugSupport(LLVMOrcLLJITRef J) { | ||
return wrap(llvm::orc::enableDebuggerSupport(*unwrap(J))); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS | |
IRReader | ||
JITLink | ||
Object | ||
OrcDebugging | ||
OrcJIT | ||
OrcShared | ||
OrcTargetProcess | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is the
RequireDebugSections
flag. Without this change the test won't pass, because the bitcode for thesum()
example has no debug info.This change may cause some overhead, but this shouldn't be a surprise in the context of debugging. And it may avoid headaches for users: Not remembering to generate debug info is a common problem for JITed code. With this change users get at least function names, like in release builds. Without it, the debugger has zero info.
Alternatively, we could expose it in the C-API and wire it up in the internal function here. See my second comment for details.