mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 13:10:10 +01:00
gallivm: Create a debug builder and add GALLIVM_DEBUG=symbols
Also defers destroying the execution engine since destroying it early looses debug information. Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28613>
This commit is contained in:
parent
3aeab4ce40
commit
95a68076a7
4 changed files with 27 additions and 2 deletions
|
|
@ -35,6 +35,8 @@
|
|||
#include "util/compiler.h"
|
||||
#include "util/u_string.h"
|
||||
|
||||
#include <llvm-c/DebugInfo.h>
|
||||
|
||||
|
||||
#define GALLIVM_DEBUG_TGSI (1 << 0)
|
||||
#define GALLIVM_DEBUG_IR (1 << 1)
|
||||
|
|
@ -42,6 +44,7 @@
|
|||
#define GALLIVM_DEBUG_PERF (1 << 3)
|
||||
#define GALLIVM_DEBUG_GC (1 << 4)
|
||||
#define GALLIVM_DEBUG_DUMP_BC (1 << 5)
|
||||
#define GALLIVM_DEBUG_SYMBOLS (1 << 8)
|
||||
|
||||
#define GALLIVM_PERF_BRILINEAR (1 << 0)
|
||||
#define GALLIVM_PERF_RHO_APPROX (1 << 1)
|
||||
|
|
|
|||
|
|
@ -92,8 +92,11 @@ gallivm_free_ir(struct gallivm_state *gallivm)
|
|||
lp_passmgr_dispose(gallivm->passmgr);
|
||||
|
||||
if (gallivm->engine) {
|
||||
/* This will already destroy any associated module */
|
||||
LLVMDisposeExecutionEngine(gallivm->engine);
|
||||
/* This will already destroy any associated module.
|
||||
*Destroy the execution engine later if we need to keep debug info around.
|
||||
*/
|
||||
if (!(gallivm_debug & GALLIVM_DEBUG_SYMBOLS))
|
||||
LLVMDisposeExecutionEngine(gallivm->engine);
|
||||
} else if (gallivm->module) {
|
||||
LLVMDisposeModule(gallivm->module);
|
||||
}
|
||||
|
|
@ -111,6 +114,9 @@ gallivm_free_ir(struct gallivm_state *gallivm)
|
|||
if (gallivm->builder)
|
||||
LLVMDisposeBuilder(gallivm->builder);
|
||||
|
||||
if (gallivm->di_builder)
|
||||
LLVMDisposeDIBuilder(gallivm->di_builder);
|
||||
|
||||
/* The LLVMContext should be owned by the parent of gallivm. */
|
||||
|
||||
gallivm->engine = NULL;
|
||||
|
|
@ -284,6 +290,9 @@ init_gallivm_state(struct gallivm_state *gallivm, const char *name,
|
|||
if (!create_pass_manager(gallivm))
|
||||
goto fail;
|
||||
|
||||
if (gallivm_debug & GALLIVM_DEBUG_SYMBOLS)
|
||||
gallivm->di_builder = LLVMCreateDIBuilder(gallivm->module);
|
||||
|
||||
lp_build_coro_declare_malloc_hooks(gallivm);
|
||||
return true;
|
||||
|
||||
|
|
@ -349,6 +358,8 @@ void
|
|||
gallivm_destroy(struct gallivm_state *gallivm)
|
||||
{
|
||||
gallivm_free_ir(gallivm);
|
||||
if (gallivm->engine)
|
||||
LLVMDisposeExecutionEngine(gallivm->engine);
|
||||
gallivm_free_code(gallivm);
|
||||
FREE(gallivm);
|
||||
}
|
||||
|
|
@ -373,6 +384,12 @@ gallivm_compile_module(struct gallivm_state *gallivm)
|
|||
gallivm->builder = NULL;
|
||||
}
|
||||
|
||||
if (gallivm->di_builder) {
|
||||
LLVMDIBuilderFinalize(gallivm->di_builder);
|
||||
LLVMDisposeDIBuilder(gallivm->di_builder);
|
||||
gallivm->di_builder = NULL;
|
||||
}
|
||||
|
||||
LLVMSetDataLayout(gallivm->module, "");
|
||||
assert(!gallivm->engine);
|
||||
if (!init_gallivm_engine(gallivm)) {
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ struct gallivm_state
|
|||
#endif
|
||||
LLVMContextRef context;
|
||||
LLVMBuilderRef builder;
|
||||
LLVMDIBuilderRef di_builder;
|
||||
struct lp_cached_code *cache;
|
||||
unsigned compiled;
|
||||
LLVMValueRef coro_malloc_hook;
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ static const struct debug_named_value lp_bld_debug_flags[] = {
|
|||
#if MESA_DEBUG
|
||||
{ "dumpbc", GALLIVM_DEBUG_DUMP_BC, NULL },
|
||||
#endif
|
||||
{ "symbols", GALLIVM_DEBUG_SYMBOLS, NULL },
|
||||
DEBUG_NAMED_VALUE_END
|
||||
};
|
||||
|
||||
|
|
@ -83,6 +84,9 @@ lp_init_env_options(void)
|
|||
{
|
||||
gallivm_debug = debug_get_option_gallivm_debug();
|
||||
|
||||
if (!__normal_user())
|
||||
gallivm_debug &= ~GALLIVM_DEBUG_SYMBOLS;
|
||||
|
||||
gallivm_perf = debug_get_flags_option("GALLIVM_PERF", lp_bld_perf_flags, 0 );
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue