From a340bc7a00bdbdf93f307c95e33545ed7a2b9245 Mon Sep 17 00:00:00 2001 From: trueeyu Date: Tue, 25 Feb 2020 13:47:20 +0800 Subject: [PATCH] Remove unused LLVM related codes of directory:be/src/runtime (#2910) (#2985) Remove unused LLVM related codes of directory (step 4):be/src/runtime (#2910) there are many LLVM related codes in code base, but these codes are not really used. The higher version of GCC is not compatible with the LLVM 3.4.2 version currently used by Doris. The PR delete all LLVM related code of directory: be/src/runtime --- be/src/exec/aggregation_node.cpp | 1 - be/src/exec/exec_node.cpp | 1 - be/src/exec/hash_table.cpp | 2 - .../exec/new_partitioned_aggregation_node.cc | 1 - be/src/exprs/arithmetic_expr.cpp | 1 - be/src/exprs/binary_predicate.cpp | 1 - be/src/exprs/case_expr.cpp | 1 - be/src/exprs/cast_expr.cpp | 1 - be/src/exprs/compound_predicate.cpp | 1 - be/src/exprs/expr.cpp | 1 - be/src/exprs/literal.cpp | 1 - be/src/exprs/null_literal.cpp | 1 - be/src/exprs/slot_ref.cpp | 1 - be/src/runtime/decimalv2_value.cpp | 2 - be/src/runtime/decimalv2_value.h | 3 - be/src/runtime/descriptors.cpp | 181 +----------------- be/src/runtime/descriptors.h | 41 ---- be/src/runtime/mem_pool.cpp | 1 - be/src/runtime/mem_pool.h | 4 - be/src/runtime/plan_fragment_executor.cpp | 35 ---- be/src/runtime/plan_fragment_executor.h | 8 - be/src/runtime/runtime_state.cpp | 27 --- be/src/runtime/runtime_state.h | 26 --- be/src/runtime/tuple.cpp | 2 - be/src/runtime/tuple.h | 3 - be/src/runtime/tuple_row.cpp | 1 - be/src/runtime/tuple_row.h | 4 - be/test/runtime/data_stream_test.cpp | 2 - 28 files changed, 4 insertions(+), 350 deletions(-) diff --git a/be/src/exec/aggregation_node.cpp b/be/src/exec/aggregation_node.cpp index 1f50f46378..0d1806eaac 100644 --- a/be/src/exec/aggregation_node.cpp +++ b/be/src/exec/aggregation_node.cpp @@ -23,7 +23,6 @@ #include #include -#include "codegen/codegen_anyval.h" #include "exec/hash_table.hpp" #include "exprs/agg_fn_evaluator.h" #include "exprs/expr.h" diff --git a/be/src/exec/exec_node.cpp b/be/src/exec/exec_node.cpp index d8bd463216..e158b5fede 100644 --- a/be/src/exec/exec_node.cpp +++ b/be/src/exec/exec_node.cpp @@ -21,7 +21,6 @@ #include #include -#include "codegen/codegen_anyval.h" #include "common/object_pool.h" #include "common/status.h" #include "exprs/expr_context.h" diff --git a/be/src/exec/hash_table.cpp b/be/src/exec/hash_table.cpp index 975c493d6f..706318afb4 100644 --- a/be/src/exec/hash_table.cpp +++ b/be/src/exec/hash_table.cpp @@ -17,8 +17,6 @@ #include "exec/hash_table.hpp" -#include "codegen/codegen_anyval.h" - #include "exprs/expr.h" #include "runtime/raw_value.h" #include "runtime/string_value.hpp" diff --git a/be/src/exec/new_partitioned_aggregation_node.cc b/be/src/exec/new_partitioned_aggregation_node.cc index 689567cecf..24688031b3 100644 --- a/be/src/exec/new_partitioned_aggregation_node.cc +++ b/be/src/exec/new_partitioned_aggregation_node.cc @@ -22,7 +22,6 @@ #include #include -//#include "codegen/codegen_anyval.h" #include "exec/new_partitioned_hash_table.h" #include "exec/new_partitioned_hash_table.inline.h" #include "exprs/new_agg_fn_evaluator.h" diff --git a/be/src/exprs/arithmetic_expr.cpp b/be/src/exprs/arithmetic_expr.cpp index adf7239334..2fd10436bb 100644 --- a/be/src/exprs/arithmetic_expr.cpp +++ b/be/src/exprs/arithmetic_expr.cpp @@ -17,7 +17,6 @@ #include "exprs/arithmetic_expr.h" -#include "codegen/codegen_anyval.h" #include "runtime/runtime_state.h" namespace doris { diff --git a/be/src/exprs/binary_predicate.cpp b/be/src/exprs/binary_predicate.cpp index ea79e3649d..d2808cb3fa 100644 --- a/be/src/exprs/binary_predicate.cpp +++ b/be/src/exprs/binary_predicate.cpp @@ -19,7 +19,6 @@ #include -#include "codegen/codegen_anyval.h" #include "util/debug_util.h" #include "gen_cpp/Exprs_types.h" #include "runtime/runtime_state.h" diff --git a/be/src/exprs/case_expr.cpp b/be/src/exprs/case_expr.cpp index 6ca84e8070..b1fde7c203 100644 --- a/be/src/exprs/case_expr.cpp +++ b/be/src/exprs/case_expr.cpp @@ -17,7 +17,6 @@ #include "exprs/case_expr.h" -#include "codegen/codegen_anyval.h" #include "exprs/anyval_util.h" #include "runtime/runtime_state.h" #include "gen_cpp/Exprs_types.h" diff --git a/be/src/exprs/cast_expr.cpp b/be/src/exprs/cast_expr.cpp index 5e5bc82d15..f33ae0d2e6 100644 --- a/be/src/exprs/cast_expr.cpp +++ b/be/src/exprs/cast_expr.cpp @@ -17,7 +17,6 @@ #include "exprs/cast_expr.h" -#include "codegen/codegen_anyval.h" #include "runtime/runtime_state.h" namespace doris { diff --git a/be/src/exprs/compound_predicate.cpp b/be/src/exprs/compound_predicate.cpp index 3dd52cecab..ee75564a9a 100644 --- a/be/src/exprs/compound_predicate.cpp +++ b/be/src/exprs/compound_predicate.cpp @@ -19,7 +19,6 @@ #include -#include "codegen/codegen_anyval.h" #include "util/debug_util.h" #include "runtime/runtime_state.h" diff --git a/be/src/exprs/expr.cpp b/be/src/exprs/expr.cpp index 5b114d34d4..b5ade12204 100644 --- a/be/src/exprs/expr.cpp +++ b/be/src/exprs/expr.cpp @@ -21,7 +21,6 @@ #include #include -#include "codegen/codegen_anyval.h" #include "common/object_pool.h" #include "common/status.h" #include "exprs/anyval_util.h" diff --git a/be/src/exprs/literal.cpp b/be/src/exprs/literal.cpp index 061f3c5952..398b5c32a0 100644 --- a/be/src/exprs/literal.cpp +++ b/be/src/exprs/literal.cpp @@ -19,7 +19,6 @@ #include -#include "codegen/codegen_anyval.h" #include "gen_cpp/Exprs_types.h" #include "util/string_parser.hpp" #include "runtime/runtime_state.h" diff --git a/be/src/exprs/null_literal.cpp b/be/src/exprs/null_literal.cpp index baade57d6c..c4e8e43aee 100644 --- a/be/src/exprs/null_literal.cpp +++ b/be/src/exprs/null_literal.cpp @@ -17,7 +17,6 @@ #include "null_literal.h" -#include "codegen/codegen_anyval.h" #include "gen_cpp/Exprs_types.h" #include "runtime/runtime_state.h" diff --git a/be/src/exprs/slot_ref.cpp b/be/src/exprs/slot_ref.cpp index 439c2dee46..ccba53d540 100644 --- a/be/src/exprs/slot_ref.cpp +++ b/be/src/exprs/slot_ref.cpp @@ -19,7 +19,6 @@ #include -#include "codegen/codegen_anyval.h" #include "gen_cpp/Exprs_types.h" #include "runtime/runtime_state.h" #include "util/types.h" diff --git a/be/src/runtime/decimalv2_value.cpp b/be/src/runtime/decimalv2_value.cpp index 72673cdcbf..dacb88dd2d 100644 --- a/be/src/runtime/decimalv2_value.cpp +++ b/be/src/runtime/decimalv2_value.cpp @@ -24,8 +24,6 @@ namespace doris { -const char* DecimalV2Value::_s_llvm_class_name = "class.doris::DecimalV2Value"; - static inline int128_t abs(const int128_t& x) { return (x < 0) ? -x : x; } // x>=0 && y>=0 diff --git a/be/src/runtime/decimalv2_value.h b/be/src/runtime/decimalv2_value.h index 9b3de338f2..a1e99f670d 100644 --- a/be/src/runtime/decimalv2_value.h +++ b/be/src/runtime/decimalv2_value.h @@ -319,9 +319,6 @@ public: return _value == 0; } - // For C++/IR interop, we need to be able to look up types by name. - static const char* _s_llvm_class_name; - private: int128_t _value; diff --git a/be/src/runtime/descriptors.cpp b/be/src/runtime/descriptors.cpp index 6044b5009e..4450d75f80 100644 --- a/be/src/runtime/descriptors.cpp +++ b/be/src/runtime/descriptors.cpp @@ -21,10 +21,6 @@ #include #include -#include -#include - -#include "codegen/llvm_codegen.h" #include "common/object_pool.h" #include "gen_cpp/Descriptors_types.h" #include "gen_cpp/descriptors.pb.h" @@ -58,10 +54,7 @@ SlotDescriptor::SlotDescriptor(const TSlotDescriptor& tdesc) _slot_idx(tdesc.slotIdx), _slot_size(_type.get_slot_size()), _field_idx(-1), - _is_materialized(tdesc.isMaterialized), - _is_null_fn(NULL), - _set_not_null_fn(NULL), - _set_null_fn(NULL) { + _is_materialized(tdesc.isMaterialized) { } SlotDescriptor::SlotDescriptor(const PSlotDescriptor& pdesc) @@ -75,10 +68,7 @@ SlotDescriptor::SlotDescriptor(const PSlotDescriptor& pdesc) _slot_idx(pdesc.slot_idx()), _slot_size(_type.get_slot_size()), _field_idx(-1), - _is_materialized(pdesc.is_materialized()), - _is_null_fn(NULL), - _set_not_null_fn(NULL), - _set_null_fn(NULL) { + _is_materialized(pdesc.is_materialized()) { } void SlotDescriptor::to_protobuf(PSlotDescriptor* pslot) const { @@ -208,8 +198,7 @@ TupleDescriptor::TupleDescriptor(const TTupleDescriptor& tdesc) : _num_null_bytes(tdesc.numNullBytes), _num_materialized_slots(0), _slots(), - _has_varlen_slots(false), - _llvm_struct(NULL) { + _has_varlen_slots(false) { if (false == tdesc.__isset.numNullSlots) { //be compatible for existing tables with no NULL value _num_null_slots = 0; @@ -225,8 +214,7 @@ TupleDescriptor::TupleDescriptor(const PTupleDescriptor& pdesc) _num_null_bytes(pdesc.num_null_bytes()), _num_materialized_slots(0), _slots(), - _has_varlen_slots(false), - _llvm_struct(NULL) { + _has_varlen_slots(false) { if (!pdesc.has_num_null_slots()) { //be compatible for existing tables with no NULL value _num_null_slots = 0; @@ -589,167 +577,6 @@ bool SlotDescriptor::layout_equals(const SlotDescriptor& other_desc) const { return true; } -// Generate function to check if a slot is null. The resulting IR looks like: -// (in this case the tuple contains only a nullable double) -// define i1 @IsNull({ i8, double }* %tuple) { -// entry: -// %null_byte_ptr = getelementptr inbounds { i8, double }* %tuple, i32 0, i32 0 -// %null_byte = load i8* %null_byte_ptr -// %null_mask = and i8 %null_byte, 1 -// %is_null = icmp ne i8 %null_mask, 0 -// ret i1 %is_null -// } -llvm::Function* SlotDescriptor::codegen_is_null(LlvmCodeGen* codegen, llvm::StructType* tuple) { - if (_is_null_fn != NULL) { - return _is_null_fn; - } - - llvm::PointerType* tuple_ptr_type = llvm::PointerType::get(tuple, 0); - LlvmCodeGen::FnPrototype prototype(codegen, "IsNull", codegen->get_type(TYPE_BOOLEAN)); - prototype.add_argument(LlvmCodeGen::NamedVariable("tuple", tuple_ptr_type)); - - llvm::Value* mask = codegen->get_int_constant(TYPE_TINYINT, _null_indicator_offset.bit_mask); - llvm::Value* zero = codegen->get_int_constant(TYPE_TINYINT, 0); - int byte_offset = _null_indicator_offset.byte_offset; - - LlvmCodeGen::LlvmBuilder builder(codegen->context()); - llvm::Value* tuple_ptr = NULL; - llvm::Function* fn = prototype.generate_prototype(&builder, &tuple_ptr); - - llvm::Value* null_byte_ptr = builder.CreateStructGEP(tuple_ptr, byte_offset, "null_byte_ptr"); - llvm::Value* null_byte = builder.CreateLoad(null_byte_ptr, "null_byte"); - llvm::Value* null_mask = builder.CreateAnd(null_byte, mask, "null_mask"); - llvm::Value* is_null = builder.CreateICmpNE(null_mask, zero, "is_null"); - builder.CreateRet(is_null); - - return _is_null_fn = codegen->finalize_function(fn); -} - -// Generate function to set a slot to be null or not-null. The resulting IR -// for SetNotNull looks like: -// (in this case the tuple contains only a nullable double) -// define void @SetNotNull({ i8, double }* %tuple) { -// entry: -// %null_byte_ptr = getelementptr inbounds { i8, double }* %tuple, i32 0, i32 0 -// %null_byte = load i8* %null_byte_ptr -// %0 = and i8 %null_byte, -2 -// store i8 %0, i8* %null_byte_ptr -// ret void -// } -llvm::Function* SlotDescriptor::codegen_update_null(LlvmCodeGen* codegen, - llvm::StructType* tuple, bool set_null) { - if (set_null && _set_null_fn != NULL) { - return _set_null_fn; - } - - if (!set_null && _set_not_null_fn != NULL) { - return _set_not_null_fn; - } - - llvm::PointerType* tuple_ptr_type = llvm::PointerType::get(tuple, 0); - LlvmCodeGen::FnPrototype prototype(codegen, (set_null) ? "SetNull" : "SetNotNull", - codegen->void_type()); - prototype.add_argument(LlvmCodeGen::NamedVariable("tuple", tuple_ptr_type)); - - LlvmCodeGen::LlvmBuilder builder(codegen->context()); - llvm::Value* tuple_ptr = NULL; - llvm::Function* fn = prototype.generate_prototype(&builder, &tuple_ptr); - - llvm::Value* null_byte_ptr = - builder.CreateStructGEP( - tuple_ptr, _null_indicator_offset.byte_offset, "null_byte_ptr"); - llvm::Value* null_byte = builder.CreateLoad(null_byte_ptr, "null_byte"); - llvm::Value* result = NULL; - - if (set_null) { - llvm::Value* null_set = codegen->get_int_constant( - TYPE_TINYINT, _null_indicator_offset.bit_mask); - result = builder.CreateOr(null_byte, null_set); - } else { - llvm::Value* null_clear_val = - codegen->get_int_constant(TYPE_TINYINT, ~_null_indicator_offset.bit_mask); - result = builder.CreateAnd(null_byte, null_clear_val); - } - - builder.CreateStore(result, null_byte_ptr); - builder.CreateRetVoid(); - - fn = codegen->finalize_function(fn); - - if (set_null) { - _set_null_fn = fn; - } else { - _set_not_null_fn = fn; - } - - return fn; -} - -// The default llvm packing is identical to what we do in the FE. Each field is aligned -// to begin on the size for that type. -// TODO: Understand llvm::SetTargetData which allows you to explicitly define the packing -// rules. -llvm::StructType* TupleDescriptor::generate_llvm_struct(LlvmCodeGen* codegen) { - // If we already generated the llvm type, just return it. - if (_llvm_struct != NULL) { - return _llvm_struct; - } - - // For each null byte, add a byte to the struct - std::vector struct_fields; - struct_fields.resize(_num_null_bytes + _num_materialized_slots); - - for (int i = 0; i < _num_null_bytes; ++i) { - struct_fields[i] = codegen->get_type(TYPE_TINYINT); - } - - // Add the slot types to the struct description. - for (int i = 0; i < slots().size(); ++i) { - SlotDescriptor* slot_desc = slots()[i]; - - if (slot_desc->is_materialized()) { - slot_desc->_field_idx = slot_desc->_slot_idx + _num_null_bytes; - DCHECK_LT(slot_desc->field_idx(), struct_fields.size()); - struct_fields[slot_desc->field_idx()] = codegen->get_type(slot_desc->type().type); - } - } - - // Construct the struct type. - llvm::StructType* tuple_struct = llvm::StructType::get( - codegen->context(), llvm::ArrayRef(struct_fields)); - - // Verify the alignment is correct. It is essential that the layout matches - // identically. If the layout does not match, return NULL indicating the - // struct could not be codegen'd. This will trigger codegen for anything using - // the tuple to be disabled. - const llvm::DataLayout* data_layout = codegen->execution_engine()->getDataLayout(); - const llvm::StructLayout* layout = data_layout->getStructLayout(tuple_struct); - layout = data_layout->getStructLayout(tuple_struct); - - if (layout->getSizeInBytes() != byte_size()) { - DCHECK_EQ(layout->getSizeInBytes(), byte_size()); - return NULL; - } - - for (int i = 0; i < slots().size(); ++i) { - SlotDescriptor* slot_desc = slots()[i]; - - if (slot_desc->is_materialized()) { - int field_idx = slot_desc->field_idx(); - - // Verify that the byte offset in the llvm struct matches the tuple offset - // computed in the FE - if (layout->getElementOffset(field_idx) != slot_desc->tuple_offset()) { - DCHECK_EQ(layout->getElementOffset(field_idx), slot_desc->tuple_offset()); - return NULL; - } - } - } - - _llvm_struct = tuple_struct; - return tuple_struct; -} - std::string DescriptorTbl::debug_string() const { std::stringstream out; out << "tuples:\n"; diff --git a/be/src/runtime/descriptors.h b/be/src/runtime/descriptors.h index 3a7489fe9c..61f18fe1d7 100644 --- a/be/src/runtime/descriptors.h +++ b/be/src/runtime/descriptors.h @@ -34,15 +34,8 @@ #include "gen_cpp/Types_types.h" #include "runtime/types.h" -namespace llvm { -class Function; -class PointerType; -class StructType; -}; - namespace doris { -class LlvmCodeGen; class ObjectPool; class TDescriptorTable; class TSlotDescriptor; @@ -55,12 +48,6 @@ class OlapTableSchemaParam; class PTupleDescriptor; class PSlotDescriptor; -struct LlvmTupleStruct { - llvm::StructType* tuple_struct; - llvm::PointerType* tuple_ptr; - std::vector indices; -}; - // Location information for null indicator bit for particular slot. // For non-nullable slots, the byte_offset will be 0 and the bit_mask will be 0. // This allows us to do the NullIndicatorOffset operations (tuple + byte_offset &/| @@ -136,14 +123,6 @@ public: std::string debug_string() const; - // Codegen for: bool IsNull(Tuple* tuple) - // The codegen function is cached. - llvm::Function* codegen_is_null(LlvmCodeGen*, llvm::StructType* tuple); - - // Codegen for: void SetNull(Tuple* tuple) / SetNotNull - // The codegen function is cached. - llvm::Function* codegen_update_null(LlvmCodeGen*, llvm::StructType* tuple, bool set_null); - private: friend class DescriptorTbl; friend class TupleDescriptor; @@ -172,11 +151,6 @@ private: const bool _is_materialized; - // Cached codegen'd functions - llvm::Function* _is_null_fn; - llvm::Function* _set_not_null_fn; - llvm::Function* _set_null_fn; - SlotDescriptor(const TSlotDescriptor& tdesc); SlotDescriptor(const PSlotDescriptor& pdesc); }; @@ -347,19 +321,6 @@ public: void to_protobuf(PTupleDescriptor* ptuple) const; - // Creates a typed struct description for llvm. The layout of the struct is computed - // by the FE which includes the order of the fields in the resulting struct. - // Returns the struct type or NULL if the type could not be created. - // For example, the aggregation tuple for this query: select count(*), min(int_col_a) - // would map to: - // struct Tuple { - // int8_t null_byte; - // int32_t min_a; - // int64_t count_val; - // }; - // The resulting struct definition is cached. - llvm::StructType* generate_llvm_struct(LlvmCodeGen* codegen); - private: friend class DescriptorTbl; friend class SchemaScanner; @@ -380,8 +341,6 @@ private: // True if _string_slots or _collection_slots have entries. bool _has_varlen_slots; - llvm::StructType* _llvm_struct; // cache for the llvm struct type for this tuple desc - TupleDescriptor(const TTupleDescriptor& tdesc); TupleDescriptor(const PTupleDescriptor& tdesc); void add_slot(SlotDescriptor* slot); diff --git a/be/src/runtime/mem_pool.cpp b/be/src/runtime/mem_pool.cpp index 95086c1636..d3dab999b8 100644 --- a/be/src/runtime/mem_pool.cpp +++ b/be/src/runtime/mem_pool.cpp @@ -34,7 +34,6 @@ namespace doris { const int MemPool::INITIAL_CHUNK_SIZE; const int MemPool::MAX_CHUNK_SIZE; -const char* MemPool::LLVM_CLASS_NAME = "class.doris::MemPool"; const int MemPool::DEFAULT_ALIGNMENT; uint32_t MemPool::k_zero_length_region_ alignas(std::max_align_t) = MEM_POOL_POISON; diff --git a/be/src/runtime/mem_pool.h b/be/src/runtime/mem_pool.h index 80fda97e2e..2b05fb73dc 100644 --- a/be/src/runtime/mem_pool.h +++ b/be/src/runtime/mem_pool.h @@ -159,10 +159,6 @@ public: MemTracker* mem_tracker() { return mem_tracker_; } - /// TODO: make a macro for doing this - /// For C++/IR interop, we need to be able to look up types by name. - static const char* LLVM_CLASS_NAME; - static const int DEFAULT_ALIGNMENT = 8; private: diff --git a/be/src/runtime/plan_fragment_executor.cpp b/be/src/runtime/plan_fragment_executor.cpp index ff703ebb19..a01ffe7e2d 100644 --- a/be/src/runtime/plan_fragment_executor.cpp +++ b/be/src/runtime/plan_fragment_executor.cpp @@ -22,7 +22,6 @@ #include #include -#include "codegen/llvm_codegen.h" #include "common/logging.h" #include "common/object_pool.h" #include "exec/data_sink.h" @@ -211,21 +210,6 @@ Status PlanFragmentExecutor::prepare(const TExecPlanFragmentParams& request) { // set up profile counters profile()->add_child(_plan->runtime_profile(), true, NULL); _rows_produced_counter = ADD_COUNTER(profile(), "RowsProduced", TUnit::UNIT); -#if 0 - // After preparing the plan and initializing the output sink, all functions should - // have been code-generated. At this point we optimize all the functions. - if (_runtime_state->llvm_codegen() != NULL) { - Status status = _runtime_state->llvm_codegen()->optimize_module(); - - if (!status.ok()) { - LOG(ERROR) << "Error with codegen for this query: " << status.get_error_msg(); - // TODO: propagate this to the coordinator and user? Not really actionable - // for them but we'd like them to let us know. - } - - // If codegen failed, we automatically fall back to not using codegen. - } -#endif _row_batch.reset(new RowBatch( _plan->row_desc(), @@ -240,23 +224,6 @@ Status PlanFragmentExecutor::prepare(const TExecPlanFragmentParams& request) { return Status::OK(); } -void PlanFragmentExecutor::optimize_llvm_module() { - if (!_runtime_state->codegen_created()) { - return; - } - LlvmCodeGen* codegen = NULL; - Status status = _runtime_state->get_codegen(&codegen, /* initalize */ false); - DCHECK(status.ok()); - DCHECK(codegen != NULL); - status = codegen->finalize_module(); - if (!status.ok()) { - std::stringstream ss; - ss << "Error with codegen for this query: "; - _runtime_state->log_error(status.get_error_msg()); - } -} - - void PlanFragmentExecutor::print_volume_ids( const PerNodeScanRanges& per_node_scan_ranges) { if (per_node_scan_ranges.empty()) { @@ -280,8 +247,6 @@ Status PlanFragmentExecutor::open() { _report_thread_active = true; } - optimize_llvm_module(); - Status status = open_internal(); if (!status.ok() && !status.is_cancelled() && _runtime_state->log_has_space()) { diff --git a/be/src/runtime/plan_fragment_executor.h b/be/src/runtime/plan_fragment_executor.h index ff089cb2a3..e78b3dc6c2 100644 --- a/be/src/runtime/plan_fragment_executor.h +++ b/be/src/runtime/plan_fragment_executor.h @@ -241,14 +241,6 @@ private: // sends a final report. void update_status(const Status& status); - /// Optimizes the code-generated functions in runtime_state_->llvm_codegen(). - /// Must be called between plan_->Prepare() and plan_->Open(). - /// This is somewhat time consuming so we don't want it to do it in - /// PlanFragmentExecutor()::Prepare() to allow starting plan fragments more - /// quickly and in parallel (in a deep plan tree, the fragments are started - /// in level order). - void optimize_llvm_module(); - // Executes open() logic and returns resulting status. Does not set _status. // If this plan fragment has no sink, open_internal() does nothing. // If this plan fragment has a sink and open_internal() returns without an diff --git a/be/src/runtime/runtime_state.cpp b/be/src/runtime/runtime_state.cpp index e5188b1489..90479fda47 100644 --- a/be/src/runtime/runtime_state.cpp +++ b/be/src/runtime/runtime_state.cpp @@ -22,7 +22,6 @@ #include "common/logging.h" #include -#include "codegen/llvm_codegen.h" #include "common/object_pool.h" #include "common/status.h" #include "exec/exec_node.h" @@ -196,12 +195,6 @@ Status RuntimeState::init( } _exec_env = exec_env; - if (!query_options.disable_codegen) { - RETURN_IF_ERROR(create_codegen()); - } else { - _codegen.reset(NULL); - } - if (_query_options.max_errors <= 0) { // TODO: fix linker error and uncomment this //_query_options.max_errors = config::max_errors; @@ -310,14 +303,6 @@ Status RuntimeState::create_block_mgr() { return Status::OK(); } -Status RuntimeState::create_codegen() { - RETURN_IF_ERROR(LlvmCodeGen::load_doris_ir( - _obj_pool.get(), print_id(fragment_instance_id()), &_codegen)); - _codegen->enable_optimizations(true); - _profile.add_child(_codegen->runtime_profile(), true, NULL); - return Status::OK(); -} - bool RuntimeState::error_log_is_empty() { boost::lock_guard l(_error_log_lock); return (_error_log.size() > 0); @@ -514,18 +499,6 @@ void RuntimeState::export_load_error(const std::string& err_msg) { } } -Status RuntimeState::get_codegen(LlvmCodeGen** codegen, bool initialize) { - if (_codegen.get() == NULL && initialize) { - RETURN_IF_ERROR(create_codegen()); - } - *codegen = _codegen.get(); - return Status::OK(); -} - -Status RuntimeState::get_codegen(LlvmCodeGen** codegen) { - return get_codegen(codegen, true); -} - // TODO chenhao , check scratch_limit, disable_spilling and file_group // before spillng Status RuntimeState::StartSpilling(MemTracker* mem_tracker) { diff --git a/be/src/runtime/runtime_state.h b/be/src/runtime/runtime_state.h index 688e7fbd41..5c9fe6b223 100644 --- a/be/src/runtime/runtime_state.h +++ b/be/src/runtime/runtime_state.h @@ -46,7 +46,6 @@ class ObjectPool; class Status; class ExecEnv; class Expr; -class LlvmCodeGen; class DateTimeValue; class MemTracker; class DataStreamRecvr; @@ -186,12 +185,6 @@ public: return _root_node_id + 1; } - // Returns true if the codegen object has been created. Note that this may return false - // even when codegen is enabled if nothing has been codegen'd. - bool codegen_created() const { - return _codegen.get() != NULL; - } - // Returns runtime state profile RuntimeProfile* runtime_profile() { return &_profile; @@ -202,18 +195,6 @@ public: return !_query_options.disable_codegen; } - // Returns CodeGen object. Returns NULL if codegen is disabled. - LlvmCodeGen* llvm_codegen() { - return _codegen.get(); - } - // Returns CodeGen object. Returns NULL if the codegen object has not been - // created. If codegen is enabled for the query, the codegen object will be - // created as part of the RuntimeState's initialization. - // Otherwise, it can be created by calling create_codegen(). - LlvmCodeGen* codegen() { - return _codegen.get(); - } - // Create a codegen object in _codegen. No-op if it has already been called. // If codegen is enabled for the query, this is created when the runtime // state is created. If codegen is disabled for the query, this is created @@ -273,12 +254,6 @@ public: // _unreported_error_idx to _errors_log.size() void get_unreported_errors(std::vector* new_errors); - // Returns _codegen in 'codegen'. If 'initialize' is true, _codegen will be created if - // it has not been initialized by a previous call already. If 'initialize' is false, - // 'codegen' will be set to NULL if _codegen has not been initialized. - Status get_codegen(LlvmCodeGen** codegen, bool initialize); - Status get_codegen(LlvmCodeGen** codegen); - bool is_cancelled() const { return _is_cancelled; } @@ -554,7 +529,6 @@ private: TUniqueId _fragment_instance_id; TQueryOptions _query_options; ExecEnv* _exec_env; - boost::scoped_ptr _codegen; // Thread resource management object for this fragment's execution. The runtime // state is responsible for returning this pool to the thread mgr. diff --git a/be/src/runtime/tuple.cpp b/be/src/runtime/tuple.cpp index 0a3fa57456..d191845820 100644 --- a/be/src/runtime/tuple.cpp +++ b/be/src/runtime/tuple.cpp @@ -29,8 +29,6 @@ namespace doris { -const char* Tuple::_s_llvm_class_name = "class.doris::Tuple"; - int64_t Tuple::total_byte_size(const TupleDescriptor& desc) const { int64_t result = desc.byte_size(); if (!desc.has_varlen_slots()) { diff --git a/be/src/runtime/tuple.h b/be/src/runtime/tuple.h index 3d7389d0d5..d6baa6e77e 100644 --- a/be/src/runtime/tuple.h +++ b/be/src/runtime/tuple.h @@ -174,9 +174,6 @@ public: return reinterpret_cast(reinterpret_cast(this) + offset); } - // For C++/IR interop, we need to be able to look up types by name. - static const char* _s_llvm_class_name; - void* get_data() { return this; } std::string to_string(const TupleDescriptor& d) const; diff --git a/be/src/runtime/tuple_row.cpp b/be/src/runtime/tuple_row.cpp index 41ceb66199..5583457956 100644 --- a/be/src/runtime/tuple_row.cpp +++ b/be/src/runtime/tuple_row.cpp @@ -20,7 +20,6 @@ #include namespace doris { -const char* TupleRow::_s_llvm_class_name = "class.doris::TupleRow"; std::string TupleRow::to_string(const RowDescriptor& d) { std::stringstream out; diff --git a/be/src/runtime/tuple_row.h b/be/src/runtime/tuple_row.h index 6416b9ae40..e2851b9f7b 100644 --- a/be/src/runtime/tuple_row.h +++ b/be/src/runtime/tuple_row.h @@ -111,10 +111,6 @@ public: return bytes; } - // TODO: make a macro for doing this - // For C++/IR interop, we need to be able to look up types by name. - static const char* _s_llvm_class_name; - std::string to_string(const RowDescriptor& d); private: Tuple* _tuples[1]; diff --git a/be/test/runtime/data_stream_test.cpp b/be/test/runtime/data_stream_test.cpp index 253cc7afae..85ec3d3396 100644 --- a/be/test/runtime/data_stream_test.cpp +++ b/be/test/runtime/data_stream_test.cpp @@ -24,7 +24,6 @@ #include #include "common/status.h" -#include "codegen/llvm_codegen.h" #include "exprs/slot_ref.h" #include "runtime/row_batch.h" #include "runtime/runtime_state.h" @@ -712,7 +711,6 @@ int main(int argc, char** argv) { doris::CpuInfo::init(); doris::DiskInfo::init(); doris::MemInfo::init(); - doris::LlvmCodeGen::initialize_llvm(); return RUN_ALL_TESTS(); }