MCPcopy Create free account
hub / github.com/apache/impala / CreateFromMemory

Method CreateFromMemory

be/src/codegen/llvm-codegen.cc:268–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266}
267
268Status LlvmCodeGen::CreateFromMemory(FragmentState* state, ObjectPool* pool,
269 MemTracker* parent_mem_tracker, const string& id, scoped_ptr<LlvmCodeGen>* codegen) {
270 codegen->reset(new LlvmCodeGen(state, pool, parent_mem_tracker, id));
271 SCOPED_TIMER((*codegen)->profile_->total_time_counter());
272 SCOPED_TIMER((*codegen)->prepare_module_timer_);
273 SCOPED_THREAD_COUNTER_MEASUREMENT((*codegen)->llvm_thread_counters());
274
275 llvm::StringRef module_ir;
276 string module_name = "Impala IR";
277 if (FLAGS_llvm_ir_opt == "O1") {
278 module_ir = llvm::StringRef(
279 reinterpret_cast<const char*>(impala_llvm_o1_ir), impala_llvm_o1_ir_len);
280 } else if (FLAGS_llvm_ir_opt == "O2") {
281 module_ir = llvm::StringRef(
282 reinterpret_cast<const char*>(impala_llvm_o2_ir), impala_llvm_o2_ir_len);
283 } else if (FLAGS_llvm_ir_opt == "Os") {
284 module_ir = llvm::StringRef(
285 reinterpret_cast<const char*>(impala_llvm_os_ir), impala_llvm_os_ir_len);
286 } else {
287 CHECK(false) << "llvm_ir_opt flag invalid; try O1, O2, or Os.";
288 }
289#if __x86_64__
290 // By default, Impala now requires AVX2 support, but the enable_legacy_avx_support
291 // flag can allow running on AVX machines. The minimum requirement must have already
292 // been enforced prior to this call, so this only needs to select the appropriate
293 // LLVM IR to use.
294 if (IsCPUFeatureEnabled(CpuInfo::AVX2)) {
295 // Use the default IR that supports AVX2
296 module_name = "Impala IR with AVX2 support";
297 } else if (FLAGS_enable_legacy_avx_support && IsCPUFeatureEnabled(CpuInfo::AVX)) {
298 // If there is no AVX but legacy mode is enabled, use legacy IR with AVX support
299 module_ir = llvm::StringRef(
300 reinterpret_cast<const char*>(impala_legacy_avx_llvm_ir),
301 impala_legacy_avx_llvm_ir_len);
302 module_name = "Legacy Impala IR with AVX support";
303 } else {
304 // This should have been enforced earlier.
305 CHECK(false) << "CPU is missing AVX/AVX2 support";
306 }
307#endif
308
309 unique_ptr<llvm::MemoryBuffer> module_ir_buf(
310 llvm::MemoryBuffer::getMemBuffer(module_ir, "", false));
311 unique_ptr<llvm::Module> loaded_module;
312 Status status = (*codegen)->LoadModuleFromMemory(move(module_ir_buf),
313 module_name, &loaded_module);
314 if (!status.ok()) goto error;
315 status = (*codegen)->Init(move(loaded_module));
316 if (!status.ok()) goto error;
317 return Status::OK();
318error:
319 (*codegen)->Close();
320 return status;
321}
322
323Status LlvmCodeGen::LoadModuleFromFile(
324 const string& file, unique_ptr<llvm::Module>* module) {

Callers

nothing calls this directly

Calls 9

moveFunction · 0.85
OKFunction · 0.85
total_time_counterMethod · 0.80
llvm_thread_countersMethod · 0.80
LoadModuleFromMemoryMethod · 0.80
resetMethod · 0.65
okMethod · 0.45
InitMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected