OmniSciDB  fe05a0c208
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NativeCodegen.cpp File Reference
#include "CodeGenerator.h"
#include "Execute.h"
#include "ExtensionFunctionsWhitelist.h"
#include "GpuSharedMemoryUtils.h"
#include "LLVMFunctionAttributesUtil.h"
#include "OutputBufferInitialization.h"
#include "QueryTemplateGenerator.h"
#include "CudaMgr/CudaMgr.h"
#include "OSDependent/omnisci_path.h"
#include "Shared/InlineNullValues.h"
#include "Shared/MathUtils.h"
#include "StreamingTopN.h"
#include <llvm/Bitcode/BitcodeReader.h>
#include <llvm/Bitcode/BitcodeWriter.h>
#include <llvm/ExecutionEngine/MCJIT.h>
#include <llvm/IR/Attributes.h>
#include <llvm/IR/GlobalValue.h>
#include <llvm/IR/InstIterator.h>
#include <llvm/IR/IntrinsicInst.h>
#include <llvm/IR/Intrinsics.h>
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/IR/Verifier.h>
#include <llvm/IRReader/IRReader.h>
#include <llvm/Linker/Linker.h>
#include <llvm/Support/Casting.h>
#include <llvm/Support/FileSystem.h>
#include <llvm/Support/FormattedStream.h>
#include <llvm/Support/MemoryBuffer.h>
#include <llvm/Support/SourceMgr.h>
#include <llvm/Support/TargetRegistry.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/Support/raw_os_ostream.h>
#include <llvm/Support/raw_ostream.h>
#include <llvm/Transforms/IPO.h>
#include <llvm/Transforms/IPO/AlwaysInliner.h>
#include <llvm/Transforms/IPO/PassManagerBuilder.h>
#include <llvm/Transforms/InstCombine/InstCombine.h>
#include <llvm/Transforms/Instrumentation.h>
#include <llvm/Transforms/Scalar.h>
#include <llvm/Transforms/Scalar/InstSimplifyPass.h>
#include <llvm/Transforms/Utils.h>
#include <llvm/Transforms/Utils/BasicBlockUtils.h>
#include <llvm/Transforms/Utils/Cloning.h>
+ Include dependency graph for NativeCodegen.cpp:

Go to the source code of this file.

Namespaces

 anonymous_namespace{NativeCodegen.cpp}
 

Macros

#define SHOW_DEFINED(MODULE)
 
#define SHOW_FUNCTIONS(MODULE)
 

Functions

void anonymous_namespace{NativeCodegen.cpp}::throw_parseIR_error (const llvm::SMDiagnostic &parse_error, std::string src="", const bool is_gpu=false)
 
template<typename T = void>
void anonymous_namespace{NativeCodegen.cpp}::show_defined (llvm::Module &module)
 
template<typename T = void>
void anonymous_namespace{NativeCodegen.cpp}::show_defined (llvm::Module *module)
 
template<typename T = void>
void anonymous_namespace{NativeCodegen.cpp}::show_defined (std::unique_ptr< llvm::Module > &module)
 
template<typename T = void>
void anonymous_namespace{NativeCodegen.cpp}::scan_function_calls (llvm::Function &F, std::unordered_set< std::string > &defined, std::unordered_set< std::string > &undefined, const std::unordered_set< std::string > &ignored)
 
template<typename T = void>
void anonymous_namespace{NativeCodegen.cpp}::scan_function_calls (llvm::Module &module, std::unordered_set< std::string > &defined, std::unordered_set< std::string > &undefined, const std::unordered_set< std::string > &ignored)
 
template<typename T = void>
std::tuple< std::unordered_set
< std::string >
, std::unordered_set
< std::string > > 
anonymous_namespace{NativeCodegen.cpp}::scan_function_calls (llvm::Module &module, const std::unordered_set< std::string > &ignored={})
 
void anonymous_namespace{NativeCodegen.cpp}::eliminate_dead_self_recursive_funcs (llvm::Module &M, const std::unordered_set< llvm::Function * > &live_funcs)
 
