PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <llvm-c/Analysis.h>
#include <llvm-c/BitReader.h>
#include <llvm-c/BitWriter.h>
#include <llvm-c/Core.h>
#include <llvm-c/ExecutionEngine.h>
#include <llvm-c/OrcBindings.h>
#include <llvm-c/Support.h>
#include <llvm-c/Target.h>
#include <llvm-c/Transforms/IPO.h>
#include <llvm-c/Transforms/PassManagerBuilder.h>
#include <llvm-c/Transforms/Scalar.h>
#include "jit/llvmjit.h"
#include "jit/llvmjit_emit.h"
#include "miscadmin.h"
#include "portability/instr_time.h"
#include "storage/ipc.h"
#include "utils/memutils.h"
#include "utils/resowner_private.h"
Go to the source code of this file.
Data Structures | |
struct | LLVMJitHandle |
Typedefs | |
typedef struct LLVMJitHandle | LLVMJitHandle |
Functions | |
static void | llvm_release_context (JitContext *context) |
static void | llvm_session_initialize (void) |
static void | llvm_shutdown (int code, Datum arg) |
static void | llvm_compile_module (LLVMJitContext *context) |
static void | llvm_optimize_module (LLVMJitContext *context, LLVMModuleRef module) |
static void | llvm_create_types (void) |
static uint64_t | llvm_resolve_symbol (const char *name, void *ctx) |
void | _PG_jit_provider_init (JitProviderCallbacks *cb) |
LLVMJitContext * | llvm_create_context (int jitFlags) |
LLVMModuleRef | llvm_mutable_module (LLVMJitContext *context) |
char * | llvm_expand_funcname (struct LLVMJitContext *context, const char *basename) |
void * | llvm_get_function (LLVMJitContext *context, const char *funcname) |
LLVMTypeRef | llvm_pg_var_type (const char *varname) |
LLVMTypeRef | llvm_pg_var_func_type (const char *varname) |
LLVMValueRef | llvm_pg_func (LLVMModuleRef mod, const char *funcname) |
static void | llvm_copy_attributes_at_index (LLVMValueRef v_from, LLVMValueRef v_to, uint32 index) |
void | llvm_copy_attributes (LLVMValueRef v_from, LLVMValueRef v_to) |
LLVMValueRef | llvm_function_reference (LLVMJitContext *context, LLVMBuilderRef builder, LLVMModuleRef mod, FunctionCallInfo fcinfo) |
static LLVMTypeRef | load_return_type (LLVMModuleRef mod, const char *name) |
void | llvm_split_symbol_name (const char *name, char **modname, char **funcname) |
typedef struct LLVMJitHandle LLVMJitHandle |
void _PG_jit_provider_init | ( | JitProviderCallbacks * | cb | ) |
Definition at line 131 of file llvmjit.c.
References JitProviderCallbacks::compile_expr, llvm_compile_expr(), llvm_release_context(), llvm_reset_after_error(), JitProviderCallbacks::release_context, and JitProviderCallbacks::reset_after_error.
|
static |
Definition at line 632 of file llvmjit.c.
References DEBUG1, elog(), ereport, errhidecontext(), errhidestmt(), errmsg_internal(), ERROR, error(), filename, INSTR_TIME_ACCUM_DIFF, INSTR_TIME_GET_DOUBLE, INSTR_TIME_SET_CURRENT, jit_dump_bitcode, lappend(), llvm_inline(), llvm_opt0_orc, llvm_opt3_orc, llvm_optimize_module(), llvm_resolve_symbol(), MemoryContextAlloc(), MemoryContextSwitchTo(), MyProcPid, LLVMJitHandle::orc_handle, pfree(), PGJIT_INLINE, PGJIT_OPT3, psprintf(), LLVMJitHandle::stack, and TopMemoryContext.
Referenced by llvm_get_function().
void llvm_copy_attributes | ( | LLVMValueRef | v_from, |
LLVMValueRef | v_to | ||
) |
Definition at line 477 of file llvmjit.c.
References llvm_copy_attributes_at_index().
Referenced by llvm_pg_func(), and slot_compile_deform().
|
static |
Definition at line 449 of file llvmjit.c.
References LLVMGetAttributeCountAtIndexPG(), palloc(), and pfree().
Referenced by llvm_copy_attributes().
LLVMJitContext* llvm_create_context | ( | int | jitFlags | ) |
Definition at line 146 of file llvmjit.c.
References CurrentResourceOwner, llvm_assert_in_fatal_section(), llvm_session_initialize(), MemoryContextAllocZero(), PointerGetDatum(), ResourceOwnerEnlargeJIT(), ResourceOwnerRememberJIT(), and TopMemoryContext.
Referenced by llvm_compile_expr().
|
static |
Definition at line 989 of file llvmjit.c.
References AttributeTemplate, buf, elog(), ERROR, llvm_layout, llvm_pg_var_type(), llvm_triple, llvm_types_module, load_return_type(), MAXPGPATH, pkglib_path, pstrdup(), snprintf, StructAggState, StructAggStatePerGroupData, StructAggStatePerTransData, StructExprContext, StructExprEvalStep, StructExprState, StructFunctionCallInfoData, StructHeapTupleData, StructHeapTupleTableSlot, StructMemoryContextData, StructMinimalTupleTableSlot, StructNullableDatum, StructTupleDescData, StructTupleTableSlot, TypeParamBool, TypePGFunction, TypeSizeT, and TypeStorageBool.
Referenced by llvm_session_initialize().
char* llvm_expand_funcname | ( | struct LLVMJitContext * | context, |
const char * | basename | ||
) |
Definition at line 257 of file llvmjit.c.
References Assert(), and psprintf().
Referenced by slot_compile_deform().
LLVMValueRef llvm_function_reference | ( | LLVMJitContext * | context, |
LLVMBuilderRef | builder, | ||
LLVMModuleRef | mod, | ||
FunctionCallInfo | fcinfo | ||
) |
Definition at line 498 of file llvmjit.c.
References FunctionCallInfoBaseData::flinfo, fmgr_symbol(), FmgrInfo::fn_addr, FmgrInfo::fn_oid, funcname, psprintf(), pstrdup(), and TypePGFunction.
Referenced by BuildV1Call().
void* llvm_get_function | ( | LLVMJitContext * | context, |
const char * | funcname | ||
) |
Definition at line 278 of file llvmjit.c.
References elog(), ERROR, error(), funcname, INSTR_TIME_ACCUM_DIFF, INSTR_TIME_SET_CURRENT, lfirst, llvm_assert_in_fatal_section(), llvm_compile_module(), llvm_opt0_orc, llvm_opt3_orc, LLVMJitHandle::orc_handle, and LLVMJitHandle::stack.
Referenced by ExecRunCompiledExpr().
LLVMModuleRef llvm_mutable_module | ( | LLVMJitContext * | context | ) |
Definition at line 232 of file llvmjit.c.
References llvm_assert_in_fatal_section(), llvm_generation, llvm_layout, and llvm_triple.
Referenced by slot_compile_deform().
|
static |
Definition at line 561 of file llvmjit.c.
References PGJIT_INLINE, and PGJIT_OPT3.
Referenced by llvm_compile_module().
LLVMValueRef llvm_pg_func | ( | LLVMModuleRef | mod, |
const char * | funcname | ||
) |
Definition at line 421 of file llvmjit.c.
References elog(), ERROR, funcname, llvm_copy_attributes(), and llvm_types_module.
Referenced by build_EvalXFuncInt(), and slot_compile_deform().
LLVMTypeRef llvm_pg_var_func_type | ( | const char * | varname | ) |
LLVMTypeRef llvm_pg_var_type | ( | const char * | varname | ) |
Definition at line 377 of file llvmjit.c.
References Assert(), elog(), ERROR, and llvm_types_module.
Referenced by llvm_create_types(), and llvm_pg_var_func_type().
|
static |
Definition at line 171 of file llvmjit.c.
References lfirst, list_free(), llvm_enter_fatal_on_oom(), llvm_leave_fatal_on_oom(), NIL, LLVMJitHandle::orc_handle, pfree(), proc_exit_inprogress, and LLVMJitHandle::stack.
Referenced by _PG_jit_provider_init().
|
static |
Definition at line 1079 of file llvmjit.c.
References Assert(), elog(), ERROR, funcname, llvm_split_symbol_name(), load_external_function(), pfree(), and WARNING.
Referenced by llvm_compile_module().
|
static |
Definition at line 783 of file llvmjit.c.
References DEBUG2, elog(), error(), FATAL, jit_debugging_support, jit_profiling_support, llvm_create_types(), llvm_opt0_orc, llvm_opt3_orc, llvm_session_initialized, llvm_shutdown(), llvm_targetref, llvm_triple, MemoryContextSwitchTo(), on_proc_exit(), and TopMemoryContext.
Referenced by llvm_create_context().
|
static |
Definition at line 896 of file llvmjit.c.
References Assert(), jit_profiling_support, llvm_in_fatal_on_oom(), llvm_opt0_orc, llvm_opt3_orc, and proc_exit_inprogress.
Referenced by llvm_session_initialize().
void llvm_split_symbol_name | ( | const char * | name, |
char ** | modname, | ||
char ** | funcname | ||
) |
Definition at line 1045 of file llvmjit.c.
References Assert(), funcname, name, pnstrdup(), and pstrdup().
Referenced by llvm_build_inline_plan(), llvm_execute_inline_plan(), and llvm_resolve_symbol().
|
static |
Datum AttributeTemplate |
Definition at line 89 of file llvmjit.c.
Referenced by llvm_create_types(), and slot_compile_deform().
|
static |
Definition at line 94 of file llvmjit.c.
Referenced by llvm_mutable_module().
|
static |
Definition at line 96 of file llvmjit.c.
Referenced by llvm_create_types(), and llvm_mutable_module().
|
static |
Definition at line 105 of file llvmjit.c.
Referenced by llvm_compile_module(), llvm_get_function(), llvm_session_initialize(), and llvm_shutdown().
|
static |
Definition at line 106 of file llvmjit.c.
Referenced by llvm_compile_module(), llvm_get_function(), llvm_session_initialize(), and llvm_shutdown().
Definition at line 93 of file llvmjit.c.
Referenced by llvm_session_initialize().
|
static |
Definition at line 99 of file llvmjit.c.
Referenced by llvm_session_initialize().
|
static |
Definition at line 95 of file llvmjit.c.
Referenced by llvm_create_types(), llvm_mutable_module(), and llvm_session_initialize().
LLVMModuleRef llvm_types_module = NULL |
Definition at line 91 of file llvmjit.c.
Referenced by llvm_create_types(), llvm_pg_func(), and llvm_pg_var_type().
LLVMTypeRef StructAggState |
Definition at line 85 of file llvmjit.c.
Referenced by llvm_create_types().
LLVMTypeRef StructAggStatePerGroupData |
Definition at line 86 of file llvmjit.c.
Referenced by llvm_create_types().
LLVMTypeRef StructAggStatePerTransData |
Definition at line 87 of file llvmjit.c.
Referenced by llvm_create_types().
LLVMTypeRef StructExprContext |
Definition at line 82 of file llvmjit.c.
Referenced by llvm_create_types().
LLVMTypeRef StructExprEvalStep |
Definition at line 83 of file llvmjit.c.
Referenced by build_EvalXFuncInt(), and llvm_create_types().
LLVMTypeRef StructExprState |
Definition at line 84 of file llvmjit.c.
Referenced by llvm_create_types().
LLVMTypeRef StructFunctionCallInfoData |
Definition at line 81 of file llvmjit.c.
Referenced by BuildV1Call(), and llvm_create_types().
LLVMTypeRef StructHeapTupleData |
Definition at line 68 of file llvmjit.c.
Referenced by llvm_create_types().
LLVMTypeRef StructHeapTupleTableSlot |
Definition at line 76 of file llvmjit.c.
Referenced by llvm_create_types(), and slot_compile_deform().
LLVMTypeRef StructMemoryContextData |
Definition at line 78 of file llvmjit.c.
Referenced by llvm_create_types().
LLVMTypeRef StructMinimalTupleTableSlot |
Definition at line 77 of file llvmjit.c.
Referenced by llvm_create_types(), and slot_compile_deform().
LLVMTypeRef StructNullableDatum |
Definition at line 63 of file llvmjit.c.
Referenced by llvm_create_types().
LLVMTypeRef StructTupleDescData |
Definition at line 74 of file llvmjit.c.
Referenced by llvm_create_types().
LLVMTypeRef StructTupleTableSlot |
Definition at line 75 of file llvmjit.c.
Referenced by llvm_create_types(), and slot_compile_deform().
LLVMTypeRef TypeParamBool |
Definition at line 60 of file llvmjit.c.
Referenced by llvm_create_types().
LLVMTypeRef TypePGFunction |
Definition at line 62 of file llvmjit.c.
Referenced by llvm_create_types(), and llvm_function_reference().
LLVMTypeRef TypeSizeT |
Definition at line 59 of file llvmjit.c.
Referenced by llvm_create_types(), and slot_compile_deform().
LLVMTypeRef TypeStorageBool |
Definition at line 61 of file llvmjit.c.
Referenced by llvm_create_types().