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/ReaderWriter.h>
#include <llvm/Support/Error.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 | IRMOVE_PARAMS |
#define | hasFnAttr hasFnAttribute |
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 (llvm::Module *mod) |
static void | llvm_execute_inline_plan (llvm::Module *mod, ImportMapTy *globalsToInline) |
static llvm::Module * | load_module_cached (llvm::StringRef modPath) |
static std::unique_ptr< llvm::Module > | load_module (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 (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 hasFnAttr hasFnAttribute |
#define ilog | ( | ... | ) | (void) 0 |
Definition at line 152 of file llvmjit_inline.cpp.
#define IRMOVE_PARAMS |
typedef struct FunctionInlineState FunctionInlineState |
typedef llvm::StringMap<FunctionInlineState> FunctionInlineStates |
Definition at line 95 of file llvmjit_inline.cpp.
typedef llvm::StringMap<llvm::StringSet<> > ImportMapTy |
Definition at line 101 of file llvmjit_inline.cpp.
typedef llvm::SmallVector<llvm::ModuleSummaryIndex *, 2> InlineSearchPath |
Definition at line 72 of file llvmjit_inline.cpp.
typedef llvm::SmallVector<InlineWorkListItem, 128> InlineWorkList |
Definition at line 82 of file llvmjit_inline.cpp.
typedef struct InlineWorkListItem InlineWorkListItem |
typedef llvm::StringMap<std::unique_ptr<llvm::Module> > ModuleCache |
Definition at line 111 of file llvmjit_inline.cpp.
typedef llvm::StringMap<std::unique_ptr<llvm::ModuleSummaryIndex> > SummaryCache |
Definition at line 113 of file llvmjit_inline.cpp.
|
static |
Definition at line 808 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 868 of file llvmjit_inline.cpp.
References F.
Referenced by llvm_execute_inline_plan().
|
static |
Definition at line 569 of file llvmjit_inline.cpp.
References FunctionInlineState::allowReconsidering, FunctionInlineState::costLimit, DEBUG1, elog(), F, FATAL, function_references(), ilog, inline_cost_decay_factor, FunctionInlineState::inlined, and FunctionInlineState::processed.
Referenced by llvm_build_inline_plan().
|
static |
|
static |
Definition at line 175 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 371 of file llvmjit_inline.cpp.
References Assert(), create_redirection_function(), DEBUG1, elog(), F, FATAL, funcname, ilog, IRMOVE_PARAMS, llvm_split_symbol_name(), and module_cache.
Referenced by llvm_inline().
void llvm_inline | ( | LLVMModuleRef | M | ) |
Definition at line 160 of file llvmjit_inline.cpp.
References llvm_build_inline_plan(), and llvm_execute_inline_plan().
Referenced by llvm_compile_module().
|
static |
Definition at line 769 of file llvmjit_inline.cpp.
References DEBUG1, elog(), FATAL, and ilog.
Referenced by add_module_to_inline_search_path().
|
static |
Definition at line 482 of file llvmjit_inline.cpp.
References buf, elog(), FATAL, MAXPGPATH, pkglib_path, and snprintf.
Referenced by load_module_cached().
|
static |
Definition at line 469 of file llvmjit_inline.cpp.
References load_module(), and module_cache.
Referenced by llvm_build_inline_plan().
|
static |
Definition at line 837 of file llvmjit_inline.cpp.
References I.
Referenced by llvm_build_inline_plan().
const float inline_cost_decay_factor = 0.5 |
Definition at line 104 of file llvmjit_inline.cpp.
Referenced by function_inlinable().
const int inline_initial_cost = 150 |
Definition at line 105 of file llvmjit_inline.cpp.
Referenced by llvm_build_inline_plan().
llvm::ManagedStatic<ModuleCache> module_cache |
Definition at line 112 of file llvmjit_inline.cpp.
Referenced by llvm_execute_inline_plan(), and load_module_cached().
llvm::ManagedStatic<SummaryCache> summary_cache |
Definition at line 114 of file llvmjit_inline.cpp.
Referenced by add_module_to_inline_search_path().