PostgreSQL Source Code git master
|
#include "postgres.h"
#include "jit/llvmjit.h"
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "common/string.h"
#include "miscadmin.h"
#include "storage/fd.h"
#include <llvm-c/Core.h>
#include <llvm-c/BitReader.h>
#include <llvm/ADT/SetVector.h>
#include <llvm/ADT/StringSet.h>
#include <llvm/ADT/StringMap.h>
#include <llvm/Analysis/ModuleSummaryAnalysis.h>
#include <llvm/Bitcode/BitcodeReader.h>
#include <llvm/IR/Attributes.h>
#include <llvm/IR/DebugInfo.h>
#include <llvm/IR/IntrinsicInst.h>
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/ModuleSummaryIndex.h>
#include <llvm/Linker/IRMover.h>
#include <llvm/Support/ManagedStatic.h>
#include <llvm/Support/MemoryBuffer.h>
Go to the source code of this file.
Data Structures | |
struct | InlineWorkListItem |
struct | FunctionInlineState |
Macros | |
#define | ilog(...) (void) 0 |
#define | starts_with startswith |
Typedefs | |
typedef llvm::SmallVector< llvm::ModuleSummaryIndex *, 2 > | InlineSearchPath |
typedef struct InlineWorkListItem | InlineWorkListItem |
typedef llvm::SmallVector< InlineWorkListItem, 128 > | InlineWorkList |
typedef struct FunctionInlineState | FunctionInlineState |
typedef llvm::StringMap< FunctionInlineState > | FunctionInlineStates |
typedef llvm::StringMap< llvm::StringSet<> > | ImportMapTy |
typedef llvm::StringMap< std::unique_ptr< llvm::Module > > | ModuleCache |
typedef llvm::StringMap< std::unique_ptr< llvm::ModuleSummaryIndex > > | SummaryCache |
Functions | |
static std::unique_ptr< ImportMapTy > | llvm_build_inline_plan (LLVMContextRef lc, llvm::Module *mod) |
static void | llvm_execute_inline_plan (llvm::Module *mod, ImportMapTy *globalsToInline) |
static llvm::Module * | load_module_cached (LLVMContextRef c, llvm::StringRef modPath) |
static std::unique_ptr< llvm::Module > | load_module (LLVMContextRef c, llvm::StringRef Identifier) |
static std::unique_ptr< llvm::ModuleSummaryIndex > | llvm_load_summary (llvm::StringRef path) |
static llvm::Function * | create_redirection_function (std::unique_ptr< llvm::Module > &importMod, llvm::Function *F, llvm::StringRef Name) |
static bool | function_inlinable (llvm::Function &F, int threshold, FunctionInlineStates &functionState, InlineWorkList &worklist, InlineSearchPath &searchpath, llvm::SmallPtrSet< const llvm::Function *, 8 > &visitedFunctions, int &running_instcount, llvm::StringSet<> &importVars) |
static void | function_references (llvm::Function &F, int &running_instcount, llvm::SmallPtrSet< llvm::GlobalVariable *, 8 > &referencedVars, llvm::SmallPtrSet< llvm::Function *, 8 > &referencedFunctions) |
static void | add_module_to_inline_search_path (InlineSearchPath &path, llvm::StringRef modpath) |
static llvm::SmallVector< llvm::GlobalValueSummary *, 1 > | summaries_for_guid (const InlineSearchPath &path, llvm::GlobalValue::GUID guid) |
void | llvm_inline_reset_caches (void) |
void | llvm_inline (LLVMModuleRef M) |
Variables | |
const float | inline_cost_decay_factor = 0.5 |
const int | inline_initial_cost = 150 |
llvm::ManagedStatic< ModuleCache > | module_cache |
llvm::ManagedStatic< SummaryCache > | summary_cache |
#define ilog | ( | ... | ) | (void) 0 |
Definition at line 147 of file llvmjit_inline.cpp.
#define starts_with startswith |
typedef struct FunctionInlineState FunctionInlineState |
typedef llvm::StringMap<FunctionInlineState> FunctionInlineStates |
Definition at line 90 of file llvmjit_inline.cpp.
typedef llvm::StringMap<llvm::StringSet<> > ImportMapTy |
Definition at line 96 of file llvmjit_inline.cpp.
typedef llvm::SmallVector<llvm::ModuleSummaryIndex *, 2> InlineSearchPath |
Definition at line 67 of file llvmjit_inline.cpp.
typedef llvm::SmallVector<InlineWorkListItem, 128> InlineWorkList |
Definition at line 77 of file llvmjit_inline.cpp.
typedef struct InlineWorkListItem InlineWorkListItem |
typedef llvm::StringMap<std::unique_ptr<llvm::Module> > ModuleCache |
Definition at line 106 of file llvmjit_inline.cpp.
typedef llvm::StringMap<std::unique_ptr<llvm::ModuleSummaryIndex> > SummaryCache |
Definition at line 108 of file llvmjit_inline.cpp.
|
static |
Definition at line 793 of file llvmjit_inline.cpp.
References Assert(), llvm_load_summary(), pkglib_path, and summary_cache.
Referenced by llvm_build_inline_plan().
|
static |
Definition at line 846 of file llvmjit_inline.cpp.
References F.
Referenced by llvm_execute_inline_plan().
|
static |
Definition at line 568 of file llvmjit_inline.cpp.
References FunctionInlineState::allowReconsidering, FunctionInlineState::costLimit, DEBUG1, elog, F, FATAL, function_inlinable(), function_references(), ilog, inline_cost_decay_factor, FunctionInlineState::inlined, and FunctionInlineState::processed.
Referenced by function_inlinable(), and llvm_build_inline_plan().
|
static |
Definition at line 511 of file llvmjit_inline.cpp.
Referenced by function_inlinable().
|
static |
Definition at line 183 of file llvmjit_inline.cpp.
References add_module_to_inline_search_path(), FunctionInlineState::allowReconsidering, Assert(), FunctionInlineState::costLimit, DEBUG1, elog, FATAL, function_inlinable(), ilog, inline_initial_cost, FunctionInlineState::inlined, llvm_split_symbol_name(), load_module_cached(), FunctionInlineState::processed, InlineWorkListItem::searchpath, summaries_for_guid(), and InlineWorkListItem::symbolName.
Referenced by llvm_inline().
|
static |
Definition at line 377 of file llvmjit_inline.cpp.
References Assert(), create_redirection_function(), DEBUG1, elog, F, FATAL, funcname, ilog, llvm_split_symbol_name(), and module_cache.
Referenced by llvm_inline().
void llvm_inline | ( | LLVMModuleRef | M | ) |
Definition at line 167 of file llvmjit_inline.cpp.
References llvm_build_inline_plan(), and llvm_execute_inline_plan().
Referenced by llvm_compile_module().
void llvm_inline_reset_caches | ( | void | ) |
Definition at line 156 of file llvmjit_inline.cpp.
References module_cache, and summary_cache.
Referenced by llvm_recreate_llvm_context().
|
static |
Definition at line 764 of file llvmjit_inline.cpp.
References DEBUG1, elog, FATAL, and ilog.
Referenced by add_module_to_inline_search_path().
|
static |
Definition at line 481 of file llvmjit_inline.cpp.
References buf, elog, FATAL, MAXPGPATH, pkglib_path, and snprintf.
Referenced by load_module_cached().
|
static |
Definition at line 468 of file llvmjit_inline.cpp.
References load_module(), and module_cache.
Referenced by llvm_build_inline_plan().
|
static |
Definition at line 825 of file llvmjit_inline.cpp.
Referenced by llvm_build_inline_plan().
const float inline_cost_decay_factor = 0.5 |
Definition at line 99 of file llvmjit_inline.cpp.
Referenced by function_inlinable().
const int inline_initial_cost = 150 |
Definition at line 100 of file llvmjit_inline.cpp.
Referenced by llvm_build_inline_plan().
llvm::ManagedStatic<ModuleCache> module_cache |
Definition at line 107 of file llvmjit_inline.cpp.
Referenced by llvm_execute_inline_plan(), llvm_inline_reset_caches(), and load_module_cached().
llvm::ManagedStatic<SummaryCache> summary_cache |
Definition at line 109 of file llvmjit_inline.cpp.
Referenced by add_module_to_inline_search_path(), and llvm_inline_reset_caches().