void anonymous_namespace{NativeCodegen.cpp}::optimize_ir (llvm::Function *query_func, llvm::Module *module, llvm::legacy::PassManager &pass_manager, const std::unordered_set< llvm::Function * > &live_funcs, const CompilationOptions &co)
 
void verify_function_ir (const llvm::Function *func)
 
std::string anonymous_namespace{NativeCodegen.cpp}::assemblyForCPU (ExecutionEngineWrapper &execution_engine, llvm::Module *module)
 
std::string anonymous_namespace{NativeCodegen.cpp}::cpp_to_llvm_name (const std::string &s)
 
std::string anonymous_namespace{NativeCodegen.cpp}::gen_array_any_all_sigs ()
 
std::string anonymous_namespace{NativeCodegen.cpp}::gen_translate_null_key_sigs ()
 
llvm::StringRef get_gpu_target_triple_string ()
 
llvm::StringRef get_gpu_data_layout ()
 
std::map< std::string,
std::string > 
get_device_parameters (bool cpu_only)
 
llvm::Module * read_template_module (llvm::LLVMContext &context)
 
void anonymous_namespace{NativeCodegen.cpp}::bind_pos_placeholders (const std::string &pos_fn_name, const bool use_resume_param, llvm::Function *query_func, llvm::Module *module)
 
void anonymous_namespace{NativeCodegen.cpp}::set_row_func_argnames (llvm::Function *row_func, const size_t in_col_count, const size_t agg_col_count, const bool hoist_literals)
 
llvm::Function * anonymous_namespace{NativeCodegen.cpp}::create_row_function (const size_t in_col_count, const size_t agg_col_count, const bool hoist_literals, llvm::Module *module, llvm::LLVMContext &context)
 
void anonymous_namespace{NativeCodegen.cpp}::bind_query (llvm::Function *query_func, const std::string &query_fname, llvm::Function *multifrag_query_func, llvm::Module *module)
 
std::vector< std::string > anonymous_namespace{NativeCodegen.cpp}::get_agg_fnames (const std::vector< Analyzer::Expr * > &target_exprs, const bool is_group_by)
 
std::unique_ptr< llvm::Module > g_rt_module (read_template_module(getGlobalLLVMContext()))
 
bool is_udf_module_present (bool cpu_only)
 
bool is_rt_udf_module_present (bool cpu_only)
 
void read_udf_gpu_module (const std::string &udf_ir_filename)
 
void read_udf_cpu_module (const std::string &udf_ir_filename)
 
void read_rt_udf_gpu_module (const std::string &udf_ir_string)
 
void read_rt_udf_cpu_module (const std::string &udf_ir_string)
 
template<typename InstType >
llvm::Value * anonymous_namespace{NativeCodegen.cpp}::find_variable_in_basic_block (llvm::Function *func, std::string bb_name, std::string variable_name)
 
size_t anonymous_namespace{NativeCodegen.cpp}::get_shared_memory_size (const bool shared_mem_used, const QueryMemoryDescriptor *query_mem_desc_ptr)
 
bool anonymous_namespace{NativeCodegen.cpp}::is_gpu_shared_mem_supported (const QueryMemoryDescriptor *query_mem_desc_ptr, const RelAlgExecutionUnit &ra_exe_unit, const CudaMgr_Namespace::CudaMgr *cuda_mgr, const ExecutorDeviceType device_type, const unsigned gpu_blocksize, const unsigned num_blocks_per_mp)
 
std::string anonymous_namespace{NativeCodegen.cpp}::serialize_llvm_metadata_footnotes (llvm::Function *query_func, CgenState *cgen_state)
 
std::unique_ptr< llvm::Module > runtime_module_shallow_copy (CgenState *cgen_state)
 
std::vector< llvm::Value * > generate_column_heads_load (const int num_columns, llvm::Value *byte_stream_arg, llvm::IRBuilder<> &ir_builder, llvm::LLVMContext &ctx)
 

Variables

float g_fraction_code_cache_to_evict = 0.2
 
std::unique_ptr< llvm::Module > udf_gpu_module
 
std::unique_ptr< llvm::Module > udf_cpu_module
 
std::unique_ptr< llvm::Module > rt_udf_gpu_module
 
std::unique_ptr< llvm::Module > rt_udf_cpu_module
 
std::unique_ptr< llvm::Module > g_rt_module
 
const std::string anonymous_namespace{NativeCodegen.cpp}::cuda_rt_decls
 

Macro Definition Documentation

#define SHOW_DEFINED (   MODULE)
Value:
{ \
std::cout << __func__ << "#" << __LINE__ << ": " #MODULE << " "; \
::show_defined(MODULE); \
}
void show_defined(llvm::Module &module)

Definition at line 145 of file NativeCodegen.cpp.

#define SHOW_FUNCTIONS (   MODULE)
Value:
{ \
std::cout << __func__ << "#" << __LINE__ << ": " #MODULE << " "; \
::show_functions(MODULE); \
}

Definition at line 151 of file NativeCodegen.cpp.

Function Documentation

std::unique_ptr<llvm::Module> g_rt_module ( read_template_module(getGlobalLLVMContext())  )
std::vector<llvm::Value*> generate_column_heads_load ( const int  num_columns,
llvm::Value *  byte_stream_arg,
llvm::IRBuilder<> &  ir_builder,
llvm::LLVMContext &  ctx 
)

Loads individual columns from a single, packed pointers buffer (the byte stream arg)

Definition at line 3109 of file NativeCodegen.cpp.

Referenced by TableFunctionCompilationContext::generateEntryPoint().

3112  {
3113  CHECK(byte_stream_arg);
3114  const auto max_col_local_id = num_columns - 1;
3115 
3116  std::vector<llvm::Value*> col_heads;
3117  for (int col_id = 0; col_id <= max_col_local_id; ++col_id) {
3118  col_heads.emplace_back(ir_builder.CreateLoad(ir_builder.CreateGEP(
3119  byte_stream_arg, llvm::ConstantInt::get(llvm::Type::getInt32Ty(ctx), col_id))));
3120  }
3121  return col_heads;
3122 }
#define CHECK(condition)
Definition: Logger.h:203

+ Here is the caller graph for this function:

std::map<std::string, std::string> get_device_parameters ( bool  cpu_only)

Definition at line 868 of file NativeCodegen.cpp.

References f.

868  {
869  std::map<std::string, std::string> result;
870 
871  result.insert(std::make_pair("cpu_name", llvm::sys::getHostCPUName()));
872  result.insert(std::make_pair("cpu_triple", llvm::sys::getProcessTriple()));
873  result.insert(
874  std::make_pair("cpu_cores", std::to_string(llvm::sys::getHostNumPhysicalCores())));
875  result.insert(std::make_pair("cpu_threads", std::to_string(cpu_threads())));
876 
877  // https://en.cppreference.com/w/cpp/language/types
878  std::string sizeof_types;
879  sizeof_types += "bool:" + std::to_string(sizeof(bool)) + ";";
880  sizeof_types += "size_t:" + std::to_string(sizeof(size_t)) + ";";
881  sizeof_types += "ssize_t:" + std::to_string(sizeof(ssize_t)) + ";";
882  sizeof_types += "char:" + std::to_string(sizeof(char)) + ";";
883  sizeof_types += "uchar:" + std::to_string(sizeof(unsigned char)) + ";";
884  sizeof_types += "short:" + std::to_string(sizeof(short)) + ";";
885  sizeof_types += "ushort:" + std::to_string(sizeof(unsigned short int)) + ";";
886  sizeof_types += "int:" + std::to_string(sizeof(int)) + ";";
887  sizeof_types += "uint:" + std::to_string(sizeof(unsigned int)) + ";";
888  sizeof_types += "long:" + std::to_string(sizeof(long int)) + ";";
889  sizeof_types += "ulong:" + std::to_string(sizeof(unsigned long int)) + ";";
890  sizeof_types += "longlong:" + std::to_string(sizeof(long long int)) + ";";
891  sizeof_types += "ulonglong:" + std::to_string(sizeof(unsigned long long int)) + ";";
892  sizeof_types += "float:" + std::to_string(sizeof(float)) + ";";
893  sizeof_types += "double:" + std::to_string(sizeof(double)) + ";";
894  sizeof_types += "longdouble:" + std::to_string(sizeof(long double)) + ";";
895  sizeof_types += "voidptr:" + std::to_string(sizeof(void*)) + ";";
896 
897  result.insert(std::make_pair("type_sizeof", sizeof_types));
898 
899  std::string null_values;
900  null_values += "boolean1:" + std::to_string(serialized_null_value<bool>()) + ";";
901  null_values += "boolean8:" + std::to_string(serialized_null_value<int8_t>()) + ";";
902  null_values += "int8:" + std::to_string(serialized_null_value<int8_t>()) + ";";
903  null_values += "int16:" + std::to_string(serialized_null_value<int16_t>()) + ";";
904  null_values += "int32:" + std::to_string(serialized_null_value<int32_t>()) + ";";
905  null_values += "int64:" + std::to_string(serialized_null_value<int64_t>()) + ";";
906  null_values += "uint8:" + std::to_string(serialized_null_value<uint8_t>()) + ";";
907  null_values += "uint16:" + std::to_string(serialized_null_value<uint16_t>()) + ";";
908  null_values += "uint32:" + std::to_string(serialized_null_value<uint32_t>()) + ";";
909  null_values += "uint64:" + std::to_string(serialized_null_value<uint64_t>()) + ";";
910  null_values += "float32:" + std::to_string(serialized_null_value<float>()) + ";";
911  null_values += "float64:" + std::to_string(serialized_null_value<double>()) + ";";
912  null_values +=
913  "Array<boolean8>:" + std::to_string(serialized_null_value<int8_t, true>()) + ";";
914  null_values +=
915  "Array<int8>:" + std::to_string(serialized_null_value<int8_t, true>()) + ";";
916  null_values +=
917  "Array<int16>:" + std::to_string(serialized_null_value<int16_t, true>()) + ";";
918  null_values +=
919  "Array<int32>:" + std::to_string(serialized_null_value<int32_t, true>()) + ";";
920  null_values +=
921  "Array<int64>:" + std::to_string(serialized_null_value<int64_t, true>()) + ";";
922  null_values +=
923  "Array<float32>:" + std::to_string(serialized_null_value<float, true>()) + ";";
924  null_values +=
925  "Array<float64>:" + std::to_string(serialized_null_value<double, true>()) + ";";
926 
927  result.insert(std::make_pair("null_values", null_values));
928 
929  llvm::StringMap<bool> cpu_features;
930  if (llvm::sys::getHostCPUFeatures(cpu_features)) {
931  std::string features_str = "";
932  for (auto it = cpu_features.begin(); it != cpu_features.end(); ++it) {
933  features_str += (it->getValue() ? " +" : " -");
934  features_str += it->getKey().str();
935  }
936  result.insert(std::make_pair("cpu_features", features_str));
937  }
938 
939  result.insert(std::make_pair("llvm_version",
940  std::to_string(LLVM_VERSION_MAJOR) + "." +
941  std::to_string(LLVM_VERSION_MINOR) + "." +
942  std::to_string(LLVM_VERSION_PATCH)));
943 
944 #ifdef HAVE_CUDA
945  if (!cpu_only) {
946  int device_count = 0;
947  checkCudaErrors(cuDeviceGetCount(&device_count));
948  if (device_count) {
949  CUdevice device{};
950  char device_name[256];
951  int major = 0, minor = 0;
952  int driver_version;
953  checkCudaErrors(cuDeviceGet(&device, 0)); // assuming homogeneous multi-GPU system
954  checkCudaErrors(cuDeviceGetName(device_name, 256, device));
955  checkCudaErrors(cuDeviceGetAttribute(
956  &major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, device));
957  checkCudaErrors(cuDeviceGetAttribute(
958  &minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, device));
959  checkCudaErrors(cuDriverGetVersion(&driver_version));
960 
961  result.insert(std::make_pair("gpu_name", device_name));
962  result.insert(std::make_pair("gpu_count", std::to_string(device_count)));
963  result.insert(std::make_pair("gpu_compute_capability",
964  std::to_string(major) + "." + std::to_string(minor)));
965  result.insert(std::make_pair("gpu_triple", get_gpu_target_triple_string()));
966  result.insert(std::make_pair("gpu_datalayout", get_gpu_data_layout()));
967  result.insert(std::make_pair("gpu_driver",
968  "CUDA " + std::to_string(driver_version / 1000) + "." +
969  std::to_string((driver_version % 1000) / 10)));
970  }
971  }
972 #endif
973 
974  return result;
975 }
void checkCudaErrors(CUresult err)
Definition: sample.cpp:38
llvm::StringRef get_gpu_data_layout()
std::string to_string(char const *&&v)
llvm::StringRef get_gpu_target_triple_string()
int CUdevice
Definition: nocuda.h:20
int cpu_threads()
Definition: thread_count.h:24
llvm::StringRef get_gpu_data_layout ( )

Definition at line 860 of file NativeCodegen.cpp.

References f, and udf_gpu_module.

860  {
861  return llvm::StringRef(
862  "e-p:64:64:64-i1:8:8-i8:8:8-"
863  "i16:16:16-i32:32:32-i64:64:64-"
864  "f32:32:32-f64:64:64-v16:16:16-"
865  "v32:32:32-v64:64:64-v128:128:128-n16:32:64");
866 }
llvm::StringRef get_gpu_target_triple_string ( )

Definition at line 856 of file NativeCodegen.cpp.

856  {
857  return llvm::StringRef("nvptx64-nvidia-cuda");
858 }
bool is_rt_udf_module_present ( bool  cpu_only)

Definition at line 1701 of file NativeCodegen.cpp.

1701  {
1702  return (cpu_only || rt_udf_gpu_module != nullptr) && (rt_udf_cpu_module != nullptr);
1703 }
std::unique_ptr< llvm::Module > rt_udf_cpu_module
std::unique_ptr< llvm::Module > rt_udf_gpu_module
bool is_udf_module_present ( bool  cpu_only)

Definition at line 1697 of file NativeCodegen.cpp.

1697  {
1698  return (cpu_only || udf_gpu_module != nullptr) && (udf_cpu_module != nullptr);
1699 }
std::unique_ptr< llvm::Module > udf_gpu_module
std::unique_ptr< llvm::Module > udf_cpu_module
void read_rt_udf_cpu_module ( const std::string &  udf_ir_string)

Definition at line 1758 of file NativeCodegen.cpp.

Referenced by DBHandler::register_runtime_extension_functions().

1758  {
1759  llvm::SMDiagnostic parse_error;
1760 
1761  auto buf =
1762  std::make_unique<llvm::MemoryBufferRef>(udf_ir_string, "Runtime UDF for CPU");
1763 
1764  rt_udf_cpu_module = llvm::parseIR(*buf, parse_error, getGlobalLLVMContext());
1765  if (!rt_udf_cpu_module) {
1766  LOG(IR) << "read_rt_udf_cpu_module:LLVM IR:\n" << udf_ir_string << "\nEnd of LLVM IR";
1767  throw_parseIR_error(parse_error);
1768  }
1769 }
std::unique_ptr< llvm::Module > rt_udf_cpu_module
#define LOG(tag)
Definition: Logger.h:194
void throw_parseIR_error(const llvm::SMDiagnostic &parse_error, std::string src="", const bool is_gpu=false)
llvm::LLVMContext & getGlobalLLVMContext()

+ Here is the caller graph for this function:

void read_rt_udf_gpu_module ( const std::string &  udf_ir_string)

Definition at line 1735 of file NativeCodegen.cpp.

Referenced by DBHandler::register_runtime_extension_functions().

1735  {
1736  llvm::SMDiagnostic parse_error;
1737 
1738  auto buf =
1739  std::make_unique<llvm::MemoryBufferRef>(udf_ir_string, "Runtime UDF for GPU");
1740 
1741  rt_udf_gpu_module = llvm::parseIR(*buf, parse_error, getGlobalLLVMContext());
1742  if (!rt_udf_gpu_module) {
1743  LOG(IR) << "read_rt_udf_gpu_module:NVVM IR:\n" << udf_ir_string << "\nEnd of NNVM IR";
1744  throw_parseIR_error(parse_error, "", /* is_gpu= */ true);
1745  }
1746 
1747  llvm::Triple gpu_triple(rt_udf_gpu_module->getTargetTriple());
1748  if (!gpu_triple.isNVPTX()) {
1749  LOG(IR) << "read_rt_udf_gpu_module:NVVM IR:\n" << udf_ir_string << "\nEnd of NNVM IR";
1750  LOG(WARNING) << "Expected triple nvptx64-nvidia-cuda for NVVM IR but got "
1751  << gpu_triple.str()
1752  << ". Executing runtime UDFs on GPU will be disabled.";
1753  rt_udf_gpu_module = nullptr;
1754  return;
1755  }
1756 }
#define LOG(tag)
Definition: Logger.h:194
std::unique_ptr< llvm::Module > rt_udf_gpu_module
void throw_parseIR_error(const llvm::SMDiagnostic &parse_error, std::string src="", const bool is_gpu=false)
llvm::LLVMContext & getGlobalLLVMContext()

+ Here is the caller graph for this function:

llvm::Module* read_template_module ( llvm::LLVMContext &  context)

Definition at line 1352 of file NativeCodegen.cpp.

1352  {
1353  llvm::SMDiagnostic err;
1354 
1355  auto buffer_or_error = llvm::MemoryBuffer::getFile(omnisci::get_root_abs_path() +
1356  "/QueryEngine/RuntimeFunctions.bc");
1357  CHECK(!buffer_or_error.getError()) << "root path=" << omnisci::get_root_abs_path();
1358  llvm::MemoryBuffer* buffer = buffer_or_error.get().get();
1359 
1360  auto owner = llvm::parseBitcodeFile(buffer->getMemBufferRef(), context);
1361  CHECK(!owner.takeError());
1362  auto module = owner.get().release();
1363  CHECK(module);
1364 
1365  return module;
1366 }
#define CHECK(condition)
Definition: Logger.h:203
std::string get_root_abs_path()
void read_udf_cpu_module ( const std::string &  udf_ir_filename)

Definition at line 1724 of file NativeCodegen.cpp.

Referenced by UdfCompiler::readCpuCompiledModule().

1724  {
1725  llvm::SMDiagnostic parse_error;
1726 
1727  llvm::StringRef file_name_arg(udf_ir_filename);
1728 
1729  udf_cpu_module = llvm::parseIRFile(file_name_arg, parse_error, getGlobalLLVMContext());
1730  if (!udf_cpu_module) {
1731  throw_parseIR_error(parse_error, udf_ir_filename);
1732  }
1733 }
void throw_parseIR_error(const llvm::SMDiagnostic &parse_error, std::string src="", const bool is_gpu=false)
std::unique_ptr< llvm::Module > udf_cpu_module
llvm::LLVMContext & getGlobalLLVMContext()

+ Here is the caller graph for this function:

void read_udf_gpu_module ( const std::string &  udf_ir_filename)

Definition at line 1705 of file NativeCodegen.cpp.

Referenced by UdfCompiler::readGpuCompiledModule().

1705  {
1706  llvm::SMDiagnostic parse_error;
1707 
1708  llvm::StringRef file_name_arg(udf_ir_filename);
1709  udf_gpu_module = llvm::parseIRFile(file_name_arg, parse_error, getGlobalLLVMContext());
1710 
1711  if (!udf_gpu_module) {
1712  throw_parseIR_error(parse_error, udf_ir_filename, /* is_gpu= */ true);
1713  }
1714 
1715  llvm::Triple gpu_triple(udf_gpu_module->getTargetTriple());
1716  if (!gpu_triple.isNVPTX()) {
1717  LOG(WARNING)
1718  << "Expected triple nvptx64-nvidia-cuda for NVVM IR of loadtime UDFs but got "
1719  << gpu_triple.str() << ". Disabling the NVVM IR module.";
1720  udf_gpu_module = nullptr;
1721  }
1722 }
std::unique_ptr< llvm::Module > udf_gpu_module
#define LOG(tag)
Definition: Logger.h:194
void throw_parseIR_error(const llvm::SMDiagnostic &parse_error, std::string src="", const bool is_gpu=false)
llvm::LLVMContext & getGlobalLLVMContext()

+ Here is the caller graph for this function:

std::unique_ptr<llvm::Module> runtime_module_shallow_copy ( CgenState cgen_state)

Makes a shallow copy (just declarations) of the runtime module. Function definitions are cloned only if they're used from the generated code.

Definition at line 3097 of file NativeCodegen.cpp.

Referenced by ResultSetReductionJIT::codegen(), GpuReductionHelperJIT::codegen(), StubGenerator::generateStub(), and TableFunctionCompilationContext::TableFunctionCompilationContext().

3097  {
3098  return llvm::CloneModule(
3099  *g_rt_module.get(), cgen_state->vmap_, [](const llvm::GlobalValue* gv) {
3100  auto func = llvm::dyn_cast<llvm::Function>(gv);
3101  if (!func) {
3102  return true;
3103  }
3104  return (func->getLinkage() == llvm::GlobalValue::LinkageTypes::PrivateLinkage ||
3105  func->getLinkage() == llvm::GlobalValue::LinkageTypes::InternalLinkage);
3106  });
3107 }
std::unique_ptr< llvm::Module > g_rt_module
llvm::ValueToValueMapTy vmap_
Definition: CgenState.h:334

+ Here is the caller graph for this function:

void verify_function_ir ( const llvm::Function *  func)

Definition at line 362 of file NativeCodegen.cpp.

References logger::FATAL, and LOG.

Referenced by GpuSharedMemCodeBuilder::codegen(), anonymous_namespace{JoinLoopTest.cpp}::create_loop_test_function(), TableFunctionCompilationContext::generateEntryPoint(), StubGenerator::generateStub(), and translate_function().

362  {
363  std::stringstream err_ss;
364  llvm::raw_os_ostream err_os(err_ss);
365  err_os << "\n-----\n";
366  if (llvm::verifyFunction(*func, &err_os)) {
367  err_os << "\n-----\n";
368  func->print(err_os, nullptr);
369  err_os << "\n-----\n";
370  LOG(FATAL) << err_ss.str();
371  }
372 }
#define LOG(tag)
Definition: Logger.h:194

+ Here is the caller graph for this function:

Variable Documentation

float g_fraction_code_cache_to_evict = 0.2

Definition at line 71 of file NativeCodegen.cpp.

Referenced by CommandLineOptions::fillAdvancedOptions().

std::unique_ptr<llvm::Module> g_rt_module
std::unique_ptr<llvm::Module> rt_udf_cpu_module

Definition at line 76 of file NativeCodegen.cpp.

Referenced by TableFunctionCompilationContext::finalize().

std::unique_ptr<llvm::Module> rt_udf_gpu_module

Definition at line 75 of file NativeCodegen.cpp.

Referenced by TableFunctionCompilationContext::finalize().

std::unique_ptr<llvm::Module> udf_cpu_module

Definition at line 74 of file NativeCodegen.cpp.

std::unique_ptr<llvm::Module> udf_gpu_module

Definition at line 73 of file NativeCodegen.cpp.

Referenced by get_gpu_data_layout().