mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-17 19:30:00 +08:00
Debugging and profiling support for LLVM JIT provider.
This currently requires patches to the LLVM codebase to be effective (submitted upstream), the GUCs are available without those patches however. Author: Andres Freund Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
This commit is contained in:
parent
b96d550eb0
commit
250bca7fc1
@ -33,7 +33,9 @@
|
|||||||
/* GUCs */
|
/* GUCs */
|
||||||
bool jit_enabled = true;
|
bool jit_enabled = true;
|
||||||
char *jit_provider = "llvmjit";
|
char *jit_provider = "llvmjit";
|
||||||
|
bool jit_debugging_support = false;
|
||||||
bool jit_dump_bitcode = false;
|
bool jit_dump_bitcode = false;
|
||||||
|
bool jit_profiling_support = false;
|
||||||
|
|
||||||
static JitProviderCallbacks provider;
|
static JitProviderCallbacks provider;
|
||||||
static bool provider_successfully_loaded = false;
|
static bool provider_successfully_loaded = false;
|
||||||
|
@ -541,6 +541,21 @@ llvm_session_initialize(void)
|
|||||||
llvm_opt0_orc = LLVMOrcCreateInstance(llvm_opt0_targetmachine);
|
llvm_opt0_orc = LLVMOrcCreateInstance(llvm_opt0_targetmachine);
|
||||||
llvm_opt3_orc = LLVMOrcCreateInstance(llvm_opt3_targetmachine);
|
llvm_opt3_orc = LLVMOrcCreateInstance(llvm_opt3_targetmachine);
|
||||||
|
|
||||||
|
#if defined(HAVE_DECL_LLVMORCREGISTERGDB) && HAVE_DECL_LLVMORCREGISTERGDB
|
||||||
|
if (jit_debugging_support)
|
||||||
|
{
|
||||||
|
LLVMOrcRegisterGDB(llvm_opt0_orc);
|
||||||
|
LLVMOrcRegisterGDB(llvm_opt3_orc);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_DECL_LLVMORCREGISTERPERF) && HAVE_DECL_LLVMORCREGISTERPERF
|
||||||
|
if (jit_profiling_support)
|
||||||
|
{
|
||||||
|
LLVMOrcRegisterPerf(llvm_opt0_orc);
|
||||||
|
LLVMOrcRegisterPerf(llvm_opt3_orc);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
before_shmem_exit(llvm_shutdown, 0);
|
before_shmem_exit(llvm_shutdown, 0);
|
||||||
|
|
||||||
llvm_session_initialized = true;
|
llvm_session_initialized = true;
|
||||||
@ -551,6 +566,27 @@ llvm_session_initialize(void)
|
|||||||
static void
|
static void
|
||||||
llvm_shutdown(int code, Datum arg)
|
llvm_shutdown(int code, Datum arg)
|
||||||
{
|
{
|
||||||
|
/* unregister profiling support, needs to be flushed to be useful */
|
||||||
|
|
||||||
|
if (llvm_opt3_orc)
|
||||||
|
{
|
||||||
|
#if defined(HAVE_DECL_LLVMORCREGISTERPERF) && HAVE_DECL_LLVMORCREGISTERPERF
|
||||||
|
if (jit_profiling_support)
|
||||||
|
LLVMOrcUnregisterPerf(llvm_opt3_orc);
|
||||||
|
#endif
|
||||||
|
LLVMOrcDisposeInstance(llvm_opt3_orc);
|
||||||
|
llvm_opt3_orc = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (llvm_opt0_orc)
|
||||||
|
{
|
||||||
|
#if defined(HAVE_DECL_LLVMORCREGISTERPERF) && HAVE_DECL_LLVMORCREGISTERPERF
|
||||||
|
if (jit_profiling_support)
|
||||||
|
LLVMOrcUnregisterPerf(llvm_opt0_orc);
|
||||||
|
#endif
|
||||||
|
LLVMOrcDisposeInstance(llvm_opt0_orc);
|
||||||
|
llvm_opt0_orc = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* helper for llvm_create_types */
|
/* helper for llvm_create_types */
|
||||||
|
@ -1734,6 +1734,22 @@ static struct config_bool ConfigureNamesBool[] =
|
|||||||
NULL, NULL, NULL
|
NULL, NULL, NULL
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
{"jit_debugging_support", PGC_SU_BACKEND, DEVELOPER_OPTIONS,
|
||||||
|
gettext_noop("Register JIT compiled function with debugger."),
|
||||||
|
NULL,
|
||||||
|
GUC_NOT_IN_SAMPLE
|
||||||
|
},
|
||||||
|
&jit_debugging_support,
|
||||||
|
false,
|
||||||
|
/*
|
||||||
|
* This is not guaranteed to be available, but given it's a developer
|
||||||
|
* oriented option, it doesn't seem worth adding code checking
|
||||||
|
* availability.
|
||||||
|
*/
|
||||||
|
NULL, NULL, NULL
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
{"jit_dump_bitcode", PGC_SUSET, DEVELOPER_OPTIONS,
|
{"jit_dump_bitcode", PGC_SUSET, DEVELOPER_OPTIONS,
|
||||||
gettext_noop("Write out LLVM bitcode to facilitate JIT debugging."),
|
gettext_noop("Write out LLVM bitcode to facilitate JIT debugging."),
|
||||||
@ -1745,6 +1761,22 @@ static struct config_bool ConfigureNamesBool[] =
|
|||||||
NULL, NULL, NULL
|
NULL, NULL, NULL
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
{"jit_profiling_support", PGC_SU_BACKEND, DEVELOPER_OPTIONS,
|
||||||
|
gettext_noop("Register JIT compiled function with perf profiler."),
|
||||||
|
NULL,
|
||||||
|
GUC_NOT_IN_SAMPLE
|
||||||
|
},
|
||||||
|
&jit_profiling_support,
|
||||||
|
false,
|
||||||
|
/*
|
||||||
|
* This is not guaranteed to be available, but given it's a developer
|
||||||
|
* oriented option, it doesn't seem worth adding code checking
|
||||||
|
* availability.
|
||||||
|
*/
|
||||||
|
NULL, NULL, NULL
|
||||||
|
},
|
||||||
|
|
||||||
/* End-of-list marker */
|
/* End-of-list marker */
|
||||||
{
|
{
|
||||||
{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL
|
{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL
|
||||||
|
@ -58,7 +58,9 @@ struct JitProviderCallbacks
|
|||||||
/* GUCs */
|
/* GUCs */
|
||||||
extern bool jit_enabled;
|
extern bool jit_enabled;
|
||||||
extern char *jit_provider;
|
extern char *jit_provider;
|
||||||
|
extern bool jit_debugging_support;
|
||||||
extern bool jit_dump_bitcode;
|
extern bool jit_dump_bitcode;
|
||||||
|
extern bool jit_profiling_support;
|
||||||
|
|
||||||
|
|
||||||
extern void jit_reset_after_error(void);
|
extern void jit_reset_after_error(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